I want to get the Recently Viewed Products without using Widget or static Block I tried this
namespace PME\Hideprice\Block;
class getTestingData extends \Magento\Framework\View\Element\Template
{
protected $recentlyViewed;
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Reports\Block\Product\Viewed $recentlyViewed,
array $data = []
) {
$this->recentlyViewed = $recentlyViewed;
parent::__construct( $context, $data );
}
public function testing(){
return $this->recentlyViewed->getItemsCollection()->getData();
//return "Asad Khan";
}
}
I also tried
<?php echo $this->getLayout()->createBlock("Magento\Reports\Block\Product\Widget\Viewed")->setDisplayType("recently.view.products")->setProductsCount("5")->setTemplate("widget/viewed/content/viewed_list.phtml")->toHtml(); ?>
but both of these does not return me anything
but these classes does not return me anything. How to get all the recently viewed product?