当前位置: 首页>>代码示例>>PHP>>正文


PHP ProductRepositoryInterface::getList方法代码示例

本文整理汇总了PHP中Magento\Catalog\Api\ProductRepositoryInterface::getList方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductRepositoryInterface::getList方法的具体用法?PHP ProductRepositoryInterface::getList怎么用?PHP ProductRepositoryInterface::getList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Catalog\Api\ProductRepositoryInterface的用法示例。


在下文中一共展示了ProductRepositoryInterface::getList方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getProductStatusMatchingSku

 /**
  * @param string $sku
  * @return string[]
  */
 public function getProductStatusMatchingSku($sku)
 {
     $this->validateSku($sku);
     $this->searchCriteriaBuilder->addFilter('sku', '%' . $sku . '%', 'like');
     $result = $this->productRepository->getList($this->searchCriteriaBuilder->create());
     return array_reduce($result->getItems(), function ($acc, ProductInterface $product) {
         return array_merge($acc, [$product->getSku() => $this->getStatusAsString($product)]);
     }, []);
 }
开发者ID:nhp,项目名称:MageTitans_ProductStatus,代码行数:13,代码来源:ProductStatusAdapter.php

示例2: getStatusForProductsMatchingSku

 /**
  * @param string $sku
  * @return string[]
  */
 public function getStatusForProductsMatchingSku($sku)
 {
     $this->validateSku($sku);
     $this->searchCriteriaBuilder->addFilter('sku', $this->getLikeSkuExpression($sku), 'like');
     $productList = $this->productRepository->getList($this->searchCriteriaBuilder->create());
     return array_reduce($productList->getItems(), function (array $carry, ProductInterface $product) {
         return array_merge($carry, [$product->getSku() => $this->getStatusString($product)]);
     }, []);
 }
开发者ID:Vinai,项目名称:MM15PL_ProductStatus,代码行数:13,代码来源:ProductStatusAdapter.php

示例3: getItems

 /**
  * getItems method
  *
  * @return array
  */
 public function getItems()
 {
     $result = [];
     $query = $this->queryFactory->get()->getQueryText();
     $productIds = $this->searchProductsFullText($query);
     // Check if products are found
     if ($productIds) {
         $searchCriteria = $this->searchCriteriaBuilder->addFilter('entity_id', $productIds, 'in')->create();
         $products = $this->productRepository->getList($searchCriteria);
         foreach ($products->getItems() as $product) {
             $image = $this->imageHelper->init($product, 'product_page_image_small')->getUrl();
             $resultItem = $this->itemFactory->create(['title' => $product->getName(), 'price' => $this->priceCurrency->format($product->getPriceInfo()->getPrice('regular_price')->getAmount()->getValue(), false), 'special_price' => $this->priceCurrency->format($product->getPriceInfo()->getPrice('special_price')->getAmount()->getValue(), false), 'has_special_price' => $product->getSpecialPrice() > 0 ? true : false, 'image' => $image, 'url' => $product->getProductUrl()]);
             $result[] = $resultItem;
         }
     }
     return $result;
 }
开发者ID:sebwite,项目名称:magento2-smartsearch,代码行数:22,代码来源:SearchDataProvider.php

示例4: getItems

 /**
  * {@inheritdoc}
  */
 public function getItems()
 {
     $result = [];
     $query = $this->queryFactory->get()->getQueryText();
     $productIds = $this->searchProductsFullText($query);
     // Check if products are found
     if ($productIds) {
         $searchCriteria = $this->searchCriteriaBuilder->addFilter('entity_id', $productIds, 'in')->create();
         $products = $this->productRepository->getList($searchCriteria);
         $baseUrl = $this->storeManager->getStore()->getBaseUrl();
         // Loop through products
         foreach ($products->getItems() as $product) {
             $resultItem = $this->itemFactory->create(['title' => $product->getName(), 'price' => $this->priceCurrency->format($product->getFinalPrice(), false), 'special_price' => $this->priceCurrency->format($product->getSpecialPrice(), false), 'has_special_price' => $product->getSpecialPrice() > 0 ? true : false, 'image' => str_replace('index.php/', '', $baseUrl) . '/pub/media/catalog/product' . $product->getImage(), 'url' => $product->getProductUrl()]);
             $result[] = $resultItem;
         }
     }
     return $result;
 }
开发者ID:srbarba,项目名称:Magento2-SmartSearch,代码行数:21,代码来源:SearchDataProvider.php

示例5: getProducts

 /**
  * @return \Magento\Catalog\Api\Data\ProductSearchResultsInterface
  */
 public function getProducts()
 {
     $filters = $this->buildFilters();
     $searchCriteria = $this->buildSearchCriteria($filters);
     return $this->productRepository->getList($searchCriteria);
 }
开发者ID:philipusmartin,项目名称:magento2-c2c,代码行数:9,代码来源:ProductList.php

示例6: getProducts

 /**
  * @return \Magento\Catalog\Api\Data\ProductSearchResultsInterface
  */
 public function getProducts()
 {
     $this->addFilterType();
     $this->addFilterStatus();
     return $this->productRepository->getList($this->searchCriteriaBuilder->create());
 }
开发者ID:stefandoorn,项目名称:magento2-console-productlist,代码行数:9,代码来源:Productlist.php


注:本文中的Magento\Catalog\Api\ProductRepositoryInterface::getList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。