getConfigSets example


    public function getConfigSetsAction()
    {
        $template = $this->Request()->getParam('templateId');
        $template = $this->getRepository()->find($template);

        $this->View()->assign([
            'success' => true,
            'data' => $this->get(Service::class)->getConfigSets($template),
        ]);
    }

    /** * Saves the passed theme configuration. */
    public function save($data)
    {
        $theme = $this->getRepository()->find($data['id']);

        $this->get(Service::class)->saveConfig(
            
// Iterates all configurations sets of the file system         foreach ($collection as $item) {
            if (!$item instanceof ConfigSet) {
                throw new Exception(sprintf("Theme %s adds a configuration set which isn't an instance of Shopware\Components\Theme\ConfigSet.", $theme->getTemplate()));
            }

            $item->validate();

            // Check if this set is already defined, to prevent auto increment in the database.             $existing = $this->getExistingConfigSet(
                $template->getConfigSets(),
                $item->getName()
            );

            // If the set isn't defined, create a new one             if (!$existing instanceof Set) {
                $existing = new Set();
                $template->getConfigSets()->add($existing);
            }

            $existing->setTemplate($template);

            
foreach ($theme['configSets'] as &$set) {
                $set = $this->translateConfigSet($set$namespace);
            }
        }

        $instance = $this->util->getThemeByTemplate($template);

        if ($template->getParent() instanceof Template && $instance->useInheritanceConfig()) {
            $themes = array_merge(
                $themes,
                $this->getConfigSets(
                    $template->getParent()
                )
            );
        }

        return $themes;
    }

    /** * Assigns the passed template id to the passed sub shop. * * @param int $shopId * @param int $templateId * * @throws Exception */
Home | Imprint | This part of the site doesn't use cookies.