getSorter example

$result = new LineItemGroupBuilderResult();

        // filter out all promotion items         $cartProducts = $this->lineItemProvider->getProducts($cart);

        // split quantities into separate line items         // so we have a real list of products like we would have         // them when holding it in our actual hands.         $restOfCart = $this->splitQuantities($cartProducts$context);

        foreach ($groupDefinitions as $groupDefinition) {
            $sorter = $this->registry->getSorter($groupDefinition->getSorterKey());
            $packager = $this->registry->getPackager($groupDefinition->getPackagerKey());

            // we have to sort our items first             // otherwise it would be a "random" order when             // adjusting the rest of our cart...             $restOfCart = $sorter->sort($restOfCart);

            // try as long as groups can be             // found for the current definition             while (true) {
                $itemsToConsider = $this->ruleMatcher->getMatchingItems($groupDefinition$restOfCart$context);

                

        $sorter = new LineItemGroupPriceAscSorter();

        $packagers = [];
        $sorters = [
            $sorter,
            new LineItemGroupPriceDescSorter(),
        ];

        $registry = new LineItemGroupServiceRegistry($packagers$sorters);

        static::assertSame($sorter$registry->getSorter($sorter->getKey()));
    }
}
$sorterKey = $discount->getFilterSorterKey();
        $applierKey = $discount->getFilterApplierKey();
        $countKey = $discount->getFilterUsageKey();

        $filteredPackages = [];

        if (!$this->hasFilterSettings($sorterKey$applierKey$countKey)) {
            return new DiscountPackageCollection($packages);
        }

        // now sort each found package depending on our configured sorter         $sortedPackages = $this->registry->getSorter($sorterKey)->sort($packages);

        // calculate an additional maximal count         // of items that need to be discounted         $maxUsage = new MaxUsage();
        $maxItems = $maxUsage->getMaxItemCount($applierKey$countKey$originalPackageCount);

        // get all index entries for         // the items that need to be discounted         $applier = new Applier();
        $applierIndexes = $applier->findIndexes($applierKey$maxItems$sortedPackages->count()$originalPackageCount);

        
Home | Imprint | This part of the site doesn't use cookies.