Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove catalog index price update by schedule subscription #870

Merged
merged 5 commits into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions Setup/UpgradeSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,34 @@
use Magento\Framework\App\Config\ConfigResource\ConfigInterface;
use Magento\Framework\App\ProductMetadataInterface;
use Magento\Framework\DB\Ddl\Table;
use Magento\Framework\Indexer\IndexerInterfaceFactory;
use Magento\Framework\Mview\View\SubscriptionFactory;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\UpgradeSchemaInterface;

class UpgradeSchema implements UpgradeSchemaInterface
{
/**
* @var ConfigInterface
*/
private $config;

/**
* @var IndexerInterfaceFactory
*/
private $indexerFactory;

/**
* @var ProductMetadataInterface
*/
private $productMetadata;

/**
* @var SubscriptionFactory
*/
private $subscriptionFactory;

private $defaultConfigData = [
'algoliasearch_credentials/credentials/enable_backend' => '1',
'algoliasearch_credentials/credentials/enable_frontend' => '1',
Expand Down Expand Up @@ -242,10 +260,16 @@ class UpgradeSchema implements UpgradeSchemaInterface
],
];

public function __construct(ConfigInterface $config, ProductMetadataInterface $productMetadata)
{
public function __construct(
ConfigInterface $config,
IndexerInterfaceFactory $indexerFactory,
ProductMetadataInterface $productMetadata,
SubscriptionFactory $subscriptionFactory
) {
$this->config = $config;
$this->indexerFactory = $indexerFactory;
$this->productMetadata = $productMetadata;
$this->subscriptionFactory = $subscriptionFactory;

$this->serializeDefaultArrayConfigData();
$this->mergeDefaultDataWithArrayData();
Expand Down Expand Up @@ -563,6 +587,20 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
$connection->createTable($table);
}

if (version_compare($context->getVersion(), '1.12.0', '<')) {
// @see \Magento\Framework\Mview\View::unsubscribe
/** @var \Magento\Framework\Indexer\IndexerInterface $indexer */
$indexer = $this->indexerFactory->create()->load('algolia_products');
$subscriptionInstance = $this->subscriptionFactory->create(
[
'view' => $indexer->getView(),
'tableName' => 'catalog_product_index_price',
'columnName' => 'entity_id',
]
);
$subscriptionInstance->remove();
}

$setup->endSetup();
}

Expand Down
1 change: 0 additions & 1 deletion etc/mview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
<table name="catalog_product_website" entity_column="product_id" />
<table name="catalog_category_product" entity_column="product_id" />
<table name="cataloginventory_stock_item" entity_column="product_id" />
<table name="catalog_product_index_price" entity_column="entity_id" />
</subscriptions>
</view>
</config>