Skip to content

Commit

Permalink
Merge pull request #583 from Nosto/enhancement/ensure-the-emulation-i…
Browse files Browse the repository at this point in the history
…s-cleared

Ensure the emulation is cleared
  • Loading branch information
Hannu Pölönen authored Oct 16, 2019
2 parents b6680b7 + 4b3f17b commit 47d9a14
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.

### 4.0.0-rc.1 (pre-release)
### 4.0.0-rc1 (pre-release)
* Introduce cache for Nosto product data to speedup the product tagging added to the product pages
* Introduce Nosto product data change detection to avoid redundant API calls to Nosto
* Utilize bulk operations for product updates
Expand Down
13 changes: 9 additions & 4 deletions Model/Indexer/AbstractIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ abstract public function getModeSwitcher(): ModeSwitcherInterface;
*
* @param Store $store
* @param array $ids
* @throws Exception
*/
abstract public function doIndex(Store $store, array $ids = []);

Expand Down Expand Up @@ -264,7 +265,6 @@ public function executeByDimensions(array $dimensions, Traversable $entityIds =
}

$storeId = $dimensions[StoreDimensionProvider::DIMENSION_NAME]->getValue();
$this->storeEmulator->startEnvironmentEmulation((int)$storeId);
$store = $this->nostoHelperScope->getStore($storeId);
$benchmarkName = sprintf('STORE-DIMENSION-%s', $store->getCode());
Benchmark::getInstance()->startInstrumentation($benchmarkName, 0);
Expand All @@ -273,8 +273,14 @@ public function executeByDimensions(array $dimensions, Traversable $entityIds =
if ($entityIds !== null) {
$ids = iterator_to_array($entityIds);
}

$this->doIndex($store, $ids);
$this->storeEmulator->startEnvironmentEmulation((int)$storeId);
try {
$this->doIndex($store, $ids);
} catch (Exception $e) {
$this->nostoLogger->error($e->getMessage());
} finally {
$this->storeEmulator->stopEnvironmentEmulation();
}

Benchmark::getInstance()->stopInstrumentation($benchmarkName);
$duration = Benchmark::getInstance()->getElapsed($benchmarkName);
Expand All @@ -285,7 +291,6 @@ public function executeByDimensions(array $dimensions, Traversable $entityIds =
round($duration, 2)
)
);
$this->storeEmulator->stopEnvironmentEmulation();
}

/**
Expand Down
6 changes: 1 addition & 5 deletions Model/Indexer/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ public function getIndexerId(): string
*/
public function doIndex(Store $store, array $ids = [])
{
try {
$this->nostoCacheService->generateProductsInStore($store, $ids);
} catch (NostoException $e) {
$this->nostoLogger->error($e->getMessage());
}
$this->nostoCacheService->generateProductsInStore($store, $ids);
}
}
2 changes: 1 addition & 1 deletion Setup/UpgradeSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
);
}

if (version_compare($fromVersion, '4.0.0-rc.1', '<')) {
if (version_compare($fromVersion, '4.0.0-rc1', '<')) {
$this->createProductCacheTable($setup);
if ($connection->isTableExists(self::PRODUCT_QUEUE_TABLE)) {
$connection->dropTable(self::PRODUCT_QUEUE_TABLE);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nosto/module-nostotagging",
"description": "Increase your conversion rate and average order value by delivering your customers personalized product recommendations throughout their shopping journey.",
"type": "magento2-module",
"version": "4.0.0-rc.1",
"version": "4.0.0-rc1",
"require-dev": {
"php": ">=7.1.0",
"phan/phan": "0.8.8",
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@
<!--suppress XmlUnboundNsPrefix -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Nosto_Tagging" setup_version="4.0.0-rc.1"/>
<module name="Nosto_Tagging" setup_version="4.0.0-rc1"/>
</config>

0 comments on commit 47d9a14

Please sign in to comment.