On product listing page, I need to show visitor nearest product first.
I've a marketplace site and each product have different seller and there is a custom table having seller_id and product_id column.
Here is the structure screenshot of my custom table:-
So how can i get the seller id of each product on product lsiting page so that i can dispay nearest product first?I'm trying to use joins based on product_id on product collection here:-
But seems,there is some problem in the joining due to which filter is not working.
My Join Code:-
$collection->addAttributeToSelect('*'); $joinType = "inner"; // join type $where = ""; // put condition $fields = "*"; // fields $collection->joinTable( ['custom' => 'marketplace_product'], 'custom.mageproduct_id = e.id', //also tried "entity_id" instead of "id" $fields, $where, $joinType ); echo $collection->getSelect() ; exit; Not printing anything on listing page.
So please let me know the code so that i can use the join and get the seller_id and then i can calculate nearest one.
After using like that:-
$joinConditions = 'ust.mageproduct_id = e.entity_id'; $this->_collection->getSelect()->join( ['ust' => $this->_collection->getTable('marketplace_product')], $joinConditions,  )->columns("ust.seller_id");
Joining is working fine but now I'm getting "You cannot define a correlation name 'ust' more than once" problem so please help me to resolve this problem.
Waiting for your reply!