I want to show marketplace dropdown name in magento grid but what i write in my code that display marketplace value.Bellow is my code
protected function _prepareColumns()
{
$this->addColumn('marketplace', array(
'header' => Mage::helper('adminhtml')->__('Marketplace'),
'align' =>'right',
'width' => '10px',
'index' => 'marketplace',
));
$this->addColumn('action',
array(
'header' => Mage::helper('adminhtml')->__('Action'),
'width' => '100px',
'type' => 'action',
'getter' => 'getId',
'actions' => array(array(
'caption' => Mage::helper('adminhtml')->__('Edit'),
'url' => array('base' => '*/*/edit'),
'field' => 'id'
)),
'filter' => false,
'sortable' => false,
'index' => 'id',
));
return parent::_prepareColumns();
}
could anyone please point out what i am doing wrong as i do not have much experience in magento.
Thanking you all in advance
add field type for market place like...
$this->addColumn('marketplace', array(
'header' => Mage::helper('adminhtml')->__('Marketplace'),
'align' =>'right',
'width' => '10px',
'index' => 'marketplace'
'type' => 'options',
'options' => array(
6 => '6',
5 => '4',
4 => '4',
3 => '3',
2 => '2',
1 => '1'
),
));
Related
$this->widget(
'bootstrap.widgets.TbGridView',
array(
'id' => 'birthday-report-grid',
'dataProvider' => $model->search(),
'selectableRows' => 0,
'ajaxType' =>'get',
'template' => GridHelper::getTemplate(),
'type' => GridHelper::getType(),
'enablePagination' => TRUE,
'enableSorting' => TRUE,
'filter' => $model,
'pager' => GridHelper::getPager(),
'columns' => array(
array(
'header' => Yii::t('backend', 'Customer Name'),
'name' => 'fullname',
'type' =>'raw',
'value' => '$data["customer_id"] ? CHtml::link($data->getCompleteName(),array("/admin/customer/profile/".$data["customer_id"]."/dashboard")) : $data->getCompleteName()',
'filter'=>CHtml::activeTextField($model, 'fullname').CHtml::activeTextField($model, 'month', array('id'=>'Filmonth','style' => 'Display:none;')),
),
array(
'name' => 'email',
'header' => Yii::t('backend', 'Customer Email'),
),
array(
'name' => 'birthday_month',
'value' => '!empty($data->birthday_month) && $data->birthday_month > 0 ? date("F", strtotime("1-".$data->birthday_month."-1970")) : ""',
'filter' => false,
),
array(
'name' => 'primary_phone',
'header' => Yii::t('backend', 'Customer Contact'),
'filter' => false,
),
array(
'header' => Yii::t('backend', 'Total Order (To Date)'),
'value' => '$data->getNoOfOrder2()',
'htmlOptions' => array('style' => 'text-align: right'),
'footer' => '<div style="text-align: right">'.$model->getTotalOfOrder().'</div>',
),
array(
'header' => Yii::t('backend', 'Total Order Amount (To Date)'),
'value' => 'CurrencyHelper::formatPrice($data->getTotalAmountOfOrderByCustomerId2())',
'htmlOptions' => array('style' => 'text-align: right'),
'footer' => '<div style="text-align: right">'.CurrencyHelper::formatPrice($model->getGrandTotalAmountOrder()).'</div>',
),
)
)
);
WHat i want is how to get sort value (Example: sort=fullname) what i want is "fullname"
i mean when i click column sorting on Customer Fullname , i can get the sort value using Jquery
Example image:
When Click sorting on "Customer Fullname" i need get sorting value (sort="VALUE")
Please help me thanks
I have created a Magento Admin Grid and am using Mass Action to set the start and stop dates.
Now my Mass Action runs as chosen in dropdown list select start or stop datepicker box will show after select first box.
Can I show two boxes at same time (dropdown list and datepicker) or select date before dropdown list?
My code:
$this->getMassactionBlock()->addItem('setstartdate', array(
'label' => $this->__('Set Start Date'),
'url' => $this->getUrl('*/*/massSetstartdate', array('' => '')),
'confirm' => $this->__('Are you sure?'),
'additional' => array(
'setstartdate' => array(
'name' => 'setstartdate',
'time' => true,
'input' => 'datetime',
'type' => 'datetime',
'class' => 'required-entry',
'label' => Mage::helper('setcustomdate')->__('Set start Date'),
// 'gmtoffset' => true,
'image' => '/skin/adminhtml/default/default/images/grid-cal.gif',
'format' => 'yyyy-MM-dd H:mm:ss'
)
)
));
$this->getMassactionBlock()->addItem('setstopdate', array(
'label' => $this->__('Set Stop Date'),
'url' => $this->getUrl('*/*/massSetstopdate', array('' => '')),
'confirm' => $this->__('Are you sure?'),
'additional' => array(
'setstopdate' => array(
'name' => 'setstopdate',
'time' => true,
'input' => 'datetime',
'type' => 'datetime',
'class' => 'required-entry',
'label' => Mage::helper('setcustomdate')->__('Set Stop Date'),
// 'gmtoffset' => true,
'image' => '/skin/adminhtml/default/default/images/grid-cal.gif',
'format' => 'yyyy-MM-dd H:mm:ss'
)
)
));
Edit 1 update prepareColumns
protected function _prepareColumns() {
$helper = Mage::helper('setupdate');
$this->addColumn('data_id', array(
'header' => $helper->__('Data No.'),
'index' => 'data_id'
));
$this->addColumn('startdate', array(
'header'=> $helper->__('Start'),// store
'index' => 'startdate',
'filter_index' => 't1.start_date',
'format' => 'F',
'type' => 'datetime',
));
$this->addColumn('stopdate', array(
'header'=> $helper->__('Stop'),// store
'index' => 'stopdate',
'filter_index' => 't1.stop_date',
'format' => 'F',
'type' => 'datetime',
));
return parent::_prepareColumns();
}
I want to create select type for a grid column in magento admin panel.inside _prepareColumns() function
protected function _prepareColumns()
{
if (!$this->getCategory()->getProductsReadonly()) {
$this->addColumn('in_category', array(
'header_css_class' => 'a-center',
'type' => 'checkbox',
'name' => 'in_category',
'values' => $this->_getSelectedProducts(),
'align' => 'center',
'index' => 'entity_id'
));
}
$this->addColumn('entity_id', array(
'header' => Mage::helper('catalog')->__('ID'),
'sortable' => true,
'width' => '60',
'index' => 'entity_id'
));
$this->addColumn('name', array(
'header' => Mage::helper('catalog')->__('Name'),
'index' => 'name'
));
$this->addColumn('position', array(
'header' => Mage::helper('catalog')->__('Position'),
'width' => '1',
'type' => 'select',
'index' => 'position',
'editable' => !$this->getCategory()->getProductsReadonly()
//'renderer' => 'adminhtml/widget_grid_column_renderer_input'
));
return parent::_prepareColumns();
}
Magento uses addColumn() function to create grid column, I want to create a column with select type, but I don't know how to provide it with options
Grid.php
$this->addColumn('state', array(
'header' => Mage::helper('modulename')->__('State'),
'index' => 'state',
'type' => 'options',
'options'=> Mage::getModel('modulename/customerstate')->getStates()
));
Model/Customerstate.php
public function getStates() {
$statesArray = array();
foreach($this->getCollection() as $state){
$statesArray[$state->getId()] = $state->getState();
}
return $statesArray;
}
First of all excuse my bad english.
I got a problem with my select-field in the BE. I would like to prefill (preselect) all of the available items.
Code in ext_tables.php:
'teilnehmer' => array(
'exclude' => 0,
'label' => 'LLL:EXT:kiwanisext/Resources/Private/Language/locallang_db.xlf:tx_kiwanisext_domain_model_veranstaltung.teilnehmer',
'config' => array(
'type' => 'select',
'foreign_table' => 'fe_users',
'MM' => 'tx_kiwanisext_veranstaltung_user_mm',
'size' => 10,
'autoSizeMax' => 30,
'maxitems' => 9999,
'multiple' => 0,
'wizards' => array(
'_PADDING' => 1,
'_VERTICAL' => 1,
'edit' => array(
'type' => 'popup',
'title' => 'Edit',
'script' => 'wizard_edit.php',
'icon' => 'edit2.gif',
'popup_onlyOpenIfSelected' => 1,
'JSopenParams' => 'height=350,width=580,status=0,menubar=0,scrollbars=1',
),
'add' => Array(
'type' => 'script',
'title' => 'Create new',
'icon' => 'add.gif',
'params' => array(
'table' => 'fe_users',
'pid' => '###CURRENT_PID###',
'setValue' => 'prepend'
),
'script' => 'wizard_add.php',
),
),
),
),
I found nothing helpful in the documentation.
Any hint, tip or help will be much appreciated!
Its not possible to do that with plain TCA config, afaik. You can however define a default value wich will be selected (if none is defines, 1st item will be selected).
'default' => 'myValue'
But to preselect multiple values at once, you have to use JavaScript I guess.
This code worked for me in typo3 6.2. I have a selectbox filled with database records.
I want the records with ID's 1 ans 2 to be preselected in the selectbox:
'thematique' => array(
'exclude' => 0,
'label' => 'LLL:EXT:dk_actus/locallang_db.xml:tx_dkactus_thematique',
'config' => array(
'type' => 'select',
'foreign_table' => 'tx_dkactus_thematique',
'foreign_table_where' => 'ORDER BY tx_dkactus_thematique.uid',
'size' => 10,
'minitems' => 0,
'maxitems' => 99,
'default' => '1,2',
),
),
I've been writing a custom out of stock module for the magento backend, I have mass actions, export etc working. However when i do any sort of search function (like put something in the product name field) and indeed try to change to the next page (or input a specific page into the field) or how many products appear on a page. It immediately redirects me to the dashboard.
Can anyone point me in the right direction as to where the code is that handles this function? I'm going to assume its part of the controller, but i've been searching for the last hour and is now time to ask for help!!
Thanks for any help you can provide!
Prepare columns function:
protected function _prepareColumns()
{
$this->addColumn('sku',
array(
'header'=> Mage::helper('catalog')->__('SKU'),
'width' => '80px',
'index' => 'sku',
));
$sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
->load()
->toOptionHash();
$this->addColumn('set_name',
array(
'header'=> Mage::helper('catalog')->__('Attrib. Set Name'),
'width' => '60px',
'index' => 'attribute_set_id',
'type' => 'options',
'options' => $sets,
));
$store = $this->_getStore();
if ($store->getId()) {
$this->addColumn('custom_name',
array(
'header'=> Mage::helper('catalog')->__('Name in %s', $store->getName()),
'index' => 'custom_name',
));
}
$this->addColumn('name',
array(
'header'=> Mage::helper('catalog')->__('Name'),
'index' => 'name',
));
$this->addColumn('stock_status',
array(
'header'=> 'Availability',
'width' => '60px',
'index' => 'stock_status',
'type' => 'options',
'options' => array('1'=>'In stock','0'=>'Out of stock'),
));
$this->addColumn('custom_stock_status',
array(
'header' => 'Custom Stock Status',
'width' => '60px',
'index' => 'custom_stock_status',
'type' => 'options',
'editable' => 'true',));
$this->addColumn('eol',
array(
'header'=> Mage::helper('catalog')->__('EoL'),
'width' => '20px',
'type' => 'checkbox',
'index' => 'eol',
'onclick' => 'this.value = this.checked ? 1 : 0;',
'values' => array('1','2'),
'editable' => 'true',
));
$store = $this->_getStore();
$this->addColumn('qty',
array(
'header'=> Mage::helper('catalog')->__('Qty'),
'width' => '25px',
'type' => 'number',
'index' => 'qty',
));
$this->addColumn('status',
array(
'header'=> Mage::helper('catalog')->__('Status'),
'width' => '70px',
'index' => 'status',
'type' => 'options',
'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
));
$this->addColumn('action',
array(
'header' => Mage::helper('catalog')->__('Action'),
'width' => '90px',
'type' => 'action',
'getter' => 'getId',
'actions' => array(
array(
'caption' => Mage::helper('catalog')->__('Edit Product'),
'url' => array(
'base'=>'store_admin/catalog_product/edit',
'params'=>array('store'=>$this->getRequest()->getParam('store'))
),
'field' => 'id'
)
),
'filter' => false,
'sortable' => false,
'index' => 'stores',
));
$this->addRssList('rss/catalog/notifystock', Mage::helper('catalog')->__('Notify Low Stock RSS'));
return parent::_prepareColumns();
}
Furthermore i'm trying to filter by an attribute, I need to filter the same attribute twice in order to output both null and no attributes, but not yes. Is there anyway to do this?
->addAttributeToFilter('eol', array('null' => true), 'left')
->addAttributeToFilter('eol', array('No' => true));
This is what i'm trying to do at the moment, however, it doesn't work in the slightest. Both work individually fine!
Mage_Adminhtml_Block_Widget_Grid
has a method
_addColumnFilterToCollection($column)
You can override it to implement filtering logic for your custom grid.
For CE 1.6.2, this worked for me:
1) Copy over app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php to app/code/local/Mage/Adminhtml/Block/Catalog/Product/Grid.php
2) add the code below from app/code/local/Mage/Adminhtml/Block/Catalog/Product/Grid.php inside/under _prepareCollection()
AFTER ->addAttributeToSelect('type_id'); and before if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
CODE:
$collection->joinTable( 'cataloginventory/stock_item',
'product_id=entity_id', array("stock_status" => "is_in_stock") )
->addAttributeToSelect('stock_status');
3) Add the below around line 180 after
'index' => 'price', ));
CODE:
$this->addColumn('stock_status',
array(
'header'=> 'Stock Status', // this is the title of the column
'width' => '60px', // this is the width of the column
'index' => 'stock_status',
'type' => 'options',
'options' => array('1'=>'In Stock','0'=>'Out Of Stock'),
)
);