We have a custom attribute which is added to the default attribute group. Used in product listing is yes and it is added in the config.xml
to the product collection.
The values of the attribute are set using \Mage_Catalog_Model_Product_Action::updateAttributes
in a data upgrade script.
Anyways, the values are not displayed in the product listing. When the product is saved in the backend, it becomes visible.
Rebuilding all indices using indexer.php
or n98-magerun.phar
did not help.
EDIT
data upgrade script 1
$installer = $this;
$installer->startSetup();
$attrCodeDeliveryTimeFrom = 'delivery_time_from';
$attrCodeDeliveryTimeTo = 'delivery_time_to';
$attrGroupName = 'General';
$attrLabelDeliveryTimeFrom = 'Delivery time from (days)';
$attrLabelDeliveryTimeTo = 'Delivery time to (days)';
$attrNoteDeliveryTimeFrom = 'Days from';
$attrNoteDeliveryTimeTo = 'Days to';
$objCatalogEavSetup = Mage::getResourceModel('catalog/eav_mysql4_setup', 'core_setup');
$attrIdTest = $objCatalogEavSetup->getAttributeId(Mage_Catalog_Model_Product::ENTITY, $attrCodeDeliveryTimeFrom);
if ($attrIdTest === false) {
$objCatalogEavSetup->addAttribute(Mage_Catalog_Model_Product::ENTITY, $attrCodeDeliveryTimeFrom, array(
'group' => $attrGroupName,
'sort_order' => 50,
'type' => 'int',
'backend' => '',
'frontend' => '',
'label' => $attrLabelDeliveryTimeFrom,
'note' => $attrNoteDeliveryTimeFrom,
'class' => '',
'source' => '',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'visible_on_front' => true,
'unique' => false,
'is_configurable' => false,
'used_for_promo_rules' => true
));
}
$attrIdTest = $objCatalogEavSetup->getAttributeId(Mage_Catalog_Model_Product::ENTITY, $attrCodeDeliveryTimeTo);
if ($attrIdTest === false) {
$objCatalogEavSetup->addAttribute(Mage_Catalog_Model_Product::ENTITY, $attrCodeDeliveryTimeTo, array(
'group' => $attrGroupName,
'sort_order' => 51,
'type' => 'int',
'backend' => '',
'frontend' => '',
'label' => $attrLabelDeliveryTimeTo,
'note' => $attrNoteDeliveryTimeTo,
'class' => '',
'source' => '',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'visible_on_front' => true,
'unique' => false,
'is_configurable' => false,
'used_for_promo_rules' => true
));
}
$setup = Mage::getResourceModel('catalog/setup','catalog_setup');
$setup->removeAttribute('catalog_product','delivery_time');
date upgrade script 2
$installer = $this;
$installer->startSetup();
$_productCollection = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addStoreFilter(2);
$storeId = 0;
foreach ($_productCollection as $_product) {
$product = Mage::getModel('catalog/product')->load($_product->getEntityId());
$data = array(
'delivery_time_to' => 3,
'delivery_time_from' => 1
);
Mage::getSingleton('catalog/product_action')->updateAttributes(array($product->getId()), $data, $storeId);
}
$installer->endSetup();
We did the attribute creation in a data upgrade script. Maybe this is the problem.