setShops example



        if (Shopware()->Container()->get('auth')->getIdentity()->id) {
            $user = $this->get('models')->find(User::classShopware()->Container()->get('auth')->getIdentity()->id);
            $emotion->setUser($user);
        }

        $emotion->setModified(new DateTime());
        $emotion->setName($data['name']);
        $emotion->setValidFrom($validFrom);
        $emotion->setValidTo($validTo);
        $emotion->setShops($shops);
        $emotion->setCategories($categories);
        $emotion->setElements($elements);
        $emotion->setTemplate($template);
        $emotion->setParentId(!empty($data['parentId']) ? $data['parentId'] : null);
        $emotion->setActive(!empty($data['active']));
        $emotion->setPosition(!empty($data['position']) ? $data['position'] : 1);
        $emotion->setShowListing(!empty($data['showListing']));
        $emotion->setFullscreen(!empty($data['fullscreen']));
        $emotion->setDevice((!empty($data['device']) || $data['device'] === '0') ? $data['device'] : null);
        $emotion->setMode($data['mode']);
        $emotion->setRows($data['rows']);
        
$params = $this->prepareCustomerGroupsAssociatedData($params);
        $params = $this->prepareMediaAssociatedData($params);

        unset($params['articles']$params['emotion']$params['imagePath']$params['parentId']$params['parent']);

        if (!\array_key_exists('template', $params)) {
            $params['template'] = null;
        }

        $params['changed'] = new DateTime();
        $categoryModel->fromArray($params);
        $categoryModel->setShops($this->Request()->getParam('shops'));
        $this->em->persist($categoryModel);
        $this->em->flush();

        $categoryId = $categoryModel->getId();
        /** @var Query<array<string, mixed>> $query */
        $query = $repo->getBackendDetailQuery($categoryId)->getQuery();
        $query->setHydrationMode(AbstractQuery::HYDRATE_ARRAY);
        $paginator = $this->em->createPaginator($query);
        $data = iterator_to_array($paginator);
        $data = $data[0];
        $data['imagePath'] = $data['media']['path'] ?? null;

        
foreach ($shopPages as $page) {
            $shopIds += (array) $page->getShopIds();
        }

        $shops = $this->shopGateway->getList(array_keys(array_flip($shopIds)));

        foreach ($shopPages as $page) {
            $pageShops = array_filter($shopsfunction DShop $shop) use ($page) {
                return \array_key_exists($shop->getId()$page->getShopIds());
            });

            $page->setShops($pageShops);
        }
    }

    /** * @param array<int, ShopPage> $shopPages */
    private function resolveChildren(array $shopPages, ShopContextInterface $context): void
    {
        $ids = array_map(function DShopPage $page) {
            return $page->getId();
        }$shopPages);

        


        $struct->setOrderCount((int) ($data['count_orders'] ?? 0));
        $struct->setTotalAmount((float) ($data['invoice_amount_sum'] ?? 0.0));
        $struct->setAvgAmount((float) ($data['invoice_amount_avg'] ?? 0.0));
        $struct->setMinAmount((float) ($data['invoice_amount_min'] ?? 0.0));
        $struct->setMaxAmount((float) ($data['invoice_amount_max'] ?? 0.0));
        $struct->setAvgProductPrice((float) ($data['product_avg'] ?? 0.0));
        $struct->setFirstOrderTime(isset($data['first_order_time']) ? new DateTime($data['first_order_time']) : null);
        $struct->setLastOrderTime(isset($data['last_order_time']) ? new DateTime($data['last_order_time']) : null);
        $struct->setPayments(array_map('\intval', $this->explodeAndFilter($data['selected_payments'] ?? '')));
        $struct->setShops(array_map('\intval', $this->explodeAndFilter($data['ordered_in_shops'] ?? '')));
        $struct->setDevices($this->explodeAndFilter($data['ordered_with_devices'] ?? ''));
        $struct->setDispatches(array_map('\intval', $this->explodeAndFilter($data['selected_dispachtes'] ?? '')));
        $struct->setWeekdays($this->explodeAndFilter($data['weekdays'] ?? ''));

        if (\array_key_exists('product_numbers', $data)) {
            $struct->setProducts($this->explodeAndFilter($data['product_numbers'] ?? ''));
        }
        if (\array_key_exists('category_ids', $data)) {
            $struct->setCategories(array_map('\intval', $this->explodeAndFilter($data['category_ids'] ?? '')));
        }
        if (\array_key_exists('manufacturer_ids', $data)) {
            
$shopIds = array_keys(array_flip(array_merge(...$shopIds)));
        $shopIds = array_filter($shopIds);

        if (empty($shopIds)) {
            return;
        }

        $shops = $this->shopGateway->getList($shopIds);

        /** @var Emotion $emotion */
        foreach ($emotions as $emotion) {
            $emotion->setShops(
                array_intersect_key($shopsarray_flip($emotion->getShopIds()))
            );
        }
    }
}
Home | Imprint | This part of the site doesn't use cookies.