0

This might've been asked before, and I'm kind of sure it was. But unfortunately, I did not succeed to find the answer to this.

I'm deeply sorry.

So let's get to the question.
We've been working with Magento for several years. Now, we've stubled across a problem.
When we add products to our Magento webshop, it used to appear as first product in de category. It was sorted from newly added to old.

Now, in Magento 1.9.1.1 and 1.9.0.1 it appears that it is not doing it like this anymore.

So how can I change this? I have seen that you can change a product's position within the category, but if I added a new product, it means I have to reposition every other product.

I know there are plugins/extensions for this. But there must be another way, right?

I would love to know! Feel free to ask for more info!

  • I don't think that this was ever an out of the box functionality in Magento to begin with. The update probably killed a core hack that you had – Yiorgos Moschovitis Jun 1 '16 at 9:43
  • @YiorgosMoschovitis, yeah that might've been it then. Fortunately, my question got answered right away. – Sj03rs Jun 1 '16 at 10:13
3

You need to do some coding, if you can then following code work for you.

Now let ‘s copy:

app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php

to:

app/code/local/Mage/Catalog/Block/Product/List/Toolbar.php

(create a new directory if it is not exists).

Open new file and look at these lines of code in around line 232:

if ($this->getCurrentOrder()) {
    $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
}

Now, replace with these lines:

if ($this->getCurrentOrder()) {
    if(($this->getCurrentOrder())=='position'){
        $this->_collection->setOrder('entity_id','desc');
    }
    else {
        $this->_collection->setOrder($this->getCurrentOrder(),$this->getCurrentDirection());
    }
}

That ‘s all, now remember to clear all cache and reindex too see the magic.

For more see here.

| improve this answer | |
  • WOW, this worked like a charm, and I am happy that we do not really mess with the core code! Thank. You. So. Much! – Sj03rs Jun 1 '16 at 10:13

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.