-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
Multiple request on product save in backend - fix. Fix getting value for stock_status.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/** | ||
* @package Divante\VsbridgeIndexerCatalog | ||
* @author Agata Firlejczyk <afirlejczyk@divante.pl> | ||
* @copyright 2019 Divante Sp. z o.o. | ||
* @license See LICENSE_DIVANTE.txt for license details. | ||
*/ | ||
|
||
namespace Divante\VsbridgeIndexerCatalog\Console\Command; | ||
|
||
use Divante\VsbridgeIndexerCatalog\Model\Indexer\ProductCategoryProcessor; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
|
||
/** | ||
* Class IndexerReindexCommand | ||
*/ | ||
class IndexerReindexCommand extends \Magento\Indexer\Console\Command\IndexerReindexCommand | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function getIndexers(InputInterface $input) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
afirlejczyk
Contributor
|
||
{ | ||
$indexers = parent::getIndexers($input); | ||
unset($indexers[ProductCategoryProcessor::INDEXER_ID]); | ||
|
||
return $indexers; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<?php | ||
/** | ||
* @package Divante\VsbridgeIndexerCatalog | ||
* @author Agata Firlejczyk <afirlejczyk@divante.pl> | ||
* @copyright 2019 Divante Sp. z o.o. | ||
* @license See LICENSE_DIVANTE.txt for license details. | ||
*/ | ||
|
||
namespace Divante\VsbridgeIndexerCatalog\Model\Indexer; | ||
|
||
use Divante\VsbridgeIndexerCatalog\Model\Indexer\Action\Product as ProductAction; | ||
use Divante\VsbridgeIndexerCore\Indexer\GenericIndexerHandler; | ||
use Divante\VsbridgeIndexerCore\Indexer\StoreManager; | ||
use Divante\VsbridgeIndexerCore\Cache\Processor as CacheProcessor; | ||
|
||
/** | ||
* Class ProductCategory | ||
*/ | ||
class ProductCategory implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface | ||
{ | ||
/** | ||
* @var GenericIndexerHandler | ||
*/ | ||
private $indexHandler; | ||
|
||
/** | ||
* @var ProductAction | ||
*/ | ||
private $productAction; | ||
|
||
/** | ||
* @var StoreManager | ||
*/ | ||
private $storeManager; | ||
|
||
/** | ||
* @var CacheProcessor | ||
*/ | ||
private $cacheProcessor; | ||
|
||
/** | ||
* Category constructor. | ||
* | ||
* @param CacheProcessor $cacheProcessor | ||
* @param GenericIndexerHandler $indexerHandler | ||
* @param StoreManager $storeManager | ||
* @param ProductAction $action | ||
*/ | ||
public function __construct( | ||
CacheProcessor $cacheProcessor, | ||
GenericIndexerHandler $indexerHandler, | ||
StoreManager $storeManager, | ||
ProductAction $action | ||
) { | ||
$this->productAction = $action; | ||
$this->storeManager = $storeManager; | ||
$this->indexHandler = $indexerHandler; | ||
$this->cacheProcessor = $cacheProcessor; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function execute($ids) | ||
{ | ||
$stores = $this->storeManager->getStores(); | ||
|
||
foreach ($stores as $store) { | ||
$this->rebuild($store, $ids); | ||
} | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function executeFull() | ||
{ | ||
$stores = $this->storeManager->getStores(); | ||
|
||
foreach ($stores as $store) { | ||
$this->rebuild($store); | ||
} | ||
} | ||
|
||
/** | ||
* @param \Magento\Store\Api\Data\StoreInterface $store | ||
* @param array $productIds | ||
* | ||
* @throws \Magento\Framework\Exception\NoSuchEntityException | ||
*/ | ||
private function rebuild($store, array $productIds = []) | ||
{ | ||
$this->indexHandler->updateIndex( | ||
$this->productAction->rebuild($store->getId(), $productIds), | ||
$store, | ||
['category_data'] | ||
); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function executeList(array $ids) | ||
{ | ||
$this->execute($ids); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function executeRow($id) | ||
{ | ||
$this->execute([$id]); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
/** | ||
* @package Divante\VsbridgeIndexerCatalog | ||
* @author Agata Firlejczyk <afirlejczyk@divante.pl> | ||
* @copyright 2019 Divante Sp. z o.o. | ||
* @license See LICENSE_DIVANTE.txt for license details. | ||
*/ | ||
|
||
namespace Divante\VsbridgeIndexerCatalog\Model\Indexer; | ||
|
||
/** | ||
* Class ProductCategoryProcessor | ||
*/ | ||
class ProductCategoryProcessor extends \Magento\Framework\Indexer\AbstractProcessor | ||
{ | ||
/** | ||
* Indexer ID | ||
*/ | ||
const INDEXER_ID = 'vsbridge_product_category'; | ||
|
||
/** | ||
* Mark Vsbridge Product indexer as invalid | ||
* | ||
* @return void | ||
*/ | ||
public function markIndexerAsInvalid() | ||
{ | ||
$this->getIndexer()->invalidate(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
/** | ||
* @package Divante\VsbridgeIndexerCatalog | ||
* @author Agata Firlejczyk <afirlejczyk@divante.pl> | ||
* @copyright 2019 Divante Sp. z o.o. | ||
* @license See LICENSE_DIVANTE.txt for license details. | ||
*/ | ||
|
||
namespace Divante\VsbridgeIndexerCatalog\Plugin\Indexer\CatalogInventory; | ||
|
||
/** | ||
* Class ProductsForReindex | ||
*/ | ||
class ProductsForReindex | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $productsForReindex = []; | ||
|
||
/** | ||
* @param array $items | ||
* @return void | ||
*/ | ||
public function setProducts(array $items) | ||
{ | ||
$this->productsForReindex = $items; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getProducts() | ||
{ | ||
return $this->productsForReindex; | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function clear() | ||
{ | ||
$this->productsForReindex = []; | ||
} | ||
} |
This feature/fix is completely disabling the ability to reindex 'vsbridge_product_category' via CLI.
It gets called before any index gets run, and removes 'vsbridge_product_category' from the queue.
I am not aware of what issue this fixes, but in my current project the index is invalid, and it seems impossible to reindex by normal means.