SKU (price) values will only be updated
How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!
While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.
legacy-article
learn-legacy-article-disclaimer-text
Issue
- How exactly does API behave, will it drop all the existing mapping ( Variant> Price> Options) and create again?
Environment
- Liferay DXP 7.4
- Commerce 4.0
Resolution
-
The SKU (price) values will only be updated with respect to the option value of each product.
- Create a new Option “City” with 3 values (Mumbai, Delhi, and Pune), and mark it as SKU Contributor (through UI).
- Send a POST Call to
http://localhost:8080/o/headless-commerce-admin-catalog/v1.0/products with the JSON (attached sample json which I created for testing), changing the catalogId and optionId.
- Check that the product was created, and check that the
createDate for CPInstances and CommercePriceEntry are the current date
- Send the same POST Call, this time altering the “price”, “cost”, “promoPrice” and “basePrice” of both SKUs
- Check the CPInstance’s and CommercePriceEntry’s createDate in the database entries.
Both had unchanged createDates, everything stayed the same except for the changed fields.
There’s no reason why the createDate would be changed by the POST call. Therefore, the existing Mappings will not be dropped, they will only be updated.
Pricing Info gets updated here:
https://github.com/liferay-commerce/liferay-portal/blob/bf9b8657efe5ca1a0766d81c9fc35edc731e0aae/modules/apps/commerce/headless/headless-commerce/headless-commerce-admin-catalog-impl/src/main/java/com/liferay/headless/commerce/admin/catalog/internal/util/v1_0/SkuUtil.java#L423
And will ultimately call:
https://github.com/liferay-commerce/liferay-portal/blob/bf9b8657efe5ca1a0766d81c9fc35edc731e0aae/modules/apps/commerce/commerce-price-list-service/src/main/java/com/liferay/commerce/price/list/service/impl/CommercePriceEntryLocalServiceImpl.java#L768
did-this-article-resolve-your-issue