0

In Magento 1.x I have used the Tridian New Arrivals code to list "New Arrivals" on my homepage.

Moving to Magento 2.1.5, I want to do the same thing, but am lost in how to achieve this?

Perhaps the easiest way to describe this is I want to display a list of products most recently created in Magento (so based on the product ID, in descending order - most recently created item being the top of the resultant list).

My products do not have the "new from" dates set in magento, so I need to use the product ID method for this task.

Can anyone point me in the right direction to achieve this?

2 Answers 2

1

Create a custom module

in block file use

 use Magento\Catalog\Model\ProductFactory;
    use Magento\Framework\View\Element\Template\Context;

    protected $_productFactory;

    public function __construct(
       Context $context, 
       ProductFactory $productFactory,
       array $data = array()       
    ) {
       $this->_productFactory   = $productFactory;
       parent::__construct($context, $data);
    }

    public function getProductCollection() {
       $productCollection =  = $this->_productFactory->create()->getCollection();
      $productCollection->setOrder('product_id','ASC');
$productCollection->setPageSize(3) // or whatwever number of product is required
       return $productCollection;
    }

And fetch this collection template file

you can also use widget for these

1
0
  1. On the Admin sidebar, tap Content > Elements > Widgets.
  2. In the upper-right corner, click Add New Widget button.
  3. In the setting section: Set Type to “Catalog New Products List.”
  4. Set Design Theme to the current used theme of your store.
  5. Click Continue and set location for that widget like CMS home page

Reference: https://www.mageplaza.com/kb/how-to-insert-new-products-list-in-widget-magento-2.html

1
  • Thanks for this - they appear to have updated this widget to not need the New Date field populating, which is cool. However, it isn't listing the new products from the latest first for me (newest items listed in descending order, should display the very latest added product at first place in the listing). It seems to have picked a random spot somewhere in the middle of all my products, and started the listing from there, and it is in Ascending order too! Any idea how to fix that?
    – robgt
    Apr 27, 2017 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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