PHP Class Smile\ElasticsuiteVirtualCategory\Plugin\Catalog\Category\SaveProductsPositions

Author: Aurelien FOUCRET ([email protected])
Inheritance: extends Smile\ElasticsuiteCatalog\Plugin\Indexer\AbstractIndexerPlugin
Show file Open project: smile-sa/elasticsuite

Public Methods

Method Description
__construct ( Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, Full $fullIndexer, Position $saveHandler, Magento\Framework\Json\Helper\Data $jsonHelper ) ReindexProductsAfterSave constructor.
aroundSave ( Magento\Catalog\Model\ResourceModel\Category $categoryResource, Closure $proceed, Magento\Framework\Model\AbstractModel $category ) : Magento\Catalog\Model\ResourceModel\Category Resource model save function plugin.

Private Methods

Method Description
getAffectedProductIds ( Magento\Catalog\Model\Category $category ) : array List of product that have been moved during the save.
unserializeProductPositions ( Magento\Catalog\Model\Category $category ) : array Unserialize the sorted_products field of category if it is a string value.

Method Details

__construct() public method

ReindexProductsAfterSave constructor.
public __construct ( Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, Full $fullIndexer, Position $saveHandler, Magento\Framework\Json\Helper\Data $jsonHelper )
$indexerRegistry Magento\Framework\Indexer\IndexerRegistry The indexer registry.
$fullIndexer Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Indexer\Fulltext\Action\Full The Full Indexer
$saveHandler Smile\ElasticsuiteVirtualCategory\Model\ResourceModel\Category\Product\Position Product position save handler.
$jsonHelper Magento\Framework\Json\Helper\Data JSON Helper.

aroundSave() public method

Append a commit callback to save the product positions.
public aroundSave ( Magento\Catalog\Model\ResourceModel\Category $categoryResource, Closure $proceed, Magento\Framework\Model\AbstractModel $category ) : Magento\Catalog\Model\ResourceModel\Category
$categoryResource Magento\Catalog\Model\ResourceModel\Category Category original resource model.
$proceed Closure Original save method.
$category Magento\Framework\Model\AbstractModel Saved category.
return Magento\Catalog\Model\ResourceModel\Category