0

after chaning line 87 in list.php (/public_html/app/code/local/Mage/Catalog/Block/Product) from:

$this->_productCollection = $layer->getProductCollection();

to

$this->_productCollection = $layer->getProductCollection()->joinField('inventory_in_stock', 'cataloginventory_stock_item', 'is_in_stock', 'product_id=entity_id','is_in_stock>=0', 'left')->setOrder('inventory_in_stock','desc');

I am doing this so that products that are in stock are shown before products out of stock.

It's working, but when I search in the search bar, see attached image for error. Error log

Thank you.

0

I would suggest to use this : https://github.com/MaximusDecimus/ShowInStockFirst

Free module and will do the job - tested it and it is working

  • Hi Ahmed, thank you for your answer. I tested the plugin on my webshop, but it did not work. I have contacted the author of the module but with no response yet. – Sebastian Søe Apr 20 '16 at 20:21
  • why it didn't work, what issue did you get? do you have another module effecting the category listing or creating custom sorting? – Ahmed Elawadi Apr 22 '16 at 10:04
  • Hi again, I do not believe that I have any other module affecting category listing or sorting. I made sure that the module was enabled on my admin page, and it showed up, but it didn't re-arrange the products on my website. – Sebastian Søe Apr 22 '16 at 15:21
0

I managed to fix this by removing my search module "searchanise". So it works like a charm now ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.