getManufacturerIds example

public function handlePostFilter(
        CriteriaPartInterface $criteriaPart,
        Criteria $criteria,
        Search $search,
        ShopContextInterface $context
    ) {
        $search->addPostFilter($this->getQuery($criteriaPart));
    }

    private function getQuery(ManufacturerCondition $criteriaPart): TermsQuery
    {
        return new TermsQuery('manufacturer.id', $criteriaPart->getManufacturerIds());
    }
}
/** * @param Manufacturer[] $manufacturers * * @return array<ValueListItem> */
    private function createListItems(Criteria $criteria, array $manufacturers): array
    {
        $actives = [];
        $condition = $criteria->getCondition('manufacturer');
        if ($condition instanceof ManufacturerCondition) {
            $actives = $condition->getManufacturerIds();
        }

        $items = [];
        foreach ($manufacturers as $manufacturer) {
            $items[] = new ValueListItem(
                $manufacturer->getId(),
                $manufacturer->getName(),
                \in_array($manufacturer->getId()$actives),
                $manufacturer->getAttributes()
            );
        }

        
/** * @return int[] */
    private function getActiveIds(Criteria $criteria): array
    {
        $condition = $criteria->getCondition('manufacturer');
        if (!$condition instanceof ManufacturerCondition) {
            return [];
        }

        return $condition->getManufacturerIds();
    }
}
return $condition instanceof OrderedProductOfManufacturerCondition;
    }

    public function handle(ConditionInterface $condition, QueryBuilder $query)
    {
        $this->addCondition($condition$query);
    }

    private function addCondition(OrderedProductOfManufacturerCondition $condition, QueryBuilder $query): void
    {
        $wheres = [];
        foreach ($condition->getManufacturerIds() as $i => $id) {
            $wheres[] = 'customer.ordered_products_of_manufacturer LIKE :manufacturer' . $i;
            $query->setParameter(':manufacturer' . $i, '%|' . $id . '|%');
        }
        $query->andWhere(implode(' OR ', $wheres));
    }
}
public function getDecorated(): AbstractListingFilterHandler
    {
        throw new DecorationPatternException(self::class);
    }

    public function create(Request $request, SalesChannelContext $context): ?Filter
    {
        if (!$request->request->get('manufacturer-filter', true)) {
            return null;
        }

        $ids = $this->getManufacturerIds($request);

        return new Filter(
            'manufacturer',
            !empty($ids),
            [new EntityAggregation('manufacturer', 'product.manufacturerId', 'product_manufacturer')],
            new EqualsAnyFilter('product.manufacturerId', $ids),
            $ids
        );
    }

    /** * @return list<string> */

    public function createManufacturerUrls(ShopContextInterface $context$offset = null, $limit = null)
    {
        $seoSupplier = $this->config->get('sSEOSUPPLIER');
        if (empty($seoSupplier)) {
            return;
        }

        $ids = $this->getManufacturerIds($offset$limit);
        $manufacturers = Shopware()->Container()->get(ManufacturerServiceInterface::class)
            ->getList($ids$context);

        $seoSupplierRouteTemplate = $this->config->get('seoSupplierRouteTemplate');
        foreach ($manufacturers as $manufacturer) {
            $manufacturer = json_decode(json_encode($manufacturer), true);
            $this->data->assign('sSupplier', $manufacturer);
            $path = $this->template->fetch('string:' . $seoSupplierRouteTemplate$this->data);
            $path = $this->sCleanupPath($path);

            $org_path = 'sViewport=listing&sAction=manufacturer&sSupplier=' . (int) $manufacturer['id'];
            
return $condition instanceof NotOrderedProductOfManufacturerCondition;
    }

    public function handle(ConditionInterface $condition, QueryBuilder $query): void
    {
        $this->addCondition($condition$query);
    }

    private function addCondition(NotOrderedProductOfManufacturerCondition $condition, QueryBuilder $query): void
    {
        $likes = [];
        foreach ($condition->getManufacturerIds() as $i => $id) {
            $likes[] = 'ordered_products_of_manufacturer LIKE :manufacturer' . $i;
        }

        $query->where('customernumber NOT IN ( SELECT customernumber FROM s_customer_search_index WHERE ' . implode(' OR ', $likes) . ' )'
        );
        foreach ($condition->getManufacturerIds() as $i => $id) {
            
$query->innerJoin(
            'product',
            's_articles_supplier',
            'manufacturer',
            'manufacturer.id = product.supplierID AND product.supplierID IN (' . $key . ')'
        );

        $query->setParameter(
            $key,
            $condition->getManufacturerIds(),
            Connection::PARAM_INT_ARRAY
        );
    }
}
Home | Imprint | This part of the site doesn't use cookies.