Forked from SchumacherFM/Namespace_Module_Block_Adminhtml_Edit_Tab_XXXX.php
          
        
    
          Created
          February 12, 2016 07:13 
        
      - 
      
 - 
        
Save gopalkumar315/75435c67d600a67bc264 to your computer and use it in GitHub Desktop.  
Revisions
- 
        
SchumacherFM revised this gist
Dec 4, 2012 . 1 changed file with 24 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ <?php /* Set up: */ class Namespace_Module_Block_Adminhtml_News_Edit_Tab_Linking { protected function _prepareForm(){ ... $fieldSet->addField('product_categories', 'multiselect', array( 'name' => 'product_categories[]', 'label' => 'Product Categories', 'title' => 'Product Categories', 'required' => FALSE, 'values' => Mage::getModel('namespace_module/option_productcategories')->getOptionArray() )); ... } }  - 
        
SchumacherFM created this gist
Dec 4, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,66 @@ <?php class Namespace_Module_Model_Option_Productcategories extends Varien_Object { const REPEATER = '_'; const PREFIX_END = ''; protected $_options = array(); /** * @param int $parentId * @param int $recursionLevel * * @return array */ public function getOptionArray($parentId = 1, $recursionLevel = 3) { $recursionLevel = (int)$recursionLevel; $parentId = (int)$parentId; $category = Mage::getModel('catalog/category'); /* @var $category Mage_Catalog_Model_Category */ $storeCategories = $category->getCategories($parentId, $recursionLevel, TRUE, FALSE, TRUE); foreach ($storeCategories as $node) { /* @var $node Varien_Data_Tree_Node */ $this->_options[] = array( 'label' => $node->getName(), 'value' => $node->getEntityId() ); if ($node->hasChildren()) { $this->_getChildOptions($node->getChildren()); } } return $this->_options; } /** * @param Varien_Data_Tree_Node_Collection $nodeCollection */ protected function _getChildOptions(Varien_Data_Tree_Node_Collection $nodeCollection) { foreach ($nodeCollection as $node) { /* @var $node Varien_Data_Tree_Node */ $prefix = str_repeat(self::REPEATER, $node->getLevel() * 1) . self::PREFIX_END; $this->_options[] = array( 'label' => $prefix . $node->getName(), 'value' => $node->getEntityId() ); if ($node->hasChildren()) { $this->_getChildOptions($node->getChildren()); } } } }