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

Update upgrade-the-price-module.md #2839

Merged
merged 10 commits into from
Jan 23, 2025
123 changes: 70 additions & 53 deletions _includes/pbc/all/upgrade-modules/upgrade-the-price-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,74 @@

## Upgrading from version 4.* to version 5.*

From version 5 we have changed price module responsibilities: previously it was responsible for handling product price related functionality. This responsibility has now been moved to the new PriceProduct module which handles product prices, while Price module is responsible for generic spryker core related functionality.

Because of this change of the Price module responsibility, all related modules have also be updated to work with the `PriceProduct` module.

1. First you have to install the new `PriceProduct` module.

* run `composer require spryker/price-product`.
* run SQL queries to create a new table and alter the existing one.

```sql
CREATE SEQUENCE "spy_price_product_store_pk_seq";

CREATE TABLE "spy_price_product_store"
(
"id_price_product_store" INTEGER NOT NULL,
"fk_price_product" INTEGER NOT NULL,
"fk_currency" INTEGER NOT NULL,
"fk_store" INTEGER,
"net_price" INTEGER,
"gross_price" INTEGER,
PRIMARY KEY ("id_price_product_store"),
CONSTRAINT "spy_price_product_store-unique-price_product" UNIQUE ("fk_currency","fk_price_product","fk_store")
);

ALTER TABLE "spy_price_type"
ADD "price_mode_configuration" INT2;
```

`spy_price_product_store` is the table for price per store / currency. `price_mode_configuration` field is added to indicate to which mode price type assigned GROSS, NET, BOTH.
* Build propel models `vendor/bin/console propel:model:build`.
* Generate new transfer objects `vendor/bin/console transfer:generate`.

If you have overwritten any of the classes from the `Price` module, you have to change namespace part with `Price` to `PriceProduct`, for example if you used `PriceFacade`, now should use `PriceProductFacade`. Same for `Factories`, `QueryContainer`, `DependencyProvider`.
Check that all `Price` plugins registered in `ProductDependencyProvider` have been moved to `PriceProduct` namespace.
`use Spryker\Zed\Price\Communication\Plugin\ProductAbstract\PriceProductAbstractAfterCreatePlugin;`
`use Spryker\Zed\Price\Communication\Plugin\ProductAbstract\PriceProductAbstractAfterUpdatePlugin;`
`use Spryker\Zed\Price\Communication\Plugin\ProductAbstract\PriceProductAbstractReadPlugin;`
`use Spryker\Zed\Price\Communication\Plugin\ProductConcrete\PriceProductConcreteAfterCreatePlugin;`
`use Spryker\Zed\Price\Communication\Plugin\ProductConcrete\PriceProductConcreteAfterUpdatePlugin;`
`use Spryker\Zed\Price\Communication\Plugin\ProductConcrete\PriceProductConcreteReadPlugin;`

Should be renamed to:

`use Spryker\Zed\PriceProduct\Communication\Plugin\ProductAbstract\PriceProductAbstractAfterCreatePlugin;`
`use Spryker\Zed\PriceProduct\Communication\Plugin\ProductAbstract\PriceProductAbstractAfterUpdatePlugin;`
`use Spryker\Zed\PriceProduct\Communication\Plugin\ProductAbstract\PriceProductAbstractReadPlugin;`
`use Spryker\Zed\PriceProduct\Communication\Plugin\ProductConcrete\PriceProductConcreteAfterCreatePlugin;`
`use Spryker\Zed\PriceProduct\Communication\Plugin\ProductConcrete\PriceProductConcreteAfterUpdatePlugin;`
`use Spryker\Zed\PriceProduct\Communication\Plugin\ProductConcrete\PriceProductConcreteReadPlugin;`

2. Update `StorageProductMapper` with the new price resolving logic
In this version, we've shifted the handling of product price related functionality from Price to the new PriceProduct module. The Price module is now responsible for generic Spryker core related functionality.

Update all related modules to to work with the `PriceProduct` module:

1. Install the `PriceProduct` module:
```bash
composer require spryker/price-product
```

2. Create a new table and update the existing one:

