No Comments

Show selected out of stock products in front

Magento 2 - How to get attribute of product?
How to using instafeed in magento 2 with requirejs?

My all out of stock products are not shown at front.

However, I would like to show some selected out of stock products in front.

I have a custom attribute called show_out_of_stock_product and is yes/no type.

I want to show only those out of stock products that are set show_out_of_stock_product to yes.

I have tried to do it through observer using catalog_product_collection_load_before event, but no luck so far.

My approach was:

    $layer = Mage::getSingleton('catalog/layer');
    $category = $layer->getCurrentCategory();

    $products = Mage::getModel('catalog/product')
        ->getCollection()
        ->addCategoryFilter($category)
        ;

    $showOutCollection = $products
        ->addAttributeToFilter('out_stock_show_product', true)
        ;

Is it possible to add this $showOutCollection to the category with all other products.

Related Posts

  • Magento 2 get out of stock products in collection (0)
    I am trying to get all the products from the collection(both in stock and out of stock) but with no luck at all. The setting on admin needs to hide the out of stock products from frontend but I want to show them in a specific page. This is my code: $productCollection = […]
  • Magento 2 get out of stock products in collection (0)
    I am trying to get all the products from the collection(both in stock and out of stock) but with no luck at all. The setting on admin needs to hide the out of stock products from frontend but I want to show them in a specific page. This is my code: $productCollection = […]
  • Show out of stock products based on attribute value in layered navigation (1)
    As the title states, in Magento 1.9.2.2 I need to show products out of stock if they have the value of a specific attribute (for example the custom attribute 'always_show') set to 1 in the layered navigation. How do I accomplish that? Do I have to extend the […]
  • How to add layered Navigation filter as stock availability? (1)
    I want to add "Stock availability" as layered navigation filter. but i cant find this attribute in attribute set. Here Display two option under stock availability if i am select out of stock so display only out of stock product and same as in stock product.
  • How to sort product collection on stock status (1)
    I want to sort product collection on category page so that the in stock products shall appear before out of stock products. All the out of stock products will be displayed after the in stock products. I have already rewritten the Mage_Product_Block_List block. After rewriting I have […]
  • CSV imported product is not showing in Magento front end (2)
    I have uploaded product in CSV format. I set the product as enabled, stock as in_stock and quantity as 100 in CSV file, But the product is not showing in front end pages, But when I just open and save the product from admin panel the product is listing in front pages. Any help is […]
  • How to set the left menu on the product page? (1)
    I have a link left.phtml in catalog.hml. But I want to show it on the product page too. Category layered navigation layout --> <catalog_category_layered translate="label"> <label>Catalog Category (Anchor)</label> <reference […]
  • Setting default layout product detail page (1)
    I'm customizing the layout in CE-1.9.2.2. After selecting a product in the grid, I get to the productdetails. This page is shown in 1column-layout. I want to use the 3column-layout in this view. I know I can change the view for each product seperately, but I wan't it to be changed […]
  • Setting default layout product detail page (1)
    I'm customizing the layout in CE-1.9.2.2. After selecting a product in the grid, I get to the productdetails. This page is shown in 1column-layout. I want to use the 3column-layout in this view. I know I can change the view for each product seperately, but I wan't it to be changed […]
  • Layered navigation 'remembering' filter value on all categories (0)
    In my layered navigation I am able to select multiple attribute values to filter by. The issue I have is that when I move from one category to another those values are not clearing automatically. Is there anyway to ensure filter values are cleared if the user moves to a different […]
Magento 2 - How to get attribute of product?
How to using instafeed in magento 2 with requirejs?

Be the first to post a comment.

Add a comment

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax