cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2 Latest Products page

Magento 2 Latest Products page

I'm already searching for a while but I couldn't find any advice for this problem.

I want to create a new magento page, where I display the latest products in the common catalog style. The goals I want to achieve are: - Display the new product sorted by the latest added one to the oldest - Display all Products tagged with New or at least the 27 latest ones

I already achieved, that I created an own block which extends the common product list:

Code at the Magento page

 

{{block class="Test\CustomLayouts\Block\Product\CustomList" template="Magento_Catalog::product/list.phtml"}

Test\CustomLayouts\Block\Product\CustomList

<?php

namespace Test\CustomLayouts\Block\Product;

use Magento\Catalog\Block\Product\ListProduct;
use Magento\Catalog\Model\ResourceModel\Collection\AbstractCollection;

class CustomList extends ListProduct
{
    public function __construct(
        \Magento\Catalog\Block\Product\Context $context,
        \Magento\Framework\Data\Helper\PostHelper $postDataHelper,
        \Magento\Catalog\Model\Layer\Resolver $layerResolver,
        \Magento\Catalog\Api\CategoryRepositoryInterface $categoryRepository,
        \Magento\Framework\Url\Helper\Data $urlHelper,
        array $data = []
    ) {
        parent::__construct($context, $postDataHelper, $layerResolver, $categoryRepository, $urlHelper, $data);
    }

}

How can I achieve the filtering. Is it possible to sort and filter inside the block? Or do I also need to create my own list.phtml?

I hope anyone can help me with this problem.