Last active
March 1, 2022 08:08
-
-
Save maxout/97ea094c5be78b259944f2dd18cfe778 to your computer and use it in GitHub Desktop.
Shopware: The following example selects a list of products assigned to the category with id 3 and sorts the result set by the cheapest price.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$criteria = new Criteria(); | |
$criteria->limit(10); | |
$criteria->addCondition(new CategoryCondition([3])); | |
$criteria->addSorting(new PriceSorting()); | |
$context = $this->get('shopware_storefront.context_service')->getShopContext(); | |
$service = $this->get('shopware_search.product_number_search'); | |
/**@var $result ProductNumberSearchResult*/ | |
$result = $service->search($criteria, $context); | |
$numbers = []; | |
foreach($result->getProducts() as $product) { | |
$numbers[] = $product->getNumber(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment