Magento 1.9 – How to Get Value from Database

databasemagento-1.9

I have this table in my Magento database:
'manthan_marketplace_vendorproduct':

    entity_id  product_id  user_id
       3          35          2 
       4          36          2

It shows all the products that have been added by each user(seller)
I can access the user_id value in my phtml file in this directory:

app\design\frontend\base\default\template\marketplace\seller\profile.phtml

by this code:

$seller = $this->sellerProfile();
$seller['user_id']; 

but $seller which is an array of objects, doesn't have any product_id. So I should use that table to get all product_id into an array
but the Magento framework is unknown for me.

Help me please, thanks!

Best Answer

Try below code to get product IDs for a seller.

$sellerData = Mage::getModel('marketplace/vendorproduct')->getCollection()‌​
->addFieldToFilter('user_id',$seller['user_id']) // Filter using seller Id
->getColumnValues('product_id'); // Get Only Product IDs
print_r($sellerData);
Related Topic