0

I've used following two joins on product listing page due to which heavier category page taking 4-5 minutes to load:-

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

Method:- setCollection()

public function setCollection($collection)
    {

        $this->_collection = $collection;


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


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



    // This join makes problem so heavier category taking time to load

       $mudJoinConditions = 'marketplace_userdata.seller_id = marketplace_product.seller_id';

                       $this->_collection->getSelect()->joinLeft(
                 $this->_collection->getTable('marketplace_userdata'),
                $mudJoinConditions,
                []
            )->columns("marketplace_userdata.latitude")
            ->columns("marketplace_userdata.longitude")->where("marketplace_userdata.store_id = '0'");


        $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()) {
            if ($this->getCurrentOrder() == 'position') {
                $this->_collection->addAttributeToSort(
                    $this->getCurrentOrder(),
                    $this->getCurrentDirection()
                )->addAttributeToSort('entity_id', $this->getCurrentDirection());
            } else {
                $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
            }
        }
          // echo $this->_collection->getSelect() ; exit;
        return $this;
    }

Note:-If I'm using only first join($mpJoinConditions) then everything works fine.after adding second join ($mudJoinConditions) getting problem.

Please help me to resolve this very urgent issue.

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.