2

Here is my code

$vendorTableName = Mage::getSingleton('core/resource')->getTableName('marketplace/vendor');
    $vendorproductsTableName = Mage::getSingleton('core/resource')->getTableName('marketplace/vendorpro');
    $productsTableName = Mage::getSingleton('core/resource')->getTableName('catalog/product');
    $collection = Mage::getModel("marketplace/vendorpro")->getCollection();

    $collection->getSelect()
    ->joinLeft(array('ce1' => $vendorTableName), 'ce1.vendor_id=main_table.vendor_id', array('vendor_name','vendor_contact_email'));

    $collection->getSelect()
    ->joinLeft(
        array('prod' => 'catalog_product_entity'), 
        'prod.entity_id = main_table.mageproduct_id',
        array('sku')
    )
    ->joinLeft(
        array('cpev' => 'catalog_product_entity_varchar'), 
        'cpev.entity_id=main_table.mageproduct_id', 
        array('name' => 'value')
    ); 

I am not getting correct data i have only two entry in database but it returns more than 2 where is my mistake?

2
$vendorTableName = Mage::getSingleton('core/resource')->getTableName('marketplace/vendor');
    $vendorproductsTableName = Mage::getSingleton('core/resource')->getTableName('marketplace/vendorpro');
    $productsTableName = Mage::getSingleton('core/resource')->getTableName('catalog/product');
    $collection = Mage::getModel("marketplace/vendorpro")->getCollection();
$collection->getSelect()
        ->joinLeft(array('ce1' => $vendorTableName), 'ce1.vendor_id=main_table.vendor_id', array('vendor_name','vendor_contact_email'));
        $entityTypeId = Mage::getModel('eav/entity')
                ->setType('catalog_product')
                ->getTypeId();
        $prodNameAttrId = Mage::getModel('eav/entity_attribute')
            ->loadByCode($entityTypeId, 'name')
            ->getAttributeId();
        $collection->getSelect()
        ->joinLeft(
            array('prod' => 'catalog_product_entity'), 
            'prod.entity_id = main_table.mageproduct_id',
            array('sku')
        )
        ->joinLeft(
            array('cpev' => 'catalog_product_entity_varchar'), 
            'cpev.entity_id=prod.entity_id AND cpev.attribute_id='.$prodNameAttrId.'', 
            array('name' => 'value')
        ); 

Using this u can get proper sku and name of product.

It works for me.

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.