Upgrade the CategoryPageSearch module

Edit on GitHub

This document describes how to upgrade the CategoryPageSearch module.

Upgrading from version 1.* to 2.*

This section describes how to upgrade the CategoryPageSearch from version 1.* to 2.*.

Version 2.* of the CategoryPageSearch module changes the storage data structure to maintain the relations of categories to stores.

Estimated migration time: 1 hour. 

To upgrade to the new version of the module, do the following:

  1. Install the ProductCategorySearch module:
composer require spryker/product-category-search
  1. Upgrade the CategoryPageSearch module to version 2.0.0:
composer require spryker/category-page-search:"^2.0.0" --update-with-dependencies
  1. From the spy_category_node_page_search table on the project level in Pyz/Zed/CategoryPageSearch/Persistence/Propel/Schema/spy_category_page_search.schema.xml, remove the synchronization behavior setup.

  2. Update the database schema and the generated classes:

console propel:install
console transfer:generate
  1. In the CategoryPageSearch module, replace the deprecated plugins:
  • ProductCategoryPageDataLoaderExpanderPlugin
  • CategoryPageDataLoaderPlugin
  • ProductCategoryMapExpanderPlugin
Pyz/Zed/ProductPageSearch/ProductPageSearchDependencyProvider
<?php

namespace Pyz\Zed\ProductPageSearch;

use Spryker\Zed\ProductCategorySearch\Communication\Plugin\ProductPageSearch\Elasticsearch\ProductCategoryMapExpanderPlugin;
use Spryker\Zed\ProductCategorySearch\Communication\Plugin\ProductPageSearch\ProductCategoryPageDataExpanderPlugin;
use Spryker\Zed\ProductCategorySearch\Communication\Plugin\ProductPageSearch\ProductCategoryPageDataLoaderPlugin;
use Spryker\Zed\ProductPageSearch\ProductPageSearchDependencyProvider as SprykerProductPageSearchDependencyProvider;

class ProductPageSearchDependencyProvider extends SprykerProductPageSearchDependencyProvider
{
    /**
     * @return \Spryker\Zed\ProductPageSearch\Dependency\Plugin\ProductPageDataExpanderInterface[]
     */
    protected function getDataExpanderPlugins()
    {
        $dataExpanderPlugins = [];

        $dataExpanderPlugins[ProductPageSearchConfig::PLUGIN_PRODUCT_CATEGORY_PAGE_DATA] = new ProductCategoryPageDataExpanderPlugin();

        return $dataExpanderPlugins;
    }

    /**
     * @return \Spryker\Zed\ProductPageSearchExtension\Dependency\Plugin\ProductAbstractMapExpanderPluginInterface[]
     */
    protected function getProductAbstractMapExpanderPlugins(): array
    {
        return [
            new ProductCategoryMapExpanderPlugin(),
        ];
    }

    /**
     * @return \Spryker\Zed\ProductPageSearchExtension\Dependency\Plugin\ProductPageDataLoaderPluginInterface[]
     */
    protected function getDataLoaderPlugins()
    {
        return [
            new ProductCategoryPageDataLoaderPlugin(),
        ];
    }
}
  1. From Pyz\Zed\Event\EventDependencyProvider, remove the deprecated subscriber: CategoryPageSearchEventSubscriber.

  2. From Pyz\EventBehavior\EventBehaviorDependencyProvider, remove the deprecated plugin: CategoryPageEventResourceQueryContainerPlugin.

  3. Add the new plugins:

Pyz\Zed\Publisher\PublisherDependencyProvider
<?php

namespace Pyz\Zed\Publisher;

