diff --git a/Helper/Data.php b/Helper/Data.php
index b84ec85ae..eceff1ff3 100644
--- a/Helper/Data.php
+++ b/Helper/Data.php
@@ -179,9 +179,9 @@ class Data extends AbstractHelper
public const XML_PATH_MULTI_CURRENCY = 'nosto/multicurrency/method';
/**
- * Path to the configuration object for light indexer
+ * Path to the configuration object for multi currency
*/
- public const XML_PATH_USE_LIGHT_INDEXER = 'nosto/flags/use_light_indexer';
+ public const XML_PATH_MULTI_INDEXER = 'nosto/product_sync/indexer_method';
/**
* @var string Nosto customer reference attribute name
@@ -203,6 +203,14 @@ class Data extends AbstractHelper
public const SETTING_VALUE_MC_DISABLED = 'disabled';
public const SETTING_VALUE_MC_UNDEFINED = 'undefined';
+ /**
+ * Values of the multi indexer settings
+ */
+ public const SETTING_VALUE_MI_PRODUCT_INDEXER = 'productindexer';
+ public const SETTING_VALUE_MI_PRODUCT_LIGHT_INDEXER = 'productlightindexer';
+ public const SETTING_VALUE_MI_PRODUCT_DISABLED = 'disabled';
+ public const SETTING_VALUE_MI_UNDEFINDED = 'undefined';
+
/**
* Name of the module
*/
@@ -542,14 +550,50 @@ public function getMultiCurrencyMethod(StoreInterface $store = null)
}
/**
- * Returns if the light indexer should be used
+ * Returns if multi indexer is disabled
+ *
+ * @param StoreInterface|null $store the store model or null.
+ * @return bool the configuration value
+ */
+ public function isMultiIndexerDisabled(StoreInterface $store = null)
+ {
+ $storeConfig = $this->getMultiIndexerMethod($store);
+ return ($storeConfig === self::SETTING_VALUE_MI_PRODUCT_DISABLED);
+ }
+
+ /**
+ * Returns if multi indexer is enabled
+ *
+ * @param StoreInterface|null $store the store model or null.
+ * @return bool the configuration value
+ */
+ public function isMultiIndexerMainIndexerEnabled(StoreInterface $store = null)
+ {
+ $storeConfig = $this->getMultiIndexerMethod($store);
+ return ($storeConfig === self::SETTING_VALUE_MI_PRODUCT_INDEXER);
+ }
+
+ /**
+ * Returns if multi indexer is enabled
+ *
+ * @param StoreInterface|null $store the store model or null.
+ * @return bool the configuration value
+ */
+ public function isMultiIndexerLightIndexerEnabled(StoreInterface $store = null)
+ {
+ $storeConfig = $this->getMultiIndexerMethod($store);
+ return ($storeConfig === self::SETTING_VALUE_MI_PRODUCT_LIGHT_INDEXER);
+ }
+
+ /**
+ * Returns the multi indexer setup value / multi indexer_method
*
* @param StoreInterface|null $store the store model or null.
* @return string the configuration value
*/
- public function getUseLightIndexer(StoreInterface $store = null)
+ public function getMultiIndexerMethod(StoreInterface $store = null)
{
- return $this->getStoreConfig(self::XML_PATH_USE_LIGHT_INDEXER, $store);
+ return $this->getStoreConfig(self::XML_PATH_MULTI_INDEXER, $store);
}
/**
diff --git a/Model/Config/Backend/MultiIndexer.php b/Model/Config/Backend/MultiIndexer.php
new file mode 100644
index 000000000..69646a167
--- /dev/null
+++ b/Model/Config/Backend/MultiIndexer.php
@@ -0,0 +1,100 @@
+
+ * @copyright 2020 Nosto Solutions Ltd
+ * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause
+ *
+ */
+
+namespace Nosto\Tagging\Model\Config\Backend;
+
+use Magento\Framework\App\Cache\TypeListInterface;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\Config\Storage\WriterInterface;
+use Magento\Framework\App\Config\Value;
+use Magento\Framework\Data\Collection\AbstractDb;
+use Magento\Framework\Model\Context;
+use Magento\Framework\Model\ResourceModel\AbstractResource;
+use Magento\Framework\Registry;
+use Nosto\Tagging\Helper\Data as NostoHelperData;
+
+class MultiIndexer extends Value
+{
+ private WriterInterface $configWriter;
+
+ /**
+ * MultiCurrency constructor.
+ * @param Context $context
+ * @param Registry $registry
+ * @param ScopeConfigInterface $config
+ * @param TypeListInterface $cacheTypeList
+ * @param WriterInterface $configWriter
+ * @param AbstractResource|null $resource
+ * @param AbstractDb|null $resourceCollection
+ * @param array $data
+ */
+ public function __construct(
+ Context $context,
+ Registry $registry,
+ ScopeConfigInterface $config,
+ TypeListInterface $cacheTypeList,
+ WriterInterface $configWriter,
+ AbstractResource $resource = null,
+ AbstractDb $resourceCollection = null,
+ array $data = []
+ ) {
+ $this->configWriter = $configWriter;
+ parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
+ }
+
+ /**
+ * @return Value
+ */
+ public function beforeSave() //@codingStandardsIgnoreLine
+ {
+ $value = $this->getValue();
+ $scopeType = $this->getScope();
+ $scopeId = $this->getScopeId();
+
+ if ($value == NostoHelperData::SETTING_VALUE_MI_PRODUCT_INDEXER
+ || $value == NostoHelperData::SETTING_VALUE_MI_PRODUCT_LIGHT_INDEXER
+ ) {
+// $this->configWriter->save(
+// NostoHelperData::XML_PATH_PRICING_VARIATION,
+// '0',
+// $scopeType,
+// $scopeId
+// );
+ }
+
+ return parent::beforeSave();
+ }
+}
diff --git a/Model/Config/Source/MultiIndexer.php b/Model/Config/Source/MultiIndexer.php
new file mode 100644
index 000000000..0ca15f0b2
--- /dev/null
+++ b/Model/Config/Source/MultiIndexer.php
@@ -0,0 +1,62 @@
+
+ * @copyright 2020 Nosto Solutions Ltd
+ * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause
+ *
+ */
+
+namespace Nosto\Tagging\Model\Config\Source;
+
+use Magento\Framework\Data\OptionSourceInterface;
+use Magento\Framework\Phrase;
+use Nosto\Tagging\Helper\Data;
+
+/**
+ * Option array class to generate a list of selectable options that allows the merchant to choose
+ * any image attribute for his image tag.
+ */
+class MultiIndexer implements OptionSourceInterface
+{
+ /**
+ * Options getter
+ *
+ * @return array
+ */
+ public function toOptionArray()
+ {
+ return [
+ ['value' => Data::SETTING_VALUE_MI_PRODUCT_INDEXER, 'label' => new Phrase('Product Indexer')],
+ ['value' => Data::SETTING_VALUE_MI_PRODUCT_LIGHT_INDEXER, 'label' => new Phrase('Product light indexer')],
+ ['value' => Data::SETTING_VALUE_MI_PRODUCT_DISABLED, 'label' => new Phrase('Disabled')]
+ ];
+ }
+}
diff --git a/Model/Config/Source/WebsitePublicity.php b/Model/Config/Source/WebsitePublicity.php
new file mode 100644
index 000000000..c897c3228
--- /dev/null
+++ b/Model/Config/Source/WebsitePublicity.php
@@ -0,0 +1,33 @@
+ 1, 'label' => __('Yes')], ['value' => 0, 'label' => __('No')]];
+ }
+
+ /**
+ * Get options in "key-value" format
+ *
+ * @return array
+ */
+ public function toArray()
+ {
+ return [0 => __('No'), 1 => __('Yes')];
+ }
+}
diff --git a/Model/Indexer/LightProductIndexer.php b/Model/Indexer/LightProductIndexer.php
index c92ef4238..c96fe21ab 100644
--- a/Model/Indexer/LightProductIndexer.php
+++ b/Model/Indexer/LightProductIndexer.php
@@ -51,6 +51,7 @@
use Nosto\Tagging\Model\Service\Indexer\IndexerStatusServiceInterface;
use Symfony\Component\Console\Input\InputInterface;
use Nosto\Tagging\Model\Service\Sync\Recrawl\RecrawlService;
+use Nosto\Tagging\Helper\Data as NostoHelperData;
/**
* Class ProductIndexer
@@ -66,6 +67,9 @@ class LightProductIndexer extends AbstractIndexer
/** @var ProductModeSwitcher */
private ProductModeSwitcher $modeSwitcher;
+ /** @var NostoHelperData */
+ protected NostoHelperData $nostoHelperData;
+
/** @var RecrawlService */
private RecrawlService $recrawlService;
@@ -81,6 +85,7 @@ class LightProductIndexer extends AbstractIndexer
* @param InputInterface $input
* @param IndexerStatusServiceInterface $indexerStatusService
* @param RecrawlService $recrawlService
+ * @param NostoHelperData $nostoHelperData
*/
public function __construct(
NostoHelperScope $nostoHelperScope,
@@ -92,11 +97,13 @@ public function __construct(
ProcessManager $processManager,
InputInterface $input,
IndexerStatusServiceInterface $indexerStatusService,
- RecrawlService $recrawlService
+ RecrawlService $recrawlService,
+ NostoHelperData $nostoHelperData
) {
$this->productCollectionBuilder = $productCollectionBuilder;
$this->modeSwitcher = $modeSwitcher;
$this->recrawlService = $recrawlService;
+ $this->nostoHelperData = $nostoHelperData;
parent::__construct(
$nostoHelperScope,
$logger,
@@ -123,10 +130,10 @@ public function getModeSwitcher(): ModeSwitcherInterface
*/
public function doIndex(Store $store, array $ids = [])
{
-// if ($this->nostoHelperData->getUseLightIndexer($store)) {
+ if ($this->nostoHelperData->isMultiIndexerLightIndexerEnabled($store)) {
$collection = $this->getCollection($store, $ids);
$this->recrawlService->recrawl($collection, $store);
-// }
+ }
}
/**
diff --git a/Model/Indexer/ProductIndexer.php b/Model/Indexer/ProductIndexer.php
index c6dc1e725..71b6bd549 100644
--- a/Model/Indexer/ProductIndexer.php
+++ b/Model/Indexer/ProductIndexer.php
@@ -41,6 +41,7 @@
use Magento\Store\Model\App\Emulation;
use Magento\Store\Model\Store;
use Nosto\NostoException;
+use Nosto\Tagging\Helper\Data as NostoHelperData;
use Nosto\Tagging\Helper\Scope as NostoHelperScope;
use Nosto\Tagging\Logger\Logger as NostoLogger;
use Nosto\Tagging\Model\Indexer\Dimensions\Product\ModeSwitcher as ProductModeSwitcher;
@@ -69,6 +70,9 @@ class ProductIndexer extends AbstractIndexer
/** @var ProductModeSwitcher */
private ProductModeSwitcher $modeSwitcher;
+ /** @var NostoHelperData */
+ protected NostoHelperData $nostoHelperData;
+
/**
* Invalidate constructor.
* @param NostoHelperScope $nostoHelperScope
@@ -92,11 +96,13 @@ public function __construct(
Emulation $storeEmulation,
ProcessManager $processManager,
InputInterface $input,
- IndexerStatusServiceInterface $indexerStatusService
+ IndexerStatusServiceInterface $indexerStatusService,
+ NostoHelperData $nostoHelperData
) {
$this->productUpdateService = $productUpdateService;
$this->productCollectionBuilder = $productCollectionBuilder;
$this->modeSwitcher = $modeSwitcher;
+ $this->nostoHelperData = $nostoHelperData;
parent::__construct(
$nostoHelperScope,
$logger,
@@ -123,11 +129,15 @@ public function getModeSwitcher(): ModeSwitcherInterface
*/
public function doIndex(Store $store, array $ids = [])
{
- $collection = $this->getCollection($store, $ids);
- $this->productUpdateService->addCollectionToUpdateMessageQueue(
- $collection,
- $store
- );
+ if ($this->nostoHelperData->isMultiIndexerMainIndexerEnabled($store)) {
+ $collection = $this->getCollection($store, $ids);
+ $this->productUpdateService->addCollectionToUpdateMessageQueue(
+ $collection,
+ $store
+ );
+ } else {
+ $this->nostoLogger->debugWithSource();
+ }
}
/**
diff --git a/Model/Service/AbstractService.php b/Model/Service/AbstractService.php
index 6351e5b3a..d019fb124 100644
--- a/Model/Service/AbstractService.php
+++ b/Model/Service/AbstractService.php
@@ -49,7 +49,7 @@
abstract class AbstractService
{
/** @var NostoDataHelper */
- private NostoDataHelper $nostoDataHelper;
+ protected NostoDataHelper $nostoDataHelper;
/** @var NostoLogger */
private NostoLogger $nostoLogger;
diff --git a/Model/Service/Sync/Recrawl/RecrawlService.php b/Model/Service/Sync/Recrawl/RecrawlService.php
index b30870fd6..7d4434a97 100644
--- a/Model/Service/Sync/Recrawl/RecrawlService.php
+++ b/Model/Service/Sync/Recrawl/RecrawlService.php
@@ -71,6 +71,9 @@ class RecrawlService extends AbstractService
/** @var NostoHelperAccount */
private NostoHelperAccount $nostoHelperAccount;
+ /** @var NostoHelperData */
+ protected NostoHelperData $nostoHelperData;
+
/** @var NostoHelperUrl */
private NostoHelperUrl $nostoHelperUrl;
@@ -99,6 +102,7 @@ public function __construct(
$this->cacheService = $cacheService;
$this->productService = $productService;
$this->nostoHelperAccount = $nostoHelperAccount;
+ $this->nostoHelperData = $nostoHelperData;
$this->nostoHelperUrl = $nostoHelperUrl;
$this->productRepository = $productRepository;
parent::__construct($nostoHelperData, $nostoHelperAccount, $logger);
@@ -115,13 +119,13 @@ public function __construct(
*/
public function recrawl(ProductCollection $collection, Store $store)
{
-// if (!$this->nostoDataHelper->isProductUpdatesEnabled($store)) {
-// $this->logDebugWithStore(
-// 'Nosto product sync is disabled - skipping products recrawl request to Nosto',
-// $store
-// );
-// return;
-// }
+ if (!$this->nostoDataHelper->isProductUpdatesEnabled($store)) {
+ $this->logDebugWithStore(
+ 'Nosto product sync is disabled - skipping products recrawl request to Nosto',
+ $store
+ );
+ return;
+ }
$account = $this->nostoHelperAccount->findAccount($store);
$this->startBenchmark(self::BENCHMARK_RECRAWL_NAME, self::BENCHMARK_RECRAWL_BREAKPOINT);
diff --git a/Model/Service/Sync/Upsert/SyncService.php b/Model/Service/Sync/Upsert/SyncService.php
index fda89b5ae..de40ae3e4 100644
--- a/Model/Service/Sync/Upsert/SyncService.php
+++ b/Model/Service/Sync/Upsert/SyncService.php
@@ -66,7 +66,7 @@ class SyncService extends AbstractService
private NostoHelperUrl $nostoHelperUrl;
/** @var NostoDataHelper */
- private NostoDataHelper $nostoDataHelper;
+ protected NostoDataHelper $nostoDataHelper;
/** @var ProductServiceInterface */
private ProductServiceInterface $productService;
diff --git a/composer.json b/composer.json
index 86278a314..e0f1ab983 100644
--- a/composer.json
+++ b/composer.json
@@ -41,7 +41,7 @@
"php": ">=7.4.0",
"magento/framework": ">=101.0.6|~104.0",
"ext-json": "*",
- "nosto/php-sdk": "^7.4",
+ "nosto/php-sdk": "dev-add-recrawl-endpoint",
"laminas/laminas-uri": "*"
},
"repositories": [
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index 5515e3001..02c829f33 100644
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -159,16 +159,6 @@
Magento\Config\Model\Config\Source\Yesno
-
-
- Warning! Disabling this feature may
- lead to products with incorrect pricing and availability data to be displayed
- in recommendations.]]>
-
- Magento\Config\Model\Config\Source\Yesno
-
@@ -191,22 +181,6 @@
Nosto\Tagging\Model\Config\Source\Memory
-
-
-
-
-
- Nosto\Tagging\Model\Config\Source\ProductsPerRequest
-
-
-
-
-
-
- Nosto\Tagging\Model\Config\Source\TimeBetweenBatchOfRequests
-
@@ -300,6 +274,63 @@
Nosto\Tagging\Block\Adminhtml\Form\Field\Tokens
+
+
+
+
+ Set this to "Product indexer" if your store uses Magento's product regural indexer. If the store view uses light indexer set this to
+ "Product light indexer". If you disable indexer you set this to "Disabled" and Nosto will not try to do any indexer.
+
+ Nosto\Tagging\Model\Config\Source\MultiIndexer
+ Nosto\Tagging\Model\Config\Backend\MultiIndexer
+
+
+
+ productindexer
+
+
+ Warning! Disabling this feature may
+ lead to products with incorrect pricing and availability data to be displayed
+ in recommendations.]]>
+
+ Magento\Config\Model\Config\Source\Yesno
+
+
+
+ productlightindexer
+
+
+
+ Warning! The light recrawl indexer does not currently perform partial API updates with inventory levels. This feature is not yet implemented on Nosto's side.]]>
+
+ Nosto\Tagging\Model\Config\Source\ProductsPerRequest
+
+
+
+ productlightindexer
+
+
+
+ Warning! The light recrawl indexer does not currently perform partial API updates with inventory levels. This feature is not yet implemented on Nosto's side.]]>
+
+ Nosto\Tagging\Model\Config\Source\TimeBetweenBatchOfRequests
+
+
+
+ Set this yes, because the light recrawl indexer only works if the website is publicity
+
+ Nosto\Tagging\Model\Config\Source\WebsitePublicity
+
+
diff --git a/etc/config.xml b/etc/config.xml
index 8e735381a..7dfb2fcbc 100644
--- a/etc/config.xml
+++ b/etc/config.xml
@@ -46,6 +46,13 @@
1
+
+ undefined
+ 1
+ 100
+ 60
+ 1
+
1
1
@@ -56,8 +63,6 @@
0
1
50
- 100
- 60
0
0
1