本文整理汇总了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)]);
}, []);
}
示例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)]);
}, []);
}
示例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;
}
示例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;
}
示例5: getProducts
/**
* @return \Magento\Catalog\Api\Data\ProductSearchResultsInterface
*/
public function getProducts()
{
$filters = $this->buildFilters();
$searchCriteria = $this->buildSearchCriteria($filters);
return $this->productRepository->getList($searchCriteria);
}
示例6: getProducts
/**
* @return \Magento\Catalog\Api\Data\ProductSearchResultsInterface
*/
public function getProducts()
{
$this->addFilterType();
$this->addFilterStatus();
return $this->productRepository->getList($this->searchCriteriaBuilder->create());
}