Smile\ElasticsuiteVirtualCategory\Model\ResourceModel\Category\Product\Position::getProductPositionsByCategory PHP Method

getProductPositionsByCategory() public method

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
    public function getProductPositionsByCategory($category)
    {
        if (is_object($category)) {
            $category = $category->getId();
        }
        $select = $this->getBaseSelect()->where('category_id = ?', (int) $category)->columns(['product_id', 'position']);
        return $this->getConnection()->fetchPairs($select);
    }

Usage Example

 /**
  * 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;
 }
All Usage Examples Of Smile\ElasticsuiteVirtualCategory\Model\ResourceModel\Category\Product\Position::getProductPositionsByCategory