1

i want to show products in order of most viewed on listing page i did below changed on my list.phtml but it seems not working

file : app/design/frontend/colora/colora_default/Magento_Catalog/templates/product/list.phtml

modified

$_productCollection = $block->getLoadedProductCollection();

to

$_productCollection->getSelect()->
            joinInner('report_event AS _table_views',
                ' _table_views.object_id = e.entity_id',
                'COUNT(_table_views.event_id) AS views')->
            group('e.entity_id')->order('views ASC');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.