use Spryker\Zed\CategoryPageSearch\Communication\Plugin\Publisher\Category\CategoryDeletePublisherPlugin as CategoryPageSearchCategoryDeletePublisherPlugin;
use Spryker\Zed\CategoryPageSearch\Communication\Plugin\Publisher\Category\CategoryWritePublisherPlugin as CategoryPageSearchCategoryWritePublisherPlugin;
use Spryker\Zed\CategoryPageSearch\Communication\Plugin\Publisher\CategoryAttribute\CategoryAttributeDeletePublisherPlugin as CategoryPageSearchCategoryAttributeDeletePublisherPlugin;
use Spryker\Zed\CategoryPageSearch\Communication\Plugin\Publisher\CategoryAttribute\CategoryAttributeWritePublisherPlugin as CategoryPageSearchCategoryAttributeWritePublisherPlugin;
use Spryker\Zed\CategoryPageSearch\Communication\Plugin\Publisher\CategoryNode\CategoryNodeDeletePublisherPlugin as CategoryPageSearchCategoryNodeDeletePublisherPlugin;
use Spryker\Zed\CategoryPageSearch\Communication\Plugin\Publisher\CategoryNode\CategoryNodeWritePublisherPlugin as CategoryPageSearchCategoryNodeWritePublisherPlugin;
use Spryker\Zed\CategoryPageSearch\Communication\Plugin\Publisher\CategoryStore\CategoryStoreWriteForPublishingPublisherPlugin as CategoryStoreSearchWriteForPublishingPublisherPlugin;
use Spryker\Zed\CategoryPageSearch\Communication\Plugin\Publisher\CategoryStore\CategoryStoreWritePublisherPlugin as CategoryStoreSearchWritePublisherPlugin;
use Spryker\Zed\CategoryPageSearch\Communication\Plugin\Publisher\CategoryTemplate\CategoryTemplateDeletePublisherPlugin as CategoryPageSearchCategoryTemplateDeletePublisherPlugin;
use Spryker\Zed\CategoryPageSearch\Communication\Plugin\Publisher\CategoryTemplate\CategoryTemplateWritePublisherPlugin as CategoryPageSearchCategoryTemplateWritePublisherPlugin;
use Spryker\Zed\CategoryPageSearch\Communication\Plugin\Publisher\CategoryPagePublisherTriggerPlugin;
use Spryker\Zed\Publisher\PublisherDependencyProvider as SprykerPublisherDependencyProvider;

class PublisherDependencyProvider extends SprykerPublisherDependencyProvider
{
    /**
     * @return array
     */
    protected function getPublisherPlugins(): array
    {
        return array_merge(
            $this->getCategoryPageSearchPlugins(),
        );
    }

    /**
     * @return \Spryker\Zed\PublisherExtension\Dependency\Plugin\PublisherPluginInterface[]
     */
    protected function getCategoryPageSearchPlugins(): array
    {
        return [
            new CategoryStoreSearchWritePublisherPlugin(),
            new CategoryStoreSearchWriteForPublishingPublisherPlugin(),
            new CategoryPageSearchCategoryDeletePublisherPlugin(),
            new CategoryPageSearchCategoryWritePublisherPlugin(),
            new CategoryPageSearchCategoryAttributeDeletePublisherPlugin(),
            new CategoryPageSearchCategoryAttributeWritePublisherPlugin(),
            new CategoryPageSearchCategoryNodeDeletePublisherPlugin(),
            new CategoryPageSearchCategoryNodeWritePublisherPlugin(),
            new CategoryPageSearchCategoryTemplateDeletePublisherPlugin(),
            new CategoryPageSearchCategoryTemplateWritePublisherPlugin(),
        ];
    }

    /**
     * @return \Spryker\Zed\PublisherExtension\Dependency\Plugin\PublisherTriggerPluginInterface[]
     */
    protected function getPublisherTriggerPlugins(): array
    {
        return [
            new CategoryPagePublisherTriggerPlugin(),
        ];
    }
}
  1. From Pyz\Zed\Synchronization\SynchronizationDependencyProvider, remove the deprecated plugin:CategoryPageSynchronizationDataPlugin.

  2. Add the new synchronization plugin to Pyz\Zed\Synchronization\SynchronizationDependencyProvider:

<?php

namespace Pyz\Zed\Synchronization;

use Spryker\Zed\CategoryPageSearch\Communication\Plugin\Synchronization\CategoryPageSynchronizationDataBulkRepositoryPlugin;
use Spryker\Zed\Synchronization\SynchronizationDependencyProvider as SprykerSynchronizationDependencyProvider;

class SynchronizationDependencyProvider extends SprykerSynchronizationDependencyProvider
{
    /**
     * @return \Spryker\Zed\SynchronizationExtension\Dependency\Plugin\SynchronizationDataPluginInterface[]
     */
    protected function getSynchronizationDataPlugins(): array
    {
        return [
            new CategoryPageSynchronizationDataBulkRepositoryPlugin(),
        ];
    }
}
  1. Refill storage:

    1. Truncate the spy_category_node_page_search database table:
    TRUNCATE TABLE spy_category_node_page_search;
    
    1. Remove all the data:
    console sync:data category_node
    
    1. Trigger the event:
    console publish:trigger-events -r category_node
    
    1. Sync all table storage data to the storage:
    console sync:data category_node
    
Verification

Ensure that the data in the spy_category_node_page_search database table is divided by stores.

Upgrading from Version 1.4.* to Version 1.5.*

Prerequisites

This migration guide is a part of the Search migration effort. Prior to upgarding this module, make sure you have completed all the steps from the Search Migration Guide.

To upgrade to the new version of the module, do the following:

  1. Update the modules using Composer:
composer update spryker/category-page-search
  1. Remove deprecated plugin usages listed below (in case it is used) from Pyz\Zed\Search\SearchDependencyProvider:
Spryker\Zed\CategoryPageSearch\Communication\Plugin\Search\CategoryNodeDataPageMapBuilder