Skip to content

Commit

Permalink
Configure ModeSwithcers, Refinement CategoryIndexer Class, preparatio…
Browse files Browse the repository at this point in the history
…n of logic for new indexer
  • Loading branch information
ugljesaspx committed Aug 28, 2024
1 parent adb846e commit 95324ee
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Model/Indexer/AbstractIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
use Nosto\Tagging\Helper\Scope as NostoHelperScope;
use Nosto\Tagging\Logger\Logger as NostoLogger;
use Nosto\Tagging\Model\Indexer\Dimensions\AbstractDimensionModeConfiguration as DimensionModeConfiguration;
use Nosto\Tagging\Model\Indexer\Dimensions\ModeSwitch\ModeSwitcherInterface;
use Nosto\Tagging\Model\Indexer\Dimensions\ModeSwitcher\ModeSwitcherInterface;
use Nosto\Tagging\Model\Indexer\Dimensions\StoreDimensionProvider;
use Nosto\Tagging\Model\Service\Indexer\IndexerStatusServiceInterface;
use Nosto\Tagging\Util\Benchmark;
Expand Down
22 changes: 19 additions & 3 deletions Model/Indexer/CategoryIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
use Nosto\NostoException;
use Nosto\Tagging\Helper\Scope as NostoHelperScope;
use Nosto\Tagging\Logger\Logger as NostoLogger;
use Nosto\Tagging\Model\Indexer\Dimensions\ModeSwitch\ModeSwitcher as CategoryModeSwitcher;
use Nosto\Tagging\Model\Indexer\Dimensions\ModeSwitch\ModeSwitcherInterface;
use Nosto\Tagging\Model\Indexer\Dimensions\ModeSwitcher\ModeSwitcher as CategoryModeSwitcher;
use Nosto\Tagging\Model\Indexer\Dimensions\ModeSwitcher\ModeSwitcherInterface;
use Nosto\Tagging\Model\Indexer\Dimensions\StoreDimensionProvider;
use Nosto\Tagging\Model\ResourceModel\Magento\Category\Collection as CategoryCollection;
use Nosto\Tagging\Model\ResourceModel\Magento\Category\CollectionBuilder;
Expand All @@ -66,11 +66,15 @@ class CategoryIndexer extends AbstractIndexer
/** @var CategoryModeSwitcher */
private CategoryModeSwitcher $modeSwitcher;

/** @var CollectionBuilder */
private CollectionBuilder $categoryCollectionBuilder;

