本文整理汇总了PHP中Magento\Catalog\Model\Category::getAffectedProductIds方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::getAffectedProductIds方法的具体用法?PHP Category::getAffectedProductIds怎么用?PHP Category::getAffectedProductIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Model\Category
的用法示例。
在下文中一共展示了Category::getAffectedProductIds方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: aroundReindex
/**
* Reindex category's products after reindexing the category
*
* @param \Magento\Catalog\Model\Category $subject The cateogry being reindexed
* @param callable $proceed The parent function we are plugged on
* : Magento\Catalog\Model\Category::reindex()
*
* @return \Magento\Catalog\Model\Category
*/
public function aroundReindex(\Magento\Catalog\Model\Category $subject, callable $proceed)
{
$proceed();
if (!empty($subject->getAffectedProductIds())) {
$this->processFullTextIndex($subject->getAffectedProductIds());
}
return;
}
示例2: afterSave
/**
* @param \Magento\Catalog\Model\Category $subject
* @param \Magento\Catalog\Model\Category $result
* @return \Magento\Catalog\Model\Category
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterSave(\Magento\Catalog\Model\Category $subject, \Magento\Catalog\Model\Category $result)
{
/** @var \Magento\Catalog\Model\Category $result */
$productIds = $result->getAffectedProductIds();
if ($productIds) {
$this->productRuleProcessor->reindexList($productIds);
}
return $result;
}
示例3: generateProductUrlRewrites
/**
* Generate url rewrites for products assigned to category
*
* @param Category $category
* @return array
*/
public function generateProductUrlRewrites(Category $category)
{
$this->isSkippedProduct = [];
$saveRewriteHistory = $category->getData('save_rewrites_history');
$storeId = $category->getStoreId();
$productUrls = [];
if ($category->getAffectedProductIds()) {
$this->isSkippedProduct = $category->getAffectedProductIds();
$collection = $this->productCollectionFactory->create()->setStoreId($storeId)->addIdFilter($category->getAffectedProductIds())->addAttributeToSelect('name')->addAttributeToSelect('url_key')->addAttributeToSelect('url_path');
foreach ($collection as $product) {
$product->setStoreId($storeId);
$product->setData('save_rewrites_history', $saveRewriteHistory);
$productUrls = array_merge($productUrls, $this->productUrlRewriteGenerator->generate($product));
}
} else {
$productUrls = array_merge($productUrls, $this->getCategoryProductsUrlRewrites($category, $storeId, $saveRewriteHistory));
}
foreach ($this->childrenCategoriesProvider->getChildren($category, true) as $childCategory) {
$productUrls = array_merge($productUrls, $this->getCategoryProductsUrlRewrites($childCategory, $storeId, $saveRewriteHistory));
}
return $productUrls;
}