Skip to content

Commit

Permalink
refactor #13585 [Catalog Promotion] [Docs] docs updated (AdamKasp)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.11 branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | .11
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | no/
| License         | MIT

<!--
 - Bug fixes must be submitted against the 1.10 or 1.11 branch(the lowest possible)
 - Features and deprecations must be submitted against the master branch
 - Make sure that the correct base branch is set

 To be sure you are not breaking any Backward Compatibilities, check the documentation:
 https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html
-->


Commits
-------

d2fcc34 CP docs updated
  • Loading branch information
GSadee committed Feb 3, 2022
2 parents 2927465 + d2fcc34 commit edaa79e
Showing 1 changed file with 5 additions and 11 deletions.
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

0 comments on commit edaa79e

Please sign in to comment.