Skip to content

Feed with min_sale_qty attribute

we have a product attribute called min_sale_qty. It’s inside the advanced_inventory. We created a custom variable called min_sale_qty. No comment. Php Script:

    <?php
    class Gmsq
    {
        public function getMinSaleQtyAllowed($productSku): float
        {
            $objectManager = MagentoFrameworkAppObjectManager::getInstance();
    
            $stockResolver = $objectManager->get('MagentoInventorySalesApiApiStockResolverInterface');
            $storeManager = $objectManager->get('MagentoStoreModelStoreManagerInterface');
            $getStockItemConfiguration = $objectManager->get('MagentoInventoryConfigurationApiApiGetStockItemConfigurationInterface');
    
            $websiteCode = $storeManager->getWebsite()->getCode();
            $stock = $stockResolver->execute('SalesChannelInterface::TYPE_WEBSITE', $websiteCode);
            $stockId = (int)$stock->getStockId();
    
            $stockItemConfiguration = $getStockItemConfiguration->execute($productSku, $stockId);
    
            return $stockItemConfiguration->getMinSaleQty();
        }
    }
    
    ?>

When trying to generate a preview with 10 items, we receive a blank page. When trying to generate the feed, the feed generation stuck at “0% processing”.

We implemented the custom variable inside the feed with:
<g:min_sale_qty>{{product.min_sale_qty}}</g:min_sale_qty>