/** * Saves the passed shop configuration values to the passed * template. * The configuration elements are identified over the * element name. * The values array can contains multiple sub shop values, * which identified over the shopId parameter inside the values array. * * @param Shop\Template $template * @param array $values */ public function saveConfig(Shop\Template $template, array $values) { foreach ($values as $data) { //get the element over the name $element = $this->getElementByName($template->getElements(), $data['elementName']); if (!$element instanceof Shop\TemplateConfig\Element) { continue; } $value = $this->getElementShopValue($element->getValues(), $data['shopId']); /**@var $shop Shop\Shop */ $shop = $this->entityManager->getReference('Shopware\\Models\\Shop\\Shop', $data['shopId']); if ($element->getType() === 'theme-media-selection') { $data['value'] = $this->mediaService->normalize($data['value']); } $value->setShop($shop); $value->setElement($element); $value->setValue($data['value']); } $this->entityManager->flush(); }
/** * @param Option[] $options * @param $imageData * @param $parent Image */ protected function createImagesForOptions($options, $imageData, $parent) { $articleId = $parent->getArticle()->getId(); $imageData['path'] = null; $imageData['parent'] = $parent; $join = ''; foreach ($options as $option) { $alias = 'alias' . $option->getId(); $join = $join . ' INNER JOIN s_article_configurator_option_relations alias' . $option->getId() . ' ON ' . $alias . '.option_id = ' . $option->getId() . ' AND ' . $alias . '.article_id = d.id '; } $sql = "SELECT d.id\n FROM s_articles_details d\n " . $join . "\n WHERE d.articleID = " . (int) $articleId; $details = $this->db->fetchCol($sql); foreach ($details as $detailId) { $detail = $this->manager->getReference(Detail::class, $detailId); $image = new Image(); $image->fromArray($imageData); $image->setArticleDetail($detail); $this->manager->persist($image); } }