Load product positions for the given category.
public getProductPositionsByCategory ( Magento\Catalog\Api\Data\CategoryInterface | integer $category ) : array | ||
$category | Magento\Catalog\Api\Data\CategoryInterface | integer | Category. |
return | array |
/** * List of product that have been moved during the save. * * @param \Magento\Catalog\Model\Category $category Category * * @return array */ private function getAffectedProductIds($category) { $oldPositionProductIds = array_keys($this->saveHandler->getProductPositionsByCategory($category)); $newPositionProductIds = array_keys($category->getSortedProducts()); $affectedProductIds = array_merge($oldPositionProductIds, $newPositionProductIds); if ($category->getAffectedProductIds()) { $affectedProductIds = array_merge($affectedProductIds, $category->getAffectedProductIds()); } return $affectedProductIds; }
/** * Load product saved positions for the current category. * * @param Category $category Category. * * @return array */ private function getProductSavedPositions(Category $category) { $productPositions = []; if ($category->getId()) { $productPositions = $this->productPositionResource->getProductPositionsByCategory($category); } return json_encode($productPositions, JSON_FORCE_OBJECT); }