/**
* Constructor.
* @param NostoHelperScope $nostoHelperScope
* @param CategoryUpdateService $categoryUpdateService
* @param NostoLogger $logger
* @param CollectionBuilder $categoryCollectionBuilder
* @param CategoryModeSwitcher $modeSwitcher
* @param StoreDimensionProvider $dimensionProvider
* @param Emulation $storeEmulation
Expand All @@ -82,6 +86,7 @@ public function __construct(
NostoHelperScope $nostoHelperScope,
CategoryUpdateService $categoryUpdateService,
NostoLogger $logger,
CollectionBuilder $categoryCollectionBuilder,
CategoryModeSwitcher $modeSwitcher,
StoreDimensionProvider $dimensionProvider,
Emulation $storeEmulation,
Expand All @@ -91,6 +96,8 @@ public function __construct(
) {
$this->categoryUpdateService = $categoryUpdateService;
$this->modeSwitcher = $modeSwitcher;
$this->categoryCollectionBuilder = $categoryCollectionBuilder;

parent::__construct(
$nostoHelperScope,
$logger,
Expand Down Expand Up @@ -139,7 +146,16 @@ public function getIndexerId(): string
*/
public function getCollection(Store $store, array $ids = []) //: CategoryCollection
{
// @TODO: implement
$this->categoryCollectionBuilder->initDefault($store);

if (!empty($ids)) {
$this->categoryCollectionBuilder->withIds($ids);
} else {
$this->categoryCollectionBuilder->withStore($store);
}

return null;
// @TODO: Implement logic

Check warning on line 158 in Model/Indexer/CategoryIndexer.php

View workflow job for this annotation

GitHub Actions / Code Sniffer

Comment refers to a TODO task "Implement logic"
// return $this->categoryCollectionBuilder->build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*
*/

namespace Nosto\Tagging\Model\Indexer\Dimensions\ModeSwitch;
namespace Nosto\Tagging\Model\Indexer\Dimensions\ModeSwitcher;

use Nosto\Tagging\Model\Indexer\Dimensions\AbstractDimensionModeConfiguration;

Expand Down
2 changes: 1 addition & 1 deletion Model/Indexer/Dimensions/ModeSwitcher/ModeSwitcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*
*/

namespace Nosto\Tagging\Model\Indexer\Dimensions\ModeSwitch;
namespace Nosto\Tagging\Model\Indexer\Dimensions\ModeSwitcher;

use Magento\Indexer\Model\DimensionMode;
use Magento\Indexer\Model\DimensionModes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*
*/

namespace Nosto\Tagging\Model\Indexer\Dimensions\ModeSwitch;
namespace Nosto\Tagging\Model\Indexer\Dimensions\ModeSwitcher;

use InvalidArgumentException;
use Magento\Framework\App\Cache\TypeListInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*
*/

namespace Nosto\Tagging\Model\Indexer\Dimensions\ModeSwitch;
namespace Nosto\Tagging\Model\Indexer\Dimensions\ModeSwitcher;

use Magento\Indexer\Model\ModeSwitcherInterface as MagentoModeSwitcherInterface;

Expand Down
4 changes: 2 additions & 2 deletions Model/Indexer/ProductIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
use Nosto\NostoException;
use Nosto\Tagging\Helper\Scope as NostoHelperScope;
use Nosto\Tagging\Logger\Logger as NostoLogger;
use Nosto\Tagging\Model\Indexer\Dimensions\ModeSwitcher as ProductModeSwitcher;
use Nosto\Tagging\Model\Indexer\Dimensions\ModeSwitcherInterface;
use Nosto\Tagging\Model\Indexer\Dimensions\ModeSwitcher\ModeSwitcher as ProductModeSwitcher;
use Nosto\Tagging\Model\Indexer\Dimensions\ModeSwitcher\ModeSwitcherInterface;
use Nosto\Tagging\Model\Indexer\Dimensions\StoreDimensionProvider;
use Nosto\Tagging\Model\ResourceModel\Magento\Product\Collection as ProductCollection;
use Nosto\Tagging\Model\ResourceModel\Magento\Product\CollectionBuilder;
Expand Down
24 changes: 23 additions & 1 deletion etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,19 @@
<arguments>
<argument name="dimensionSwitchers" xsi:type="array">
<item name="nosto_index_product" xsi:type="object">
Nosto\Tagging\Model\Indexer\Dimensions\ModeSwitch\ModeSwitcher
Nosto\Tagging\Model\Indexer\Dimensions\ModeSwitcher\ModeSwitcher
</item>
<item name="nosto_index_category" xsi:type="object">
Nosto\Tagging\Model\Indexer\Dimensions\ModeSwitcher\ModeSwitcher
</item>

</argument>
</arguments>
</type>
<type name="Nosto\Tagging\Model\Indexer\CategoryIndexer">
<arguments>
<argument name="dimensionProvider" xsi:type="object" shared="false">
Nosto\Tagging\Model\Indexer\Dimensions\StoreDimensionProvider
</argument>
</arguments>
</type>
Expand Down Expand Up @@ -238,4 +249,15 @@
<argument name="batchSize" xsi:type="number">500</argument>
</arguments>
</type>
<type name="Nosto\Tagging\Model\Service\Update\CategoryUpdateService">
<arguments>
<argument name="upsertBulkPublisher" xsi:type="object" shared="false">
Nosto\Tagging\Model\Service\Sync\Upsert\AsyncBulkPublisher
</argument>
<argument name="deleteBulkPublisher" xsi:type="object" shared="false">
Nosto\Tagging\Model\Service\Sync\Delete\AsyncBulkPublisher
</argument>
<argument name="batchSize" xsi:type="number">500</argument>
</arguments>
</type>
</config>
5 changes: 5 additions & 0 deletions etc/indexer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@
<title>Nosto Product Indexer</title>
<description>Populates message queue with product ids to be sent to Nosto</description>
</indexer>
<indexer id="nosto_index_category" view_id="nosto_index_category" class="Nosto\Tagging\Model\Indexer\CategoryIndexer">
<title>Nosto Category Indexer</title>
<!-- @TODO: Add description-->
<description>Category</description>
</indexer>
</config>
14 changes: 8 additions & 6 deletions etc/mview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@
</view>

<view id="nosto_index_category" class="Nosto\Tagging\Model\Indexer\CategoryIndexer" group="indexer">
<table name="catalog_category_entity" entity_column="entity_id" />
<table name="catalog_category_entity_decimal" entity_column="entity_id" />
<table name="catalog_category_entity_int" entity_column="entity_id" />
<table name="catalog_category_entity_text" entity_column="entity_id" />
<table name="catalog_category_entity_varchar" entity_column="entity_id" />
<table name="catalog_category_entity_datetime" entity_column="entity_id" />
<subscriptions>
<table name="catalog_category_entity" entity_column="entity_id" />
<table name="catalog_category_entity_decimal" entity_column="entity_id" />
<table name="catalog_category_entity_int" entity_column="entity_id" />
<table name="catalog_category_entity_text" entity_column="entity_id" />
<table name="catalog_category_entity_varchar" entity_column="entity_id" />
<table name="catalog_category_entity_datetime" entity_column="entity_id" />
</subscriptions>
</view>
</config>

0 comments on commit 95324ee

Please sign in to comment.