Migration guide - CategoryStorage

Edit on GitHub

This document describes how to update the CategoryStorage module.

Upgrading from version 1.* to 2.*

Version 2.* of the CategoryStorage module changes the storage data structure to maintain the relation of categories to stores.

Estimated migration time: 1 hour. 

To upgrade the module from version 1.* to 2.*:

  1. Upgrade the CategoryStorage module to version 2.0.0:
composer require spryker/category-storage:"^2.0.0" --update-with-dependencies
  1. On the project level in Pyz/Zed/CategoryStorage/Persistence/Propel/Schema/spy_category_storage.schema.xml, remove the synchronization behavior setup from the spy_category_tree_storage and spy_category_node_storage tables.

  2. Update the database schema and the generated data transfer classes:

console propel:install
console transfer:generate
  1. From Pyz\Zed\Event\EventDependencyProvider, remove the deprecated subscriber: CategoryStorageEventSubscriber.

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

    • CategoryTreeEventResourceQueryContainerPlugin
    • CategoryNodeEventResourceQueryContainerPlugin
  3. Add the new plugins:

Pyz\Zed\Publisher\PublisherDependencyProvider
<?php

namespace Pyz\Zed\Publisher;

use Spryker\Zed\CategoryStorage\Communication\Plugin\Publisher\Category\CategoryDeletePublisherPlugin;
use Spryker\Zed\CategoryStorage\Communication\Plugin\Publisher\Category\CategoryWritePublisherPlugin as CategoryStoreCategoryWritePublisherPlugin;
use Spryker\Zed\CategoryStorage\Communication\Plugin\Publisher\CategoryAttribute\CategoryAttributeDeletePublisherPlugin;
use Spryker\Zed\CategoryStorage\Communication\Plugin\Publisher\CategoryAttribute\CategoryAttributeWritePublisherPlugin;
use Spryker\Zed\CategoryStorage\Communication\Plugin\Publisher\CategoryNode\CategoryNodeDeletePublisherPlugin;
use Spryker\Zed\CategoryStorage\Communication\Plugin\Publisher\CategoryNode\CategoryNodeWritePublisherPlugin;
use Spryker\Zed\CategoryStorage\Communication\Plugin\Publisher\CategoryStore\CategoryStoreWriteForPublishingPublisherPlugin as CategoryStoreStorageWriteForPublishingPublisherPlugin;
use Spryker\Zed\CategoryStorage\Communication\Plugin\Publisher\CategoryStore\CategoryStoreWritePublisherPlugin as CategoryStoreStorageWritePublisherPlugin;
use Spryker\Zed\CategoryStorage\Communication\Plugin\Publisher\CategoryTemplate\CategoryTemplateDeletePublisherPlugin;
use Spryker\Zed\CategoryStorage\Communication\Plugin\Publisher\CategoryTemplate\CategoryTemplateWritePublisherPlugin;
use Spryker\Zed\CategoryStorage\Communication\Plugin\Publisher\CategoryTree\CategoryTreeDeletePublisherPlugin;
use Spryker\Zed\CategoryStorage\Communication\Plugin\Publisher\CategoryTree\CategoryTreeWriteForPublishingPublisherPlugin;
use Spryker\Zed\CategoryStorage\Communication\Plugin\Publisher\ParentWritePublisherPlugin;
use Spryker\Zed\CategoryStorage\Communication\Plugin\Publisher\CategoryNodePublisherTriggerPlugin;
use Spryker\Zed\CategoryStorage\Communication\Plugin\Publisher\CategoryTreePublisherTriggerPlugin;
use Spryker\Zed\Publisher\PublisherDependencyProvider as SprykerPublisherDependencyProvider;

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

    /**
     * @return \Spryker\Zed\PublisherExtension\Dependency\Plugin\PublisherPluginInterface[]
     */
    protected function getCategoryStoragePlugins(): array
    {
        return [
            new CategoryStoreStorageWritePublisherPlugin(),
            new CategoryStoreStorageWriteForPublishingPublisherPlugin(),
            new CategoryTreeWriteForPublishingPublisherPlugin(),
            new CategoryDeletePublisherPlugin(),
            new CategoryStoreCategoryWritePublisherPlugin(),
            new CategoryAttributeDeletePublisherPlugin(),
            new CategoryAttributeWritePublisherPlugin(),
            new CategoryNodeDeletePublisherPlugin(),
            new CategoryNodeWritePublisherPlugin(),
            new CategoryTemplateDeletePublisherPlugin(),
            new CategoryTemplateWritePublisherPlugin(),
            new CategoryTreeDeletePublisherPlugin(),
            new ParentWritePublisherPlugin(),
        ];
    }

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

    • CategoryNodeSynchronizationDataPlugin
    • CategoryTreeSynchronizationDataPlugin
  2. Add the new synchronization plugins:

Pyz\Zed\Synchronization\SynchronizationDependencyProvider
<?php

namespace Pyz\Zed\Synchronization;

use Spryker\Zed\CategoryStorage\Communication\Plugin\Synchronization\CategoryNodeSynchronizationDataBulkRepositoryPlugin;
use Spryker\Zed\CategoryStorage\Communication\Plugin\Synchronization\CategoryTreeSynchronizationDataBulkRepositoryPlugin;
use Spryker\Zed\Synchronization\SynchronizationDependencyProvider as SprykerSynchronizationDependencyProvider;

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

    1. Truncate the spy_category_node_storage and spy_category_tree_storage database tables:
    TRUNCATE TABLE APPROVED;
    TRUNCATE TABLE spy_category_tree_storage;
    
    1. Remove all the data:
    console sync:data category_node
    console sync:data category_tree
    
    1. Trigger the events:
    console publish:trigger-events -r category_node
    console publish:trigger-events -r category_tree
    
    1. Sync all table storage data to the storage:
    console sync:data category_node
    console sync:data category_tree
    
Verification

Ensure that the data in the spy_category_node_storage and spy_category_tree_storage database tables is divided by stores.