• info@synamen.com
  • +91-89396 79369
  • Reach Us
synamen-logo
  • Home
  • Solutions
    E-Commerce Development Magento E-Commerce Management Mobile App Development Oracle Cloud Solutions
  • Products
    Splurgify for M-commerce MeterDesk -Energy Management & Industrial Analytics Enquiry Management System
  • Portfolio
  • Company
    About Us Our Team News Reach Us
  • Careers
  • Blog

Home >> Blog >> Out Of Stock Products To The End Of The List In Magento Category Page

magento-management-solutions

03 May 2017

Out Of Stock Products To The End Of The List In Magento Category Page

Posted By : AdminPerson Magento
The shopping experience has gone better and better with more and more eCommerce sites. Magentois the market leader among E-Commerce platform. The leading E-Commerce sites such as Amazon, Flipkart, etc., are listing the products even if there is no stock in it, but listing it at the end of the listed items. However, this feature is not available with default Magento platform as out of stock products should be pushed to the end of the list. Here we are giving you the way to achieve the task with code (query). This is a working code, running successfully with our live projects. Please follow the below steps to achieve it.

Step 1 :  Using your file explorer copy file Layer.php from app/code/core/Mage/Catalog/Model/ and paste to app/code/local/Mage/Catalog/Model/

Step 2 :  Open the newly copied file i.e., app/code/local/Mage/Catalog/Model/Layer.php using your code editor such as Notepad or Sub Lime

Step 3 :  Search for the function getProductCollection(), which needs to be inserted with a below query

$collection->getSelect()->joinLeft(array('stock_status'=>$collection->getTable('cataloginventory/stock_status')),'e.entity_id = stock_status.product_id AND stock_status.website_id='.Mage::app()->getWebsite()->getId());

$collection->getSelect()->order('stock_status DESC');

 This query to be inserted next to "$collection = $this->getCurrentCategory()->getProductCollection();" with appropriate comment Step 4 :  After inserting the query overridden function getProductCollection() should look like
 

public function getProductCollection()

{

    if (isset($this->_productCollections[$this->getCurrentCategory()->getId()])) {

        $collection = $this->_productCollections[$this->getCurrentCategory()->getId()];

    } else {

        $collection = $this->getCurrentCategory()->getProductCollection();

 /********************** QUERY TO DISPLAY OUT OF STOCK PRODUCTS TO THE END OF LIST IN CATEGORY PAGE ***********************/

         $collection->getSelect()->joinLeft(array('stock_status' => $collection->getTable('cataloginventory/stock_status')),'e.entity_id = stock_status.product_id AND stock_status.website_id='.Mage::app()->getWebsite()->getId());

        $collection->getSelect()->order('stock_status DESC');

        $this->prepareProductCollection($collection);

        $this->_productCollections[$this->getCurrentCategory()->getId()] = $collection;

    }

    return $collection;

}

Share this Article on

  • Facebook
  • Twitter
  • LinkedIn

Tags: magento


Related Posts

How Magento Framework Benefits B2B E-Commerce Businesses?

What does Magento 2 provide in terms of ‘Critical Security and Software Updates’ to keep your website safe

Are you ready to take international customers and reach the global market?

3 New Magento Tools To Boost Your E-Commerce Growth In 2022

Custom Shopping Cart Price Rule Condition

Archive

  • 2022

    September

    July

    April

    March

    February

  • 2019

    March

    February

    January

  • 2018

    December

    November

    October

    September

    August

    July

    June

    March

    February

    January

  • 2017

    December

    November

    October

    September

    August

    July

    June

    May

    April

    March

    February

  • 2013

    December

    September

Tags

add new condition in shopping cart admin admob analytics artificial intelligence augmented information augmented reality automation avoid jquery b2b b2b business b2c bounce rate bvp corporate crawling custom catalogs custom shopping cart price rule customer customer engagement customer satisfaction digital marketing e-commerce e-commerce checkout ecommerce customer experience erp form rules form validation generic google ranking google search googlebot http https hybrid ideas innovation international ionic javascript m-commerce machine learning magento magento e-commerce magento pwa studio mobile advertising platform mobile app development mobile application mobile apps mobile commerce strategy
Synamen-logo

Synamen is an Internet consulting company focusing on efficient use of Internet and Web technologies in business. We are into E-Commerce Development, Magento Development and Mobile App Development Services.

Read More

Solutions

  • E-Commerce Development
  • Magento E-Commerce Management
  • Mobile App Development
  • Oracle Cloud Solutions

Products

  • Mobile E-Commerce Solution
  • Energy Management & Industrial Analytics
  • Enquiry Management System

Reach Us

  • Synamen Thinklabs Pvt Ltd
    #7, Second Floor, Seetha Nagar Main Road, Nungambakkam, Chennai - 600034. India.
  • +91-89396 79369
  • info@synamen.com

© 2007 - Synamen Thinklabs Pvt Ltd. All rights reserved     Privacy Policy