0

I need to show all the newly created products on top. So need to arrange all the products according entity id in descending order

  • Please, show your collection? – Khoa TruongDinh Jun 6 '19 at 9:33
  • what do you mean by "product page"? the admin grid? the category in the storefront? – Philipp Sander Jun 6 '19 at 9:36
  • sorry it was category page on frontend – twinkle_gupta Jun 6 '19 at 11:08
1

Easiest and cleanest solution would be creating an "afterPlugin" on \Magento\Catalog\Model\Config\Source\ListSort::toOptionArray and adding $options[] = ['label' => __('Entity ID'), 'value' => 'entity_id'];

Once you did this, you can select the value in "Configuration -> Catalog -> Catalog -> Product Listing Sort by" to apply it to all categories by default.

  • Can you please explain more in detail this? where to put this file, how to declare? Thanks! – ʞᴉɯ Feb 14 at 6:29
  • as stated in the answer, you are supposed to create an afterPlugin. the documentation explains how to do this – Philipp Sander Feb 14 at 7:43

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.