On the webguys page is a german article about this problem: http://www.webguys.de/magento/turchen-23-pimp-my-produktgrid/
Nicht alle unsere Änderungen werden von Magento übernommen, zum Beispiel funktioniert die Sortierung und Filterung der neuen Attribute nicht.
Das liegt daran, dass unsere Änderungen nach dem Aufruf von _prepareCollection()
, in dem die Spalteninfos an die Collection übergeben werden, stattfinden.
Translation:
Not all changes are made by magento, e.g. sorting and filtering of the new attributes doesn't work.
That's because they are made after the _prepareCollection()
call, where the informations about the columns are passed to the collection.
protected function _callProtectedMethod($object, $methodName) {
$reflection = new ReflectionClass($object);
$method = $reflection->getMethod($methodName);
$method->setAccessible(true);
return $method->invoke($object);
}
protected function _modifyProductGrid(Mage_Adminhtml_Block_Catalog_Product_Grid $grid) {
$this->_addUpdatedAtColumn($grid);
$this->_addColorColumn($grid);
$this->_removeColumn($grid, 'set_name');
$this->_removeColumn($grid, 'visibility');
// reinitialisiert die Spaltensortierung
$grid->sortColumnsByOrder();
// reinitialisiert die Sortierung und Filter der Collection
$this->_callProtectedMethod($grid, '_prepareCollection');
}
More in the post. I think the source code is quite self explaining and if not, use google (if you don't understand german ;-))
You can do that via the menu Catalog > Attributes > Manage Attributes and creating an attribute with a Dropdown type.
After that, you can add it to the attribute set of your choice in Catalog > Attributes > Manage Attribute Sets. Select your Set, then drag your attribute in the right column, and drop it in the left one, under the group "Images". Your attribute should then display in "Manage Products".
If you want to add this attribute programmatically, you can do it with an installer, and a code like that :
<?php
$installer = $this;
$installer->startSetup();
// Group : General
$attributeSetDefault = 'Default';
$attributeGroup = 'Images';
$attributeSetId = $installer->getAttributeSetId('catalog_product', $attributeSetDefault);
if($attributeSetId){
$attributeGroupId = $installer->getAttributeGroupId('catalog_product', $attributeSetId, $attributeGroup);
}
// Attribute : attribute_code
$attributeCode = 'attribute_code';
$attribute = $installer->getAttribute('catalog_product', $attributeCode);
if (empty($attribute['attribute_id'])) {
$options = array();
$options['value']['option0'][0] = 'Option 0';
$options['value']['option1'][0] = 'Option 1';
$installer->addAttribute(
'catalog_product',
$attributeCode,
array(
'label' => 'Attribute',
'type' => 'varchar',
'backend' => 'eav/entity_attribute_backend_array',
'frontend' => '',
'input' => 'select',
'frontend_class' => '',
'source' => '',
'required' => false,
'user_defined' => true,
'default' => '',
'unique' => false,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'option' => $options,
)
);
$attributeId = $installer->getAttributeId('catalog_product', $attributeCode);
if($attributeGroupId && $attributeId){
$installer->addAttributeToGroup('catalog_product', $attributeSetId, $attributeGroupId, $attributeId);
}
}
$installer->endSetup();
Best Answer
The checkbox on each line in the grids is a way to mark if the product listed on that line is in relation with the product you are creating/editing (up-sell, cross-sell, related).
In general a grid in Magento has the following elements.
In the case of the relations tabs (and others) the dropdown with the values
Any
,Yes
,No
represents a way to filter the grid (because it's on the filter row of the grid).If you select
Any
it means that there is no filter on the grid for the column with checkboxes.If you select
Yes
and pressSearch
you will see in the grid only the rows that have the checkbox checked. (Of course the rest of the filters apply if you have any). If you selectNo
and pressSearch
you will see in the grid only the rows that have the checbox uncheched.It's somehow similar to this. The difference is that in this case there are checkboxes not radio buttons. [EDIT]
The purpose of the checkbox above the
Any/Yes/No
filter is to check/uncheck easier all visible checkboxes.