本文整理匯總了PHP中Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface::process方法的典型用法代碼示例。如果您正苦於以下問題:PHP JoinProcessorInterface::process方法的具體用法?PHP JoinProcessorInterface::process怎麽用?PHP JoinProcessorInterface::process使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface
的用法示例。
在下文中一共展示了JoinProcessorInterface::process方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getList
/**
* {@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;
}
示例2: getList
/**
* 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;
}
示例3: getList
/**
* {@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);
}
示例4: getList
/**
* {@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;
}
示例5: getList
/**
* 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;
}
示例6: getList
/**
* {@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;
}
示例7: getItems
/**
* @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;
}
示例8: getSamples
/**
* 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();
}
示例9: getList
/**
* {@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;
}
示例10: getProductOptions
/**
* @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();
}
示例11: getList
/**
* {@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;
}
示例12: getList
/**
* 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;
}
示例13: load
/**
* @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;
}
示例14: getList
/**
* {@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;
}
示例15: getList
/**
* {@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);
}