Ejemplo n.º 1
0
 /**
  * prepare grid columns
  *
  * @return Mage_Adminhtml_Block_Widget_Grid
  */
 protected function _prepareColumns()
 {
     $this->addColumn('item_id', array('header' => $this->__('ID'), 'align' => 'right', 'width' => '50px', 'type' => 'int', 'index' => 'item_id'));
     $this->addColumn('store_id', array('header' => $this->__('Store'), 'align' => 'left', 'width' => '100px', 'index' => 'store_id', 'sortable' => false, 'type' => 'options', 'options' => Mage::getModel('core/store')->getCollection()->toOptionHash()));
     $this->addColumn('label', array('header' => $this->__('Label'), 'align' => 'left', 'index' => 'label'));
     $this->addColumn('type', array('header' => $this->__('Type'), 'align' => 'left', 'index' => 'type', 'type' => 'options', 'options' => VF_CustomMenu_Model_Resource_Menu_Attribute_Source_Type::getValues()));
     $this->addColumn('info', array('header' => $this->__('Info'), 'align' => 'left', 'index' => 'info', 'renderer' => 'VF_CustomMenu_Block_Adminhtml_Menu_Grid_Renderer_Info'));
     $this->addColumn('position', array('header' => $this->__('Position'), 'align' => 'left', 'width' => '50px', 'index' => 'position'));
     return parent::_prepareColumns();
 }
Ejemplo n.º 2
0
 /**
  * prepare the form
  *
  * @return Mage_Adminhtml_Block_Widget_Form|void
  */
 protected function _prepareForm()
 {
     //add form
     $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id', null))), 'method' => 'post'));
     $form->setUseContainer(true);
     $this->setForm($form);
     //add fieldset
     $fieldSet = $form->addFieldset('custom_menu_form', array('legend' => $this->__('Menu Item')));
     $fieldSet->addField('store_id', 'select', array('label' => $this->__('Store'), 'name' => 'store_id', 'values' => Mage::getModel('core/store')->getCollection()->toOptionHash()));
     $fieldSet->addField('label', 'text', array('label' => $this->__('Label'), 'class' => 'required-entry', 'required' => true, 'name' => 'label'));
     $fieldSet->addField('type', 'select', array('label' => $this->__('Type'), 'class' => 'required-entry', 'required' => 'true', 'name' => 'type', 'options' => VF_CustomMenu_Model_Resource_Menu_Attribute_Source_Type::getValues()));
     $fieldSet->addField('url', 'text', array('label' => $this->__('Url'), 'name' => 'url', 'note' => $this->__('Url without base url. To display "http://www.domain.com/test-page.html", enter "test-page.html". Leave blank to use default category URL')));
     $fieldSet->addField('title', 'text', array('label' => $this->__('Title'), 'name' => 'title'));
     $fieldSet->addField('position', 'text', array('label' => $this->__('Position'), 'name' => 'position', 'note' => $this->__('Default 0')));
     $fieldSet->addField('source_attribute', 'select', array('label' => $this->__('Source Attribute'), 'name' => 'source_attribute', 'note' => $this->__('If you select attribute, ' . 'you will see dropdown with its values for layered navigation'), 'values' => Mage::getModel('menu/attribute')->getSourceAttributes()));
     /** @var $categories Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */
     $categories = Mage::getModel('catalog/category')->getCollection();
     $categories->addAttributeToSelect('name');
     $values = array(array('label' => '', 'value' => ''));
     foreach ($categories as $_category) {
         $catId = $_category->getId();
         $values[] = array('value' => $catId, 'label' => $_category->getName() . " ({$catId})");
     }
     $fieldSet->addField('default_category', 'select', array('label' => $this->__('Category'), 'name' => 'default_category', 'note' => $this->__('Custom default category'), 'values' => $values));
     $data = Mage::registry('current_menu');
     $showChildren = false;
     if ($data) {
         $showChildren = $data->getShowChildren();
     }
     $fieldSet->addField('show_children', 'checkbox', array('label' => $this->__('Show Children'), 'name' => 'show_children', 'checked' => $showChildren));
     $fieldSet->addField('is_current_exclusive', 'select', array('label' => $this->__('Is Current Exclusive'), 'name' => 'is_current_exclusive', 'values' => Mage::getSingleton('adminhtml/system_config_source_yesno')->toOptionArray(), 'note' => $this->__('For this item to have the \'current\' classname applied on a PDP, that product must be assigned ONLY to this category or its children')));
     if ($data) {
         $form->setValues($data->getData());
     }
     parent::_prepareForm();
 }