Magento 2.3.1 How to display source or stock name on product page ? MSI Multii Source Inventory

magento.stackexchange https://magento.stackexchange.com/questions/277718

Вопрос

How to display source or stock name and code on the product page? Where is information about a current stock or source name? Can I use the code from Sourceitem.php on the Product page?

     public function getSourceCode(): ?string
 {
     return $this->getData(self::SOURCE_CODE);
 }

Thanks in advance

Нет правильного решения

Другие советы

You can use GetSourceItemBySku to get all SourceItem from product's sku. Then you can foreach the array and getSourceCode() from SourceItem.

Please check this path: /vendor/magento/module-inventory/Model/SourceItem/Command/GetSourceItemsBySku.php

After defined and declared GetSourceItemsBySkuInterface, just use it in your function.

$availableSourcesForProduct = $this->sourceItemsBySku->execute($sku);

Refer this file to know how to use it, /vendor/magento/module-inventory-grouped-product-admin-ui/Plugin/Catalog/Model/Product/Link/ProcessSourceItemsAfterSaveAssociatedLinks.php. Check function processSourceItemsForSku

Good luck!!!

Лицензировано под: CC-BY-SA с атрибуция
Не связан с magento.stackexchange
scroll top