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

[Catalog Promotion] [Docs] docs updated #13585

Merged
merged 1 commit into from
Feb 3, 2022
Merged
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
16 changes: 5 additions & 11 deletions docs/book/products/catalog_promotions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ You can check if the catalog promotion exists by using GET endpoint
.. code-block:: php

/** @var CatalogPromotionInterface $promotion */
$promotion = $this->container->get('sylius.factory.t_shirt_promotion')->createNew();
$promotion = $this->container->get('sylius.factory.catalog_promotion')->createNew();

$promotion->setCode('t_shirt_promotion');
$promotion->setName('T-shirt Promotion');
Expand Down Expand Up @@ -230,12 +230,12 @@ We can also make it programmatically:
$catalogPromotion->addChannel('FASHION_WEB');

/** @var CatalogPromotionScopeInterface $catalogPromotionScope */
$catalogPromotionScope = $this->catalogPromotionScopeExampleFactory->create($scope);
$catalogPromotionScope = $this->container->get('sylius.factory.catalog_promotion_scope')->createNew();
$catalogPromotionScope->setCatalogPromotion($catalogPromotion);
$catalogPromotion->addScope($catalogPromotionScope);

/** @var CatalogPromotionActionInterface $catalogPromotionAction */
$catalogPromotionAction = $this->catalogPromotionActionExampleFactory->create($action);
$catalogPromotionAction = $this->container->get('sylius.factory.catalog_promotion_action')->createNew();
$catalogPromotionAction->setCatalogPromotion($catalogPromotion);
$catalogPromotion->addAction($catalogPromotionAction);

Expand Down Expand Up @@ -322,15 +322,9 @@ on proper events and dispatch ``CatalogPromotionCreated`` event to event bus. Th
one is edited, then the ``CatalogPromotionUpdated`` event is dispatched to event bus.

This event is handled by `CatalogPromotionUpdateListener <https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/CoreBundle/Listener/CatalogPromotionUpdateListener.php>`_ which resolves the appropriate ``CatalogPromotion``.
With the needed data and configuration from ``CatalogPromotion`` we can now process the ``Product`` and ``ProductVariant`` entities.
With the needed data and configuration from ``CatalogPromotion`` we can now process the Product Catalog.

The changes are first handled in `CatalogPromotionProcessor <https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/CoreBundle/Processor/CatalogPromotionProcessor.php>`_
which inside uses the `CatalogPromotionApplicator <https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/CoreBundle/Applicator/CatalogPromotionApplicator.php>`_.

The **CatalogPromotionProcessor**'s method ``process()`` is executed on the eligible items:

* firstly it iterates over eligible items: ``Product Variants``,
* then it calculates and applies the ``CatalogPromotionAction`` for given item
Any changes in Catalog Promotion cause recalculations of entire Product Catalog (`BatchedApplyCatalogPromotionsOnVariantsCommandDispatcher <https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/CoreBundle/CommandDispatcher/BatchedApplyCatalogPromotionsOnVariantsCommandDispatcher.php>`_ is called, which dispatch events `ApplyCatalogPromotionsOnVariants <https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/CoreBundle/Command/ApplyCatalogPromotionsOnVariants.php>`_)

.. note::

Expand Down