1

I'm new to Magento. Could you please spare few minutes to help me out?

I have added a new button in Catalog->Manage Products Grid.

When i select few products in the Product List and click my new button, i need to get all the attributes (Price, Product ID, SKU, status, etc,..) for the selected (check box selected) products.

And how to iterate through the list ? Could you please help me with the above.

Thanks

0

You could go with getting all attributesetids for all your products. After that, use this to get all distinct attributes for those attribute sets.

$productIds = $this->getRequest()->getParam('product_ids'); // do not know yet, guessing

// Assuming that $productIds is a array containing productIds

$collection = Mage::getResourceModel('catalog/product_collection');

$select = $collection->getSelect();
$connection = $collection->getConnection();

$select->reset(Zend_Db_Select::COLUMN)
    ->distinct()
    ->columns('attribute_set_id')
    ->where('entity_id', array('in' => $productId));

$attributeSetIds = $connection->fetchAll($select);

$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
    ->setAttributeSetsFilter($attributeSetIds);

foreach ($attributes as $attribute) {
    var_dump($attribute->getFrontendLabel());
}

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.