0

I'm trying to join custom table on product listing page,here is the Class and method:-

Class:- vendor/magento/module-catalog/Block/Product/ProductList/Toolbar.php

Method:- setCollection()

Here is the code of this method:-

 public function setCollection($collection)
    {
        $this->_collection = $collection;

       //My Custom Code

         $mpJoinConditions = 'mp.mageproduct_id = e.entity_id';

                       $this->_collection->getSelect()->join(
                ['mp' => $this->_collection->getTable('marketplace_product')],
                $mpJoinConditions,
                []
            )->columns("mp.seller_id");

       // End of My Custom Code

        $this->_collection->setCurPage($this->getCurrentPage());

        // we need to set pagination only if passed value integer and more that 0
        $limit = (int)$this->getLimit();
        if ($limit) {
            $this->_collection->setPageSize($limit);
        }
        if ($this->getCurrentOrder()) {
            $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
        }
        return $this;
    }

But getting following issue:-

"You cannot define a correlation name 'mp' more than once"

Please help me to resolve the issue!!!

0

Used Tablename "marketplace_product" instead of using alias "mp" and it's working fine now.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.