Troubleshooting
Incorrect Stock Status with Multi-Source Inventory
8 min
problem when using magento’s multi source inventory , you may encounter scenarios where the stock status synced with klevu doesn’t match the availability in the webstore potential solutions replace “is available” check with “is salable” often, the problem can be traced to the klevu integration checking whether is a product is available, rather than is salable, in the pipeline extraction we can validate this as a root cause with a small modification to the pipeline responsible for extracting product data, modifying the in stock extract for products and variants found in the following locations https //github com/klevu/module m2 indexing products/blob/main/etc/pipeline/product/attributes/in stock yml https //github com/klevu/module m2 indexing products/blob/main/etc/pipeline/product/attributes/in stock/variant yml the specifics of modifying attribute data via pipeline customisations can be found in the following article changing attribute data sent to klevu indexes docid\ dzq7yw9jljr6ll1u pm3u override the extraction method for stock status following the above article’s steps 1\ the yaml paths we need to modify are for variant products stages iterateindexingrecordsbatch stages iterateindexingrecords stages processproduct stages variantproduct stages generaterecord stages attributes stages instock stages checkstock stages getparentstock stages iterateindexingrecordsbatch stages iterateindexingrecords stages processproduct stages variantproduct stages generaterecord stages attributes stages instock stages checkstock stages getvariantstock for all other product types stages iterateindexingrecordsbatch stages iterateindexingrecords stages processproduct stages configurableproduct stages generaterecord stages attributes stages instock stages getstock stages iterateindexingrecordsbatch stages iterateindexingrecords stages processproduct stages groupedproduct stages generaterecord stages attributes stages instock stages getstock stages iterateindexingrecordsbatch stages iterateindexingrecords stages processproduct stages bundleproduct stages generaterecord stages attributes stages instock stages getstock stages iterateindexingrecordsbatch stages iterateindexingrecords stages processproduct stages virtualproduct stages generaterecord stages attributes stages instock stages getstock stages iterateindexingrecordsbatch stages iterateindexingrecords stages processproduct stages downloadableproduct stages generaterecord stages attributes stages instock stages getstock stages iterateindexingrecordsbatch stages iterateindexingrecords stages processproduct stages default stages generaterecord stages attributes stages instock stages getstock 2\ the change required is to change the extraction method from isavailable() to issalable() 3\ express the changes as yaml variant products stages instock stages checkstock stages getparentstock pipeline stage\extract args extraction 'currentparentproduct issalable()' getvariantstock pipeline stage\extract args extraction 'currentproduct issalable()' transformations tobooleany as the getparentstock stage essentially acts as a guard clause, you may not want or need to override this stage, depending on your site’s set up all other product types stages instock stages getstock pipeline stage\extract args extraction 'currentproduct issalable()' transformations toboolean 4\ implement the changes in a local or staging environment the easiest way is to add the above snippets under the attributes path for each applicable product type under var/klevu/indexing/pipeline/product/add update overrides yml and trigger a sync as this file is already registered, it will not require a recompilation before testing, allowing faster feedback on whether the change addresses the issue 5\ transfer the changes to a dedicated customisation module complete yaml override based on above suggested filepath within module etc/pipeline/indexing/product/add update overrides yml stages iterateindexingrecordsbatch stages iterateindexingrecords stages processproduct stages variantproduct stages generaterecord stages attributes stages instock stages checkstock stages getparentstock pipeline stage\extract args extraction 'currentparentproduct issalable()' getvariantstock pipeline stage\extract args extraction 'currentproduct issalable()' transformations toboolean configurableproduct stages generaterecord stages attributes stages instock stages instock stages getstock pipeline stage\extract args extraction 'currentproduct issalable()' transformations toboolean groupedproduct stages generaterecord stages attributes stages instock stages instock stages getstock pipeline stage\extract args extraction 'currentproduct issalable()' transformations toboolean bundleproduct stages generaterecord stages attributes stages instock stages instock stages getstock pipeline stage\extract args extraction 'currentproduct issalable()' transformations toboolean virtualproduct stages generaterecord stages attributes stages instock stages instock stages getstock pipeline stage\extract args extraction 'currentproduct issalable()' transformations toboolean downloadableproduct stages generaterecord stages attributes stages instock stages instock stages getstock pipeline stage\extract args extraction 'currentproduct issalable()' transformations toboolean default stages generaterecord stages attributes stages instock stages instock stages getstock pipeline stage\extract args extraction 'currentproduct issalable()' transformations toboolean and registration changes to be added to etc/di xml \<virtualtype name="klevu\indexingproducts\service\provider\pipelineconfigurationoverridesfilepathsprovider\add"> \<arguments> \<argument name="pipelineconfigurationoverridefilepaths" xsi\ type="array"> \<item name="vendor klevuindexingstockstatus indexing product add update" xsi\ type="string">vendor klevuindexingstockstatus etc/pipeline/indexing/product/add update overrides yml\</item> \</argument> \</arguments> \</virtualtype> \<virtualtype name="klevu\indexingproducts\service\provider\pipelineconfigurationoverridesfilepathsprovider\update"> \<arguments> \<argument name="pipelineconfigurationoverridefilepaths" xsi\ type="array"> \<item name="vendor klevuindexingstockstatus indexing product add update" xsi\ type="string">vendor klevuindexingstockstatus etc/pipeline/indexing/product/add update overrides yml\</item> \</argument> \</arguments> \</virtualtype> 6\ deploy the customisation module to production; requeue any affected products; and trigger an entity sync sample module vendor klevuindexingstockstatus on github