We have around 10 products in one category with category name as "custom" & id = "40"
We created some "Brands" [values] in backend.
Once we click on each brand, it will display like below image:
In above image, below Status
field, we want to create a Multiselect box [similar like store view] and we want to display those 10 products assigned to category "custom" in multi-select box.
app/code/local/Company/Brand/Block/Adminhtml/Item/Edit/Tab/Min.php
<?php
class Company_Brand_Block_Adminhtml_Category_Edit_Tab_Main extends Mage_Adminhtml_Block_Widget_Form
{
/**
* Preparation of current form
*
* @return Outthink_Brand_Block_Adminhtml_Category_Edit_Tab_Main
*/
protected function _prepareForm()
{
$model = Mage::registry('brand_category');
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('brand_');
$fieldset = $form->addFieldset('base_fieldset', array (
'legend' => Mage::helper('brand')->__('General information'),
'class' => 'fieldset-wide' ));
if ($model->getCategoryId()) {
$fieldset->addField('category_id', 'hidden', array (
'name' => 'category_id'
));
}
$fieldset->addField('category_name', 'text', array (
'name' => 'category_name',
'label' => Mage::helper('brand')->__('Category Name'),
'title' => Mage::helper('brand')->__('Category Name'),
'required' => true,
));
$fieldset->addField('cat_order', 'text', array (
'name' => 'cat_order',
'label' => Mage::helper('brand')->__('Category Order'),
'title' => Mage::helper('brand')->__('Category Order'),
'required' => false,
));
/**
* Check is single store mode
*/
if (!Mage::app()->isSingleStoreMode()) {
$fieldset->addField('store_id', 'multiselect',
array (
'name' => 'store_id[]',
'label' => Mage::helper('brand')->__('Store view'),
'title' => Mage::helper('brand')->__('Store view'),
'required' => true,
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true) ));
}
else {
$fieldset->addField('store_id', 'hidden', array (
'name' => 'store_id[]',
'value' => Mage::app()->getStore(true)->getId() ));
$model->setStoreId(Mage::app()->getStore(true)->getId());
}
$fieldset->addField('is_active', 'select',
array (
'label' => Mage::helper('brand')->__('Status'),
'title' => Mage::helper('brand')->__('Category Status'),
'name' => 'is_active',
'required' => true,
'options' => array (
'1' => Mage::helper('brand')->__('Enabled'),
'0' => Mage::helper('brand')->__('Disabled') ) ));
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
}
}
I will give 50 bounty points if it worked for me.