14

This is actually a feature of Magento. Setting Display out of stock products to No only hides them from the category list pages and the search results page. The product page is actually still available. Starting with CE 1.9.1 there is even a message under the config setting Display out of stock products saying Products will still be shown by direct product ...


12

Solution 1 This moves out of stock products to the end of the list on page, not all over the pagination: 1.Add event observer: <frontend> <events> <catalog_block_product_list_collection> <observers> <ssd_test> <type>model</type> <...


10

isSaleable() is just an alias of isSalable() : /** * Alias for isSalable() * * @return bool */ public function isSaleable() { return $this->isSalable(); } The isSalable() method looks complex but it simply checks for the availability of the product via the isAvailable() method: /** * Check is product available for sale * * @return bool */ ...


10

In our case the issue was related to a migration from Magento 1 to Magento 2 via migration data tool. The problem is that default value for the attribute 'links_exist' is 0 in Magento 1. However in Magento 2 default value for 'links_exist' is null. Because of that following validation fails File: vendor/magento/module-catalog/view/frontend/templates/product/...


9

You can easily do this by visiting your Advanced Inventory Tab of your product. Just set Manage Stock option to No EDIT If your store contain all digital products then you can set below option by default, so you don't need to set for individual product Stores > Configuration > Catalog > Inventory > Product Stock Options Manage Stock to No


7

To show out of stock products go to System > Configuration > Catalog > Inventory and set Display Out of Stock Products to yes. Now we'll need to rewrite the class Mage_Catalog_Block_Product_View_Type_Configurable which you can do in your own module. Specifically the method getJsonConfig. This method actually outputs a javascript string that is ...


7

Go to admin > Stores > configuration > Catalog > Inventory > Stock Options Set Display Out of Stock Products to NO


7

This one adds to Sohel Rana's answer. Tested on 2.3.3 for configurable products For any of the product out of stock: In your di.xml <preference for="Magento\ConfigurableProduct\Pricing\Render\FinalPriceBox" type="<Vendor>\<Module>\Pricing\Render\FinalPriceBox" /> And in \\Pricing\Render\FinalPriceBox.php namespace <Vendor>\<...


7

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $productCollectionFactory = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory'); $productCollection = $productCollectionFactory ->create() ->addAttributeToSelect('*') ->addAttributeToSort('created_at', 'DESC') ->joinField('...


7

You need to create your custom module using below code Let say module name Custom_Outofstock So create folder in app/code Create registration.php file at app/code/Custom/Outofstock/registration.php Add below code to it: <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, '...


6

You can use this code which give stock in faster way using product id $model=Mage::getModel('cataloginventory/stock_item'); $model->getResource()->loadByProductId($model, $productId); $data=$model->setOrigData(); echo "<pre>"; print_r($data->getData()); Out is an array An exmaple: Array ( [item_id] => 1868 [product_id] => ...


6

These all are methods which checked the product availability with different parameters . isInStock() - Its just check the product is in stock or not. And for this its check the product attribute value of Stock Status, if it is set as In Stock then it will return true. isAvailable() - Its check the product availability according to product status, stock ...


5

The "Display Out of Stock Products" option set to No will hide products that are completely out of stock. If you want these to be displayed, but also want filters to hide options where the simple product for that option is out of stock, there is a simple solution. Rather than fiddle about with how the product collection is retrieved and/or displayed, it is ...


5

After doing R&D found a solution to get all the out of stock products <?php namespace [VENDOR_NAME]\[MODULE_NAME]\Block; use Magento\Catalog\Model\Product\Attribute\Source\Status; use Magento\Catalog\Model\Product\Visibility; use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; use Magento\Framework\View\Element\Template; use Magento\...


4

By default in product collection join the cataloginventory_stock_status table so "stock_status_index.stock_status = 1" added into the query. To get the only out of stock products, first we need to remove cataloginventory_stock_status join and than filter again. $productCollection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\...


4

Not sure if this is applicable, but I'm on Magento 2.1.9 and there is an issue with configurable products showing price of $0.00 when child products are out of stock on Github. The hack, Albeit a core hack, is the only available remedy it seems. I added the code & commented below, into vendor/magento/module-configurable-product/Pricing/Price/...


4

Try following code: $product->setQuantityAndStockStatus(['qty' => $qty, 'is_in_stock' => (bool)$qty]); OR $stockItem->setQty($qty); $stockItem->setIsInStock((bool)$qty);


4

Use below code $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $productCollection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory'); $collection = $productCollection->create(); $collection->setFlag('has_stock_status_filter', true); $collection = $collection ->joinField('qty', ...


4

By default magento filters only in stock products in collection. We have to set the in stock filter as false. $productCollection = $_objectManager->create('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory'); $collection = $productCollection->create()->setFlag('has_stock_status_filter', false)->load();


4

To do above things, you need to do this things. Vendor\Extension\etc\di.xml <type name="Magento\CatalogInventory\Helper\Stock"> <plugin name="Vendor_Extension_Stock_Helper" type="Vendor\Extension\Plugin\Helper\Stock" sortOrder="10" disabled="false" /> </type> Create the Helper File with arround plugin. Vendor\Extension\...


3

Try this $firstProductId = Mage::getSingleton('catalog/product')->getIdBySku('mysku'); $inStock = Mage::getModel('cataloginventory/stock_item')->getCollection()->addFieldToFilter('product_id', $firstProductId)->getFirstItem() This should do the trick. Although, not sure how efficient it would be but can confirm this is magento way.


3

let's say that $collection is your product collection that you build like this: $collection = Mage::getModel('catalog/product')->getCollection() ->...additional filters here...; now do this to your collection. This joins the collection with the stock status table. $website = Mage::app()->getWebsite(); Mage::getModel('cataloginventory/...


3

Solution 1 Add this in config.xml <?xml version="1.0"?> <config> <modules> <Froggyline_HappyHour> <version>0.0.0</version> </Froggyline_HappyHour> </modules> <adminhtml> <events> //second event <catalog_product_save_after> ...


3

Yes it does. Check this out. Magento has in-built setting for turning on "Backordering". It is located at System >> Configuration >> Catalog >> Inventory but this will work only on new products. For all existing products you still have to turn it on in admin products grid(Catalog >> Manage Products) by selecting products and then ...


3

You need to modify some logic for that. So create a new module and add following code. Vendor/Module/etc/frontend/di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Magento\Catalog\Pricing\Render\...


3

I just created a small module to show the price of out-of-stock items based on @Cotton 's answer. Feel free to fork: https://github.com/nordcomputer/magento2-showoutofstockprice Composer install should work if you add the repo to your dependencies. Be aware, that I set the required PHP version to ^7.1 - you may need to reconfigure that in the composer.json ...


3

The above one is a known issue for Magento and can be solved partially by installing the below extension. https://github.com/interjar/configurable-child-visibility Reference for the Issue can be found at Magento Issue 10454


3

I was facing the same issue in one of my projects recently. In my case the client wanted to display stock availability label (i.e. Instock/Outofstock) on category pages as well. That is not available in default magento. When saleable qty becomes 0 and quantity is 1 in that case PDP page was showing outofstock where the category page was still showing in ...


2

If you are able to add an extra class to the product image of the sold out product then you can solve it with pure CSS. Check: https://gist.github.com/karlhorky/3478370


2

Sorry if solution isn't very clean. I just copied from one of the modules which has been written many years ago... etc/config.xml <catalog_product_collection_load_before> <observers> <product_sort> <type>singleton</type> <class>custom/observer&...


Only top voted, non community-wiki answers of a minimum length are eligible