0

I am trying to get current seller id by product id in magento 2. I am try this also but its not useful for me.

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;

    }

I also try this

$collection = $objectManager->create(
                        'Webkul\Marketplace\Model\Product'
                    )
                    ->getCollection()
                    ->addFieldToFilter(
                        'mageproduct_id',
                        $id
                    );

Please help me..

4
  • Your question is not clear. We cant use 'Mage' class in magento 1 and your second try well give output of products. I am confused that what u want to say by current seller. – Mousam Roy Oct 1 '19 at 5:54
  • I have multiple seller in magento 2 marketplace. how i get Current seller id by product id.I just asked this. – Vishal Varshney Oct 1 '19 at 6:00
  • Check database there must be an relation between seller id and product id, base on that u can call seller collection by filter with product id. – Mousam Roy Oct 1 '19 at 6:14
  • Thank You for advise but in which table of database. – Vishal Varshney Oct 1 '19 at 6:26

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.