/** * {@inheritdoc} */ public function getList(\Magento\Framework\Api\SearchCriteria $searchCriteria) { $quoteCollection = $this->quoteCollectionFactory->create(); $this->extensionAttributesJoinProcessor->process($quoteCollection); $searchData = $this->searchResultsDataFactory->create(); $searchData->setSearchCriteria($searchCriteria); $searchData->setItems($quoteCollection->getItems()); return $searchData; }
/** * Retrieve customers addresses matching the specified criteria. * * @param SearchCriteriaInterface $searchCriteria * @return \Magento\Customer\Api\Data\AddressSearchResultsInterface * @throws \Magento\Framework\Exception\LocalizedException */ public function getList(SearchCriteriaInterface $searchCriteria) { $searchResults = $this->addressSearchResultsFactory->create(); /** @var Collection $collection */ $collection = $this->addressCollectionFactory->create(); $this->extensionAttributesJoinProcessor->process($collection, 'Magento\\Customer\\Api\\Data\\AddressInterface'); // Add filters from root filter group to the collection foreach ($searchCriteria->getFilterGroups() as $group) { $this->addFilterGroupToCollection($group, $collection); } $searchResults->setTotalCount($collection->getSize()); /** @var SortOrder $sortOrder */ foreach ((array) $searchCriteria->getSortOrders() as $sortOrder) { $field = $sortOrder->getField(); $collection->addOrder($field, $sortOrder->getDirection() == SearchCriteriaInterface::SORT_ASC ? 'ASC' : 'DESC'); } $collection->setCurPage($searchCriteria->getCurrentPage()); $collection->setPageSize($searchCriteria->getPageSize()); /** @var \Magento\Customer\Api\Data\AddressInterface[] $addresses */ $addresses = []; /** @var \Magento\Customer\Model\Address $address */ foreach ($collection->getItems() as $address) { $addresses[] = $this->getById($address->getId()); } $searchResults->setItems($addresses); $searchResults->setSearchCriteria($searchCriteria); return $searchResults; }
/** * {@inheritdoc} */ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria) { /** @var \Magento\Tax\Model\ResourceModel\Calculation\Rate\Collection $collection */ $collection = $this->rateFactory->create()->getCollection(); $this->joinProcessor->process($collection); $collection->joinRegionTable(); //Add filters from root filter group to the collection foreach ($searchCriteria->getFilterGroups() as $group) { $this->addFilterGroupToCollection($group, $collection); } $sortOrders = $searchCriteria->getSortOrders(); /** @var SortOrder $sortOrder */ if ($sortOrders) { foreach ($sortOrders as $sortOrder) { $collection->addOrder($this->translateField($sortOrder->getField()), $sortOrder->getDirection() == SortOrder::SORT_ASC ? 'ASC' : 'DESC'); } } $collection->setCurPage($searchCriteria->getCurrentPage()); $collection->setPageSize($searchCriteria->getPageSize()); $taxRate = []; /** @var \Magento\Tax\Model\Calculation\Rate $taxRateModel */ foreach ($collection as $taxRateModel) { $taxRate[] = $taxRateModel; } return $this->taxRateSearchResultsFactory->create()->setItems($taxRate)->setTotalCount($collection->getSize())->setSearchCriteria($searchCriteria); }
/** * {@inheritdoc} */ public function getList(\Magento\Framework\Api\SearchCriteria $searchCriteria) { $this->quoteCollection = $this->getQuoteCollection(); /** @var \Magento\Quote\Api\Data\CartSearchResultsInterface $searchData */ $searchData = $this->searchResultsDataFactory->create(); $searchData->setSearchCriteria($searchCriteria); foreach ($searchCriteria->getFilterGroups() as $group) { $this->addFilterGroupToCollection($group, $this->quoteCollection); } $searchData->setTotalCount($this->quoteCollection->getSize()); $sortOrders = $searchCriteria->getSortOrders(); if ($sortOrders) { /** @var SortOrder $sortOrder */ foreach ($sortOrders as $sortOrder) { $this->quoteCollection->addOrder($sortOrder->getField(), $sortOrder->getDirection() == SortOrder::SORT_ASC ? 'ASC' : 'DESC'); } } $this->quoteCollection->setCurPage($searchCriteria->getCurrentPage()); $this->quoteCollection->setPageSize($searchCriteria->getPageSize()); $this->extensionAttributesJoinProcessor->process($this->quoteCollection); foreach ($this->quoteCollection->getItems() as $quote) { /** @var CartInterface $quote */ $this->getLoadHandler()->load($quote); } $searchData->setItems($this->quoteCollection->getItems()); return $searchData; }
/** * Retrieve coupon. * * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria * @return \Magento\SalesRule\Api\Data\CouponSearchResultInterface * @throws \Magento\Framework\Exception\LocalizedException */ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria) { /** @var \Magento\SalesRule\Model\ResourceModel\Coupon\Collection $collection */ $collection = $this->collectionFactory->create(); $couponInterfaceName = 'Magento\\SalesRule\\Api\\Data\\CouponInterface'; $this->extensionAttributesJoinProcessor->process($collection, $couponInterfaceName); //Add filters from root filter group to the collection /** @var FilterGroup $group */ foreach ($searchCriteria->getFilterGroups() as $group) { $this->addFilterGroupToCollection($group, $collection); } $sortOrders = $searchCriteria->getSortOrders(); if ($sortOrders === null) { $sortOrders = []; } /** @var \Magento\Framework\Api\SortOrder $sortOrder */ foreach ($sortOrders as $sortOrder) { $field = $sortOrder->getField(); $collection->addOrder($field, $sortOrder->getDirection() == SortOrder::SORT_ASC ? 'ASC' : 'DESC'); } $collection->setCurPage($searchCriteria->getCurrentPage()); $collection->setPageSize($searchCriteria->getPageSize()); $coupons = []; /** @var \Magento\SalesRule\Model\Coupon $couponModel */ foreach ($collection->getItems() as $couponModel) { $coupons[] = $couponModel->getData(); } $searchResults = $this->searchResultFactory->create(); $searchResults->setSearchCriteria($searchCriteria); $searchResults->setItems($coupons); $searchResults->setTotalCount($collection->getSize()); return $searchResults; }
/** * {@inheritdoc} */ public function getList(\Magento\Framework\Api\SearchCriteria $searchCriteria) { $searchResults = $this->taxRuleSearchResultsFactory->create(); $searchResults->setSearchCriteria($searchCriteria); $fields = []; $collection = $this->collectionFactory->create(); $this->joinProcessor->process($collection); //Add filters from root filter group to the collection foreach ($searchCriteria->getFilterGroups() as $group) { $this->addFilterGroupToCollection($group, $collection); foreach ($group->getFilters() as $filter) { $fields[] = $this->translateField($filter->getField()); } } if ($fields) { if (in_array('cd.customer_tax_class_id', $fields) || in_array('cd.product_tax_class_id', $fields)) { $collection->joinCalculationData('cd'); } } $searchResults->setTotalCount($collection->getSize()); $sortOrders = $searchCriteria->getSortOrders(); /** @var SortOrder $sortOrder */ if ($sortOrders) { foreach ($sortOrders as $sortOrder) { $collection->addOrder($this->translateField($sortOrder->getField()), $sortOrder->getDirection() == SearchCriteria::SORT_ASC ? 'ASC' : 'DESC'); } } $collection->setCurPage($searchCriteria->getCurrentPage()); $collection->setPageSize($searchCriteria->getPageSize()); $searchResults->setItems($collection->getItems()); return $searchResults; }
/** * @param \Magento\Catalog\Api\Data\ProductInterface $product * @return \Magento\Bundle\Api\Data\OptionInterface[] */ public function getItems(\Magento\Catalog\Api\Data\ProductInterface $product) { $optionCollection = $this->type->getOptionsCollection($product); $this->extensionAttributesJoinProcessor->process($optionCollection); $optionList = []; /** @var \Magento\Bundle\Model\Option $option */ foreach ($optionCollection as $option) { $productLinks = $this->linkList->getItems($product, $option->getOptionId()); /** @var \Magento\Bundle\Api\Data\OptionInterface $optionDataObject */ $optionDataObject = $this->optionFactory->create(); $this->dataObjectHelper->populateWithArray($optionDataObject, $option->getData(), '\\Magento\\Bundle\\Api\\Data\\OptionInterface'); $optionDataObject->setOptionId($option->getOptionId())->setTitle($option->getTitle() === null ? $option->getDefaultTitle() : $option->getTitle())->setSku($product->getSku())->setProductLinks($productLinks); $optionList[] = $optionDataObject; } return $optionList; }
/** * Get downloadable product samples * * @param \Magento\Catalog\Model\Product $product * @return \Magento\Downloadable\Model\Resource\Sample\Collection */ public function getSamples($product) { if ($product->getDownloadableSamples() === null) { $sampleCollection = $this->_samplesFactory->create()->addProductToFilter($product->getId())->addTitleToResult($product->getStoreId()); $this->extensionAttributesJoinProcessor->process($sampleCollection); $product->setDownloadableSamples($sampleCollection); } return $product->getDownloadableSamples(); }
/** * {@inheritdoc} */ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria) { /** @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection $collection */ $collection = $this->collectionFactory->create(); $this->joinProcessor->process($collection); /** The only possible/meaningful search criteria for attribute set is entity type code */ $entityTypeCode = $this->getEntityTypeCode($searchCriteria); if ($entityTypeCode !== null) { $collection->setEntityTypeFilter($this->eavConfig->getEntityType($entityTypeCode)->getId()); } $collection->setCurPage($searchCriteria->getCurrentPage()); $collection->setPageSize($searchCriteria->getPageSize()); $searchResults = $this->searchResultsFactory->create(); $searchResults->setSearchCriteria($searchCriteria); $searchResults->setItems($collection->getItems()); $searchResults->setTotalCount($collection->getSize()); return $searchResults; }
/** * @param int $productId * @param int $storeId * @param bool $requiredOnly * @return \Magento\Catalog\Api\Data\ProductCustomOptionInterface[] */ public function getProductOptions($productId, $storeId, $requiredOnly = false) { $collection = $this->addFieldToFilter('cpe.entity_id', $productId)->addTitleToResult($storeId)->addPriceToResult($storeId)->setOrder('sort_order', 'asc')->setOrder('title', 'asc'); if ($requiredOnly) { $collection->addRequiredFilter(); } $collection->addValuesToResult($storeId); $this->joinProcessor->process($collection); return $collection->getItems(); }
/** * {@inheritdoc} */ public function getList($entityTypeCode, \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria) { if (!$entityTypeCode) { throw InputException::requiredField('entity_type_code'); } /** @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection $attributeCollection */ $attributeCollection = $this->attributeCollectionFactory->create(); $this->joinProcessor->process($attributeCollection); $attributeCollection->addFieldToFilter('entity_type_code', ['eq' => $entityTypeCode]); $attributeCollection->join(['entity_type' => $attributeCollection->getTable('eav_entity_type')], 'main_table.entity_type_id = entity_type.entity_type_id', []); $attributeCollection->joinLeft(['eav_entity_attribute' => $attributeCollection->getTable('eav_entity_attribute')], 'main_table.attribute_id = eav_entity_attribute.attribute_id', []); $entityType = $this->eavConfig->getEntityType($entityTypeCode); $additionalTable = $entityType->getAdditionalAttributeTable(); if ($additionalTable) { $attributeCollection->join(['additional_table' => $attributeCollection->getTable($additionalTable)], 'main_table.attribute_id = additional_table.attribute_id', []); } //Add filters from root filter group to the collection foreach ($searchCriteria->getFilterGroups() as $group) { $this->addFilterGroupToCollection($group, $attributeCollection); } /** @var SortOrder $sortOrder */ foreach ((array) $searchCriteria->getSortOrders() as $sortOrder) { $attributeCollection->addOrder($sortOrder->getField(), $sortOrder->getDirection() == SortOrder::SORT_ASC ? 'ASC' : 'DESC'); } $totalCount = $attributeCollection->getSize(); // Group attributes by id to prevent duplicates with different attribute sets $attributeCollection->addAttributeGrouping(); $attributeCollection->setCurPage($searchCriteria->getCurrentPage()); $attributeCollection->setPageSize($searchCriteria->getPageSize()); $attributes = []; /** @var \Magento\Eav\Api\Data\AttributeInterface $attribute */ foreach ($attributeCollection as $attribute) { $attributes[] = $this->get($entityTypeCode, $attribute->getAttributeCode()); } $searchResults = $this->searchResultsFactory->create(); $searchResults->setSearchCriteria($searchCriteria); $searchResults->setItems($attributes); $searchResults->setTotalCount($totalCount); return $searchResults; }
/** * Find entities by criteria * * @param \Magento\Framework\Api\SearchCriteria $searchCriteria * @return \Magento\Sales\Api\Data\ShipmentItemInterface[] */ public function getList(\Magento\Framework\Api\SearchCriteria $searchCriteria) { $collection = $this->shipmentItemInterfaceSearchResultFactory->create(); $this->extensionAttributesJoinProcessor->process($collection); foreach ($searchCriteria->getFilterGroups() as $filterGroup) { foreach ($filterGroup->getFilters() as $filter) { $condition = $filter->getConditionType() ? $filter->getConditionType() : 'eq'; $collection->addFieldToFilter($filter->getField(), [$condition => $filter->getValue()]); } } $collection->setCurPage($searchCriteria->getCurrentPage()); $collection->setPageSize($searchCriteria->getPageSize()); return $collection; }
/** * @param ProductInterface $product * @return OptionInterface[] */ public function load(ProductInterface $product) { $options = []; /** @var Configurable $typeInstance */ $typeInstance = $product->getTypeInstance(); $attributeCollection = $typeInstance->getConfigurableAttributeCollection($product); $this->extensionAttributesJoinProcessor->process($attributeCollection); foreach ($attributeCollection as $attribute) { $values = []; $attributeOptions = $attribute->getOptions(); if (is_array($attributeOptions)) { foreach ($attributeOptions as $option) { /** @var \Magento\ConfigurableProduct\Api\Data\OptionValueInterface $value */ $value = $this->optionValueFactory->create(); $value->setValueIndex($option['value_index']); $values[] = $value; } } $attribute->setValues($values); $options[] = $attribute; } return $options; }
/** * {@inheritdoc} * * @return \Magento\CheckoutAgreements\Api\Data\AgreementInterface[] Array of checkout agreement data objects. */ public function getList() { if (!$this->scopeConfig->isSetFlag('checkout/options/enable_agreements', ScopeInterface::SCOPE_STORE)) { return []; } $storeId = $this->storeManager->getStore()->getId(); /** @var $agreementCollection AgreementCollection */ $agreementCollection = $this->collectionFactory->create(); $this->extensionAttributesJoinProcessor->process($agreementCollection); $agreementCollection->addStoreFilter($storeId); $agreementCollection->addFieldToFilter('is_active', 1); $agreementDataObjects = []; foreach ($agreementCollection as $agreement) { $agreementDataObjects[] = $agreement; } return $agreementDataObjects; }
/** * {@inheritdoc} */ public function getList(SearchCriteriaInterface $searchCriteria) { $searchResults = $this->searchResultsFactory->create(); $searchResults->setSearchCriteria($searchCriteria); /** @var \Magento\Customer\Model\Resource\Group\Collection $collection */ $collection = $this->groupFactory->create()->getCollection(); $groupInterfaceName = 'Magento\\Customer\\Api\\Data\\GroupInterface'; $this->extensionAttributesJoinProcessor->process($collection, $groupInterfaceName); $collection->addTaxClass(); //Add filters from root filter group to the collection /** @var FilterGroup $group */ foreach ($searchCriteria->getFilterGroups() as $group) { $this->addFilterGroupToCollection($group, $collection); } $sortOrders = $searchCriteria->getSortOrders(); /** @var \Magento\Framework\Api\SortOrder $sortOrder */ if ($sortOrders) { foreach ($searchCriteria->getSortOrders() as $sortOrder) { $field = $this->translateField($sortOrder->getField()); $collection->addOrder($field, $sortOrder->getDirection() == SearchCriteriaInterface::SORT_ASC ? 'ASC' : 'DESC'); } } else { // set a default sorting order since this method is used constantly in many // different blocks $field = $this->translateField('id'); $collection->addOrder($field, 'ASC'); } $collection->setCurPage($searchCriteria->getCurrentPage()); $collection->setPageSize($searchCriteria->getPageSize()); /** @var \Magento\Customer\Api\Data\GroupInterface[] $groups */ $groups = []; /** @var \Magento\Customer\Model\Group $group */ foreach ($collection as $group) { /** @var \Magento\Customer\Api\Data\GroupInterface $groupDataObject */ $groupDataObject = $this->groupDataFactory->create()->setId($group->getId())->setCode($group->getCode())->setTaxClassId($group->getTaxClassId())->setTaxClassName($group->getTaxClassName()); $data = $group->getData(); $data = $this->extensionAttributesJoinProcessor->extractExtensionAttributes($groupInterfaceName, $data); if (isset($data[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]) && $data[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY] instanceof GroupExtensionInterface) { $groupDataObject->setExtensionAttributes($data[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]); } $groups[] = $groupDataObject; } $searchResults->setTotalCount($collection->getSize()); return $searchResults->setItems($groups); }
/** * {@inheritdoc} */ public function getList(\Magento\Framework\Api\SearchCriteria $searchCriteria) { $searchData = $this->searchResultsDataFactory->create(); $searchData->setSearchCriteria($searchCriteria); foreach ($searchCriteria->getFilterGroups() as $group) { $this->addFilterGroupToCollection($group, $this->quoteCollection); } $searchData->setTotalCount($this->quoteCollection->getSize()); $sortOrders = $searchCriteria->getSortOrders(); if ($sortOrders) { foreach ($sortOrders as $sortOrder) { $this->quoteCollection->addOrder($sortOrder->getField(), $sortOrder->getDirection() == SearchCriteria::SORT_ASC ? 'ASC' : 'DESC'); } } $this->quoteCollection->setCurPage($searchCriteria->getCurrentPage()); $this->quoteCollection->setPageSize($searchCriteria->getPageSize()); $this->extensionAttributesJoinProcessor->process($this->quoteCollection); $searchData->setItems($this->quoteCollection->getItems()); return $searchData; }
/** * {@inheritdoc} */ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria) { $attributeSetId = $this->retrieveAttributeSetIdFromSearchCriteria($searchCriteria); if (!$attributeSetId) { throw InputException::requiredField('attribute_set_id'); } try { $this->setRepository->get($attributeSetId); } catch (\Exception $exception) { throw NoSuchEntityException::singleField('attributeSetId', $attributeSetId); } $collection = $this->groupListFactory->create(); $this->joinProcessor->process($collection); $collection->setAttributeSetFilter($attributeSetId); $collection->setSortOrder(); $searchResult = $this->searchResultsFactory->create(); $searchResult->setSearchCriteria($searchCriteria); $searchResult->setItems($collection->getItems()); $searchResult->setTotalCount($collection->getSize()); return $searchResult; }
/** * {@inheritdoc} */ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria) { $searchResults = $this->searchResultsFactory->create(); $searchResults->setSearchCriteria($searchCriteria); /** @var TaxClassCollection $collection */ $collection = $this->taxClassCollectionFactory->create(); $this->joinProcessor->process($collection); foreach ($searchCriteria->getFilterGroups() as $group) { $this->addFilterGroupToCollection($group, $collection); } $searchResults->setTotalCount($collection->getSize()); $sortOrders = $searchCriteria->getSortOrders(); /** @var SortOrder $sortOrder */ if ($sortOrders) { foreach ($searchCriteria->getSortOrders() as $sortOrder) { $collection->addOrder($sortOrder->getField(), $sortOrder->getDirection() == SortOrder::SORT_ASC ? 'ASC' : 'DESC'); } } $collection->setCurPage($searchCriteria->getCurrentPage()); $collection->setPageSize($searchCriteria->getPageSize()); $searchResults->setItems($collection->getItems()); return $searchResults; }
/** * {@inheritdoc} */ public function getList(SearchCriteriaInterface $searchCriteria) { $searchResults = $this->searchResultsFactory->create(); $searchResults->setSearchCriteria($searchCriteria); /** @var \Magento\Customer\Model\ResourceModel\Customer\Collection $collection */ $collection = $this->customerFactory->create()->getCollection(); $this->extensionAttributesJoinProcessor->process($collection, 'Magento\\Customer\\Api\\Data\\CustomerInterface'); // This is needed to make sure all the attributes are properly loaded foreach ($this->customerMetadata->getAllAttributesMetadata() as $metadata) { $collection->addAttributeToSelect($metadata->getAttributeCode()); } // Needed to enable filtering on name as a whole $collection->addNameToSelect(); // Needed to enable filtering based on billing address attributes $collection->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left')->joinAttribute('company', 'customer_address/company', 'default_billing', null, 'left'); //Add filters from root filter group to the collection foreach ($searchCriteria->getFilterGroups() as $group) { $this->addFilterGroupToCollection($group, $collection); } $searchResults->setTotalCount($collection->getSize()); $sortOrders = $searchCriteria->getSortOrders(); if ($sortOrders) { /** @var SortOrder $sortOrder */ foreach ($searchCriteria->getSortOrders() as $sortOrder) { $collection->addOrder($sortOrder->getField(), $sortOrder->getDirection() == SortOrder::SORT_ASC ? 'ASC' : 'DESC'); } } $collection->setCurPage($searchCriteria->getCurrentPage()); $collection->setPageSize($searchCriteria->getPageSize()); $customers = []; /** @var \Magento\Customer\Model\Customer $customerModel */ foreach ($collection as $customerModel) { $customers[] = $customerModel->getDataModel(); } $searchResults->setItems($customers); return $searchResults; }
/** * Retrieve configurable attributes data * * @param \Magento\Catalog\Model\Product $product * @return \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute[] */ public function getConfigurableAttributes($product) { \Magento\Framework\Profiler::start('CONFIGURABLE:' . __METHOD__, ['group' => 'CONFIGURABLE', 'method' => __METHOD__]); if (!$product->hasData($this->_configurableAttributes)) { $configurableAttributes = $this->getConfigurableAttributeCollection($product); $this->extensionAttributesJoinProcessor->process($configurableAttributes); $configurableAttributes->orderByPosition()->load(); $product->setData($this->_configurableAttributes, $configurableAttributes); } \Magento\Framework\Profiler::stop('CONFIGURABLE:' . __METHOD__); return $product->getData($this->_configurableAttributes); }
/** * {@inheritdoc} */ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria) { /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $collection */ $collection = $this->collectionFactory->create(); $this->extensionAttributesJoinProcessor->process($collection); foreach ($this->metadataService->getList($this->searchCriteriaBuilder->create())->getItems() as $metadata) { $collection->addAttributeToSelect($metadata->getAttributeCode()); } $collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner'); $collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner'); //Add filters from root filter group to the collection foreach ($searchCriteria->getFilterGroups() as $group) { $this->addFilterGroupToCollection($group, $collection); } /** @var SortOrder $sortOrder */ foreach ((array) $searchCriteria->getSortOrders() as $sortOrder) { $field = $sortOrder->getField(); $collection->addOrder($field, $sortOrder->getDirection() == SortOrder::SORT_ASC ? 'ASC' : 'DESC'); } $collection->setCurPage($searchCriteria->getCurrentPage()); $collection->setPageSize($searchCriteria->getPageSize()); $collection->load(); $searchResult = $this->searchResultsFactory->create(); $searchResult->setSearchCriteria($searchCriteria); $searchResult->setItems($collection->getItems()); $searchResult->setTotalCount($collection->getSize()); return $searchResult; }
/** * Retrieve configurable attributes data * * @param \Magento\Catalog\Model\Product $product * @return \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute[] */ public function getConfigurableAttributes($product) { \Magento\Framework\Profiler::start('CONFIGURABLE:' . __METHOD__, ['group' => 'CONFIGURABLE', 'method' => __METHOD__]); if (!$product->hasData($this->_configurableAttributes)) { $metadata = $this->getMetadataPool()->getMetadata(ProductInterface::class); $productId = $product->getData($metadata->getLinkField()); $cacheId = __CLASS__ . $productId . '_' . $product->getStoreId(); $configurableAttributes = $this->getCache()->load($cacheId); $configurableAttributes = $this->hasCacheData($configurableAttributes); if ($configurableAttributes) { $configurableAttributes->setProductFilter($product); } else { $configurableAttributes = $this->getConfigurableAttributeCollection($product); $this->extensionAttributesJoinProcessor->process($configurableAttributes); $configurableAttributes->orderByPosition()->load(); $this->getCache()->save(serialize($configurableAttributes), $cacheId, array_merge($product->getIdentities(), [self::TYPE_CODE . '_' . $productId])); } $product->setData($this->_configurableAttributes, $configurableAttributes); } \Magento\Framework\Profiler::stop('CONFIGURABLE:' . __METHOD__); return $product->getData($this->_configurableAttributes); }
/** * Retrieve quote items collection * * @param bool $useCache * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function getItemsCollection($useCache = true) { if ($this->hasItemsCollection()) { return $this->getData('items_collection'); } if (null === $this->_items) { $this->_items = $this->_quoteItemCollectionFactory->create(); $this->extensionAttributesJoinProcessor->process($this->_items); $this->_items->setQuote($this); } return $this->_items; }
/** * Get all options of product * * @return \Magento\Catalog\Api\Data\ProductCustomOptionInterface[]|null */ public function getOptions() { if (empty($this->_options) && $this->getHasOptions() && !$this->optionsInitialized) { $collection = $this->getProductOptionsCollection(); $this->joinProcessor->process($collection); foreach ($collection as $option) { $option->setProduct($this); $this->addOption($option); } $this->optionsInitialized = true; } return $this->_options; }
/** * Retrieve configurable attributes data * * @param \Magento\Catalog\Model\Product $product * @return \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute[] */ public function getConfigurableAttributes($product) { \Magento\Framework\Profiler::start('CONFIGURABLE:' . __METHOD__, ['group' => 'CONFIGURABLE', 'method' => __METHOD__]); if (!$product->hasData($this->_configurableAttributes)) { $cacheId = __CLASS__ . $product->getId(); $configurableAttributes = $this->cache->load($cacheId); if ($configurableAttributes) { $configurableAttributes = unserialize($configurableAttributes); $configurableAttributes->setProductFilter($product); } else { $configurableAttributes = $this->getConfigurableAttributeCollection($product); $this->extensionAttributesJoinProcessor->process($configurableAttributes); $configurableAttributes->orderByPosition()->load(); $this->cache->save(serialize($configurableAttributes), $cacheId, $product->getIdentities()); } $product->setData($this->_configurableAttributes, $configurableAttributes); } \Magento\Framework\Profiler::stop('CONFIGURABLE:' . __METHOD__); return $product->getData($this->_configurableAttributes); }