```sql
CREATE SEQUENCE "spy_price_product_store_pk_seq";

CREATE TABLE "spy_price_product_store"
(
"id_price_product_store" INTEGER NOT NULL,
"fk_price_product" INTEGER NOT NULL,
"fk_currency" INTEGER NOT NULL,
"fk_store" INTEGER,
"net_price" INTEGER,
"gross_price" INTEGER,
PRIMARY KEY ("id_price_product_store"),
CONSTRAINT "spy_price_product_store-unique-price_product" UNIQUE ("fk_currency","fk_price_product","fk_store")
);

ALTER TABLE "spy_price_type"
ADD "price_mode_configuration" INT2;
```

`spy_price_product_store` is the table for price per store / currency. `price_mode_configuration` field is added to indicate to which mode price type assigned GROSS, NET, BOTH.

3. Build propel models
```bash
vendor/bin/console propel:model:build
```

4. Generate new transfer objects
```bash
vendor/bin/console transfer:generate
```

5. If you overwrote any of the classes from the `Price` module, change the namespace part with `Price` to `PriceProduct`. For example, `PriceFacade` should be renamed to `PriceProductFacade`. Same for `Factories`, `QueryContainer`, `DependencyProvider`.

6. Check that all `Price` plugins registered in `ProductDependencyProvider` have been moved to the `PriceProduct` namespace:

Original:
```php
use Spryker\Zed\Price\Communication\Plugin\ProductAbstract\PriceProductAbstractAfterCreatePlugin;
use Spryker\Zed\Price\Communication\Plugin\ProductAbstract\PriceProductAbstractAfterUpdatePlugin;
use Spryker\Zed\Price\Communication\Plugin\ProductAbstract\PriceProductAbstractReadPlugin;
use Spryker\Zed\Price\Communication\Plugin\ProductConcrete\PriceProductConcreteAfterCreatePlugin;
use Spryker\Zed\Price\Communication\Plugin\ProductConcrete\PriceProductConcreteAfterUpdatePlugin;
use Spryker\Zed\Price\Communication\Plugin\ProductConcrete\PriceProductConcreteReadPlugin;
```
Expected:

```php
use Spryker\Zed\PriceProduct\Communication\Plugin\ProductAbstract\PriceProductAbstractAfterCreatePlugin;
use Spryker\Zed\PriceProduct\Communication\Plugin\ProductAbstract\PriceProductAbstractAfterUpdatePlugin;
use Spryker\Zed\PriceProduct\Communication\Plugin\ProductAbstract\PriceProductAbstractReadPlugin;
use Spryker\Zed\PriceProduct\Communication\Plugin\ProductConcrete\PriceProductConcreteAfterCreatePlugin;
use Spryker\Zed\PriceProduct\Communication\Plugin\ProductConcrete\PriceProductConcreteAfterUpdatePlugin;
use Spryker\Zed\PriceProduct\Communication\Plugin\ProductConcrete\PriceProductConcreteReadPlugin;
```


7. Update `StorageProductMapper` with the new price resolving logic:

```php
namespace Pyz\Yves\Product\Mapper;
Expand Down Expand Up @@ -97,7 +114,7 @@ class StorageProductMapper implements StorageProductMapperInterface
}
```

3. Inject `PriceProduct` client dependency and pass it to mapper class.
7. Inject the `PriceProduct` client dependency and pass it to a mapper class.

```php
namespace Pyz\Yves\Product;
Expand Down Expand Up @@ -149,7 +166,7 @@ class ProductFactory extends AbstractFactory
}
```

4. Collectors have changed the way price is collected. Change `ProductAbstractCollector` and `ProductConcreteCollector` to reflect that. Both are now using `PriceProductFacade` instead of `PriceFacade`.
8. Update `ProductAbstractCollector` and `ProductConcreteCollector` to use `PriceProductFacade` instead of `PriceFacade`.

```php
namespace Pyz\Zed\Collector\Business\Storage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ last_updated: Sep 24, 2024
description: Learn how to edit concrete products in the Merchant Portal.
template: back-office-user-guide-template
redirect_from:
- /docs/pbc/all/product-information-management/202404.0/marketplace/manage-in-the-merchant-portal/concrete-products/edit-marketplace-concrete-products.html
- /docs/pbc/all/product-information-management/202404.0/marketplace/manage-in-the-merchant-portal/concrete-products/managing-marketplace-concrete-products.html
related:
- title: Marketplace Product feature overview
link: docs/pbc/all/product-information-management/page.version/marketplace/marketplace-product-feature-overview.html
Expand Down
Loading