Public Member Functions | |
toOptionArray ($addEmpty=true) |
Definition at line 34 of file Category.php.
toOptionArray | ( | $ | addEmpty = true |
) |
Definition at line 36 of file Category.php.
00037 { 00038 $tree = Mage::getResourceModel('catalog/category_tree'); 00039 00040 $collection = Mage::getResourceModel('catalog/category_collection'); 00041 00042 $collection->addAttributeToSelect('name') 00043 ->addPathFilter('^1/[0-9]+$') 00044 ->load(); 00045 00046 $options = array(); 00047 00048 if ($addEmpty) { 00049 $options[] = array( 00050 'label' => Mage::helper('adminhtml')->__('-- Please select a category --'), 00051 'value' => '' 00052 ); 00053 } 00054 foreach ($collection as $category) { 00055 $options[] = array( 00056 'label' => $category->getName(), 00057 'value' => $category->getId() 00058 ); 00059 } 00060 00061 return $options; 00062 }