I have been doing frontend magento for a while, but just started creating modules. This is what I know how to do the interface, but I'm afraid in my module. What I'm trying to achieve at the moment fills multiselect in admin with all available product attributes. Including custom product attributes for all product attribute sets. I'm not quite sure which table this will require, because I don't want to assume that Flat data is included.
I created my administration area on a new tab in the system configuration, I created a multi selector field, which is currently populated with three static parameters. It works a lot. Can someone help me by pointing my finger in the right direction ... Currently, this is what I still have (for what it's worth).
<?php class test_test_Model_Source { public function toOptionArray() { return array( array('value' => 0, 'label' =>'First item'), array('value' => 1, 'label' => 'Second item'), array('value' => 2, 'label' =>'third item'), ); } }
///////////////////////////// EDIT //////////////////// /////////////////
I feel like I can be on something here, but it only returns the first letter of each attribute (so I'm not sure if even its attributes are returned)
public function toOptionArray() { $attributes = Mage::getModel('catalog/product')->getAttributes(); $attributeArray = array(); foreach($attributes as $a){ foreach($a->getSource()->getAllOptions(false) as $option){ $attributeArray[$option['value']] = $option['label']; } } return $attributeArray; }
///////////////////////////////// EDIT //////////////// //////////////////////
I'm not very close, because now I know that the array returns what I want, all the code_attributes. However, he still only displays the first letter of each ... Does anyone know why?
public function toOptionArray() { $attributes = Mage::getModel('catalog/product')->getAttributes(); $attributeArray = array(); foreach($attributes as $a){ foreach ($a->getEntityType()->getAttributeCodes() as $attributeName) { $attributeArray[$attributeName] = $attributeName; } break; } return $attributeArray; }
Frank clark
source share