Skip to content

Instantly share code, notes, and snippets.

@ankitsam
Last active September 21, 2017 16:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ankitsam/d462634215ad38d7e757 to your computer and use it in GitHub Desktop.
Save ankitsam/d462634215ad38d7e757 to your computer and use it in GitHub Desktop.
Magento Category Products List Sort by Product ID
<?php
/* Copy file
* app\code\core\Mage\Catalog\Block\Product\List.php
* to
* app\code\local\Mage\Catalog\Block\Product\List.php
*/
/* Replace */
$this->_productCollection = $layer->getProductCollection()->addAttributeToSort($_GET['order'], $_GET['dir']);
/* With */
if($_GET['dir'] == NULL)
$this->_productCollection = $layer->getProductCollection()->addAttributeToSort('entity_id', 'desc');
else
$this->_productCollection = $layer->getProductCollection()->addAttributeToSort($_GET['order'], $_GET['dir']);
?>
@albertobraschi
Copy link

tnx mate!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment