Skip to content

Instantly share code, notes, and snippets.

@webdawe
Last active October 25, 2016 05:21
Show Gist options
  • Save webdawe/aa9a5fcb7db7c16c8680d6cc32e38f26 to your computer and use it in GitHub Desktop.
Save webdawe/aa9a5fcb7db7c16c8680d6cc32e38f26 to your computer and use it in GitHub Desktop.
Configuration Settings Source Model for Product Attribute Collection
<?php
/**
*
* @category Webdawe
* @package Webdawe_General
* @author Anil Paul
* @copyright Copyright (c) 2016 Anil Paul
* @license
*/
class Webdawe_General_Model_System_Config_Source_Product_Attribute
{
/**
* Retireve option Array of Product Attributes
* @return array
*/
public function toOptionArray()
{
$collection = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter(Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId())
//->addFieldToFilter('backend_type', 'int'); // Uncomment if you want to filter with backend type
$cols = array();
foreach($collection->getItems() as $col)
{
$cols[] = array('value' => $col->getAttributeCode(), 'label' => $col->getFrontendLabel());
}
return $cols;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment