Closed hostep closed 7 months ago
Hmm not fully solved, we get crashes on the frontend due to various MSI dependencies not being installed, I'm thus currently blocked in updating this module to the latest version :(
If it's too difficult to solve this for non-MSI installations, maybe we should give in and install the full suite, but I'm still hopeful that it's not needed 🤞?
Hi @hostep but module-catalog-inventory is fully deprecated and changed to MSI. Try to override my class in preference and use StockRegistry to get StockItem there. And I also will remove dependency in module.xml Later I will take a look at how it could be done better.
I understand its deprecated, but in practice we've found it to be a lot more stable than the MSI modules. We've always ran into very strange issues with wrong stock qty's and statusses after a few weeks when we attempt to use MSI modules in production webshops. So much so that our clients asked us to remove the MSI modules again.
We haven't tried the very latest versions of MSI modules yet, but we have lost our confidence in those modules. We can always give it a try again for this one project, but I'm afraid we might loose a lot of time and effort again in figuring out strange bugs caused by the MSI modules.
Also, once the fully open source Mage-OS fork finally kicks of in the future, they'll most likely have a package without MSI modules I think (but I'm not sure). So looking forward in the future, it might be a good idea to have a module that works both with and without MSI modules.
Thanks for the information, let me know if my suggestion works for you
Okay thanks for the hint around StockRegistry, I was able to get it working using this patch:
diff --git a/Service/GetMinimalSalableQty.php b/Service/GetMinimalSalableQty.php
index 4ec79d2..9e4953b 100644
--- a/Service/GetMinimalSalableQty.php
+++ b/Service/GetMinimalSalableQty.php
@@ -5,15 +5,15 @@ declare(strict_types=1);
namespace Commerce365\CustomerPrice\Service;
use Magento\Catalog\Api\Data\ProductInterface;
-use Magento\InventoryConfiguration\Model\GetLegacyStockItem;
+use Magento\CatalogInventory\Api\StockRegistryInterface;
class GetMinimalSalableQty
{
- private GetLegacyStockItem $getLegacyStockItem;
+ private StockRegistryInterface $stockRegistry;
- public function __construct(GetLegacyStockItem $getLegacyStockItem)
+ public function __construct(StockRegistryInterface $stockRegistry)
{
- $this->getLegacyStockItem = $getLegacyStockItem;
+ $this->stockRegistry = $stockRegistry;
}
/**
@@ -23,7 +23,7 @@ class GetMinimalSalableQty
*/
public function execute(ProductInterface $product): ?float
{
- $stockItem = $this->getLegacyStockItem->execute($product->getSku());
+ $stockItem = $this->stockRegistry->getStockItemBySku($product->getSku());
$minSaleQty = $stockItem->getMinSaleQty();
return $minSaleQty > 0 ? $minSaleQty : null;
}
Solved in version 1.7.3
Thanks!
Similar situation as reported in #3
We've chosen to not install
magento/inventory-metapackage
and all dependencies.However, when updating
commerce365/module-customer-price
from 1.2.4 to 1.5.0 we get this error duringbin/magento setup:di:compile
:We can work around it by requiring that one module and disabling it:
But it would be appreciated if you can figure out something so this isn't needed like you did in #3