الأخبار التكنولوجية والاستعراضات والنصائح!

كيفية التحقق برمجيًا مما إذا كان المخزون قد انخفض عند تقديم الطلب في Magento 2

ستساعدك المقالة التالية: كيفية التحقق برمجيًا مما إذا كان المخزون قد انخفض عند تقديم الطلب في Magento 2

<؟ php

Vendor \ Module \ Helper مساحة الاسم ؛

استخدم Magento \ CatalogInventory \ Model \ Configuration ؛

استخدم Magento \ Framework \ App \ Helper \ AbstractHelper ؛

استخدام Magento \ Framework \ App \ Helper \ Context ؛

استخدم Magento \ Framework \ Exception \ NoSuchEntityException ؛

استخدام Magento \ Store \ Model \ StoreManagerInterface ؛

/ **

* فئة IsStockDecreaseWhenOrderIsPlaced

* /

الفئة IsStockDecreaseWhenOrderIsPlaced تمتد إلى AbstractHelper

{

/ **

* تكوينvar

* /

جرد $ خاص ؛

/ **

*var StoreManagerInterface

* /

$ storeManager الخاص ؛

/ **

* IsStockDecreaseWhenOrderIsPlaced المُنشئ.

*param Configuration $ InventoryConfiguration

*param StoreManagerInterface $ storeManager

*param Context $ Context

* /

public function __construct (Configuration $ stockConfiguration، StoreManagerInterface $ storeManager، Context $ Context)

{

الأصل :: __ بناء (سياق $) ؛

$ this-> InventoryConfiguration = $ InventoryConfiguration؛

$ this-> storeManager = $ storeManager ؛

}

/ **

*return منطقية

*throws NoSuchEntityException

* /

الوظيفة العامة هي StockDecreaseWhenOrderIsPlaced ()

{

إرجاع $ this-> stockConfiguration-> canSubtractQty ($ this-> storeManager-> getStore () -> getId ()) ؛

}

}