We are using Magento 2.1.7 and building some API endpoints to serve our need.
Following is how we get Products list and send them as json from API call.
<?php
namespace Vendor\Customer\Model;
use Magento\Framework\Api\Filter;
class ProductRepository
{
protected $_productCollection, $productRepository, $searchCriteriaBuilder;
public function __construct(
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
\Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder
)
{
$this->productRepository = $productRepository;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
}
/**
* @return \Magento\Catalog\Api\Data\ProductSearchResultsInterface
*/
public function getProductCollection()
{
$searchCriteria = $this->searchCriteriaBuilder->create();
$this->_productCollection = $this->productRepository->getList($searchCriteria);
return $this->_productCollection;
}
}
We need to know if we can add some search criteria to getProductCollection() method using Filter to get only those products associated to some active catalog price rule with discounted price.
Or if we have any other method to get Products with Catalog Price Rule and discounted Price, guide me in that direction.