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' )
1
  • maybe ... addAttributeToSelect instead of to filter? Commented Mar 28, 2016 at 20:20

1 Answer 1

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;

    }
27
  • How to get in collection
    – Magento 2
    Commented Mar 29, 2016 at 5:10
  • updated the code............................ Commented Mar 29, 2016 at 5:14
  • what doubt you have? Commented Mar 29, 2016 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
    Commented Mar 29, 2016 at 5:18
  • off course 200 record will take time. For that you add pagination Commented Mar 29, 2016 at 5:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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