0

I written Product collection but i can't able to get current seller id

public function getMy(){


        $collection = Mage::getResourceModel('catalog/product_collection');
        $collection->addAttributeToFilter('status',1); //only enabled product
        $collection->addAttributeToSelect('*'); //add product attribute to be fetched
        $collection->getSelect()->order('rand()');
        $collection->getSelect()->limit(5);
        //$collection->addAttributeToFilter('seller_id');
        $collection->addStoreFilter();
        return $collection;

    }

My problem is i want to display other product of same seller in product details page, So how to get Current seller id

Mage::getModel ( 'marketplace/sellerprofile' )
  • maybe ... addAttributeToSelect instead of to filter? – FlorinelChis Mar 28 '16 at 20:20
1

current seller will be customer id of current user. and you can get it with below code

public function getMy(){

if(Mage::getSingleton('customer/session')->isLoggedIn()) {
         $customerData = Mage::getSingleton('customer/session')->getCustomer();
          $seller_id= $customerData->getId();
     }
        $collection = Mage::getResourceModel('catalog/product_collection');
        $collection->addAttributeToFilter('status',1); //only enabled product
        $collection->addAttributeToSelect('*'); //add product attribute to be fetched
        $collection->getSelect()->order('rand()');
        $collection->getSelect()->limit(5);
        $collection->addAttributeToFilter($seller_id);
        $collection->addStoreFilter();
        return $collection;

    }
| improve this answer | |
  • How to get in collection – Magento 2 Mar 29 '16 at 5:10
  • updated the code............................ – Qaisar Satti Mar 29 '16 at 5:14
  • what doubt you have? – Qaisar Satti Mar 29 '16 at 5:17
  • query fetch more then 200 record i worte that collection in phtml it will take time to load in front end – Magento 2 Mar 29 '16 at 5:18
  • off course 200 record will take time. For that you add pagination – Qaisar Satti Mar 29 '16 at 5:20

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.