$Custommodel=$this->mycustommodelFactory->create();
$collection = $Custommodel->getCollection()->addFieldToFilter("customer_id",$customerid);
$collection->getSelect()->group('product_id')->order("viewed_date DESC");
while implement this way i getting wrong ordered records
what mistake there??
here this query runing magento SELECT
main_table
.* FROMwac_viewed_products
ASmain_table
WHERE (customer_id
= '4') GROUP BYproduct_id
ORDER BYviewed_date
DESC
->__toString()
to see what query is running and then try in MySQL console directly to see if what you are getting is what is expected?