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

Init recrawl light indexer #860

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from
Draft
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
92 changes: 92 additions & 0 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ class Data extends AbstractHelper
*/
public const XML_PATH_INDEXER_MEMORY = 'nosto/flags/indexer_memory';

/**
* Product per request
*/
public const XML_PATH_PRODUCT_PER_REQUEST = 'nosto/flags/product_per_request';

/**
* Request timeout
*/
public const XML_PATH_REQUEST_TIMEOUT = 'nosto/flags/request_timeout';

/**
* Path to the configuration object that stores the preference for indexing disabled products
*/
Expand Down Expand Up @@ -168,6 +178,11 @@ class Data extends AbstractHelper
*/
public const XML_PATH_MULTI_CURRENCY = 'nosto/multicurrency/method';

/**
* Path to the configuration object for multi currency
*/
public const XML_PATH_MULTI_INDEXER = 'nosto/product_sync/indexer_method';

/**
* @var string Nosto customer reference attribute name
*/
Expand All @@ -188,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
*/
Expand Down Expand Up @@ -436,6 +459,28 @@ public function getIndexerMemory(StoreInterface $store = null)
return $this->getStoreConfig(self::XML_PATH_INDEXER_MEMORY, $store);
}

/**
* Products per request
*
* @param StoreInterface|null $store the store model or null.
* @return int the configuration value
*/
public function getProductsPerRequest(StoreInterface $store = null)
{
return $this->getStoreConfig(self::XML_PATH_PRODUCT_PER_REQUEST, $store);
}

/**
* Request timeout
*
* @param StoreInterface|null $store the store model or null.
* @return int the configuration value
*/
public function getRequestTimeout(StoreInterface $store = null)
{
return $this->getStoreConfig(self::XML_PATH_REQUEST_TIMEOUT, $store);
}

/**
* Returns maximum percentage of PHP available memory that indexer should use
*
Expand Down Expand Up @@ -504,6 +549,53 @@ public function getMultiCurrencyMethod(StoreInterface $store = null)
return $this->getStoreConfig(self::XML_PATH_MULTI_CURRENCY, $store);
}

/**
* 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 getMultiIndexerMethod(StoreInterface $store = null)
{
return $this->getStoreConfig(self::XML_PATH_MULTI_INDEXER, $store);
}

/**
* Saves the multi currency setup value / multi currency method
*
Expand Down
100 changes: 100 additions & 0 deletions Model/Config/Backend/MultiIndexer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php
/**
* Copyright (c) 2020, Nosto Solutions Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @author Nosto Solutions Ltd <[email protected]>
* @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();
}
}
62 changes: 62 additions & 0 deletions Model/Config/Source/MultiIndexer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/**
* Copyright (c) 2020, Nosto Solutions Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @author Nosto Solutions Ltd <[email protected]>
* @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')]
];
}
}
59 changes: 59 additions & 0 deletions Model/Config/Source/ProductsPerRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
* Copyright (c) 2020, Nosto Solutions Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @author Nosto Solutions Ltd <[email protected]>
* @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;

class ProductsPerRequest implements OptionSourceInterface
{
/**
* Options getter
*
* @return array
*/
public function toOptionArray()
{
return [
['value' => 100, 'label' => new Phrase('100')],
['value' => 200, 'label' => new Phrase('200')],
['value' => 300, 'label' => new Phrase('300')],
['value' => 400, 'label' => new Phrase('400')],
['value' => 500, 'label' => new Phrase('500')],
];
}
}
Loading
Loading