當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。