3

I am creating a special page only for the particular customer group.. So, Regardless of category, i need to get the products those are having exclusive price for that customer group..

I tried with the following but it's not working:

Mage::getModel('catalog/product')->getCollection()
    ->addAttributeToSelect('*')
    ->addFieldToFilter('customer_group_id', $groupId);

Any help would be greatly appreciated.

  • you mean a particular customer group? – Nikitas Dec 18 '13 at 13:42
  • Yes.. one particular customer group newly created. – phpdeveloperbalaji Dec 18 '13 at 13:49
  • not working? what are you getting? – Shathish Dec 19 '13 at 9:11
  • Fatal error: Call to a member function getBackend() on a non-object in /var/www/html/asterix/app/code/core/Mage/Eav/Model/Entity/Abstract.php on line 816 – phpdeveloperbalaji Dec 19 '13 at 9:24
2

Finally found the answer by myself..

<?php

$id = $this->getRequest()->getParam('id'); //Customer Group Id

$collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
 $collection->getSelect()->join(array('cpgp'=>Mage::getResourceModel('catalog/product')->getTable('catalog/product_attribute_group_price')),"e.entity_id=cpgp.entity_id and cpgp.customer_group_id='".$id."'",'*');

foreach($collection as $product)
{
    //Code Here
}

?>

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.