Skip to content

MSI - setting stock_qty attribute #27

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

Open
simonmaass opened this issue May 10, 2024 · 3 comments
Open

MSI - setting stock_qty attribute #27

simonmaass opened this issue May 10, 2024 · 3 comments

Comments

@simonmaass
Copy link

After looking deeper into this modules I dont understand why here:

algoliasearch-inventory-magento-2\Helper\InventoryProductHelper.php

we are not overriding the "addStockQty" function... this is the core function thats should set the MSI sellable quantity. What am i missing?

@simonmaass simonmaass changed the title MSI MSI - setting stock_qty attribute May 10, 2024
@simonmaass
Copy link
Author

I would expect something like this:

       if ($this->isMsiEnabled) {
            // Handle multi-source inventory if enabled
            /** @var \Magento\InventorySalesApi\Api\GetProductSalableQtyInterface $getProductSalableQty */
            $getProductSalableQty = $this->objectManager->get('Magento\InventorySalesApi\Api\GetProductSalableQtyInterface');

            $defaultData['stock_qty'] = $getProductSalableQty->execute($product['sku'], $stockId);
        }

@thomas-kl1
Copy link
Contributor

You may want to take a look on my PR on the main repo: algolia/algoliasearch-magento-2#1739

It basically add support for MSI in a backward-compatible way (meaning that if you have MSI disabled, it will fallback to basic inventory management).
The changes I propose are overridden and/or extended by MSI, so it make it compatible naturally.

@cammonro
Copy link

This is a fair critique and we will be reviewing your contributions. Thanks guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants