0

I have a custom attribute for the product, Which is a Multi-select. I created this attribute with php script as shown below. The attribute's "Used in Product Listing" is set to true. But im unable to access this on front-end.

$installer = new Mage_Sales_Model_Mysql4_Setup;

    $attributeLabel = 'Choose Active Product Store';
    $attributeCode  = 'active_stores';
    $attributeGroup = 'General';
    $attributeOrder  = 100;

    $attributeOptions2 = array(
        'label'                      => $attributeLabel,
        'input'                      => 'multiselect',
        'type'                       => 'text',
        'backend'                    => 'eav/entity_attribute_backend_array',
        'frontend'                   => null,
        'source'                     => 'storeSwitcher/product_attribute_source_store',
        'global'                     => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
        'required'                   => false,
        'user_defined'               => false,
        'required'                   => true,
        'class'                      => null,
        'unique'                     => false,
        'searchable'                 => false,
        'filterable'                 => false,
        'comparable'                 => false,
        'visible_on_front'           => true,
        'is_configurable'            => false,
        'visible'                    => true,
        'default'                   => 'none',
    );

    $installer->updateAttribute(
        Mage_Catalog_Model_Product::ENTITY,
        $attributeCode,
        $attributeOptions2, $attributeCode
    );


    foreach ($attributeSets as $attributeSet) {
        $installer->addAttributeToSet(
            Mage_Catalog_Model_Product::ENTITY, $attributeSet,
            $attributeGroup, $attributeCode, $attributeOrder
        );
    }

i cannot filter the product collections based on this attribute. When i checked the catalog_product_flat_xx table i cannot find the column for this attribute!

Magento 1.9.2.4 CE

  • add used_in_product_listing=1 – Gopal Patel Feb 20 '17 at 7:45
  • I am Still waiting for an advice :( – Shan Mar 1 '17 at 5:35
0

Add

'used_in_product_listing' => 1

in

$attributeOptions2 = array(
        'label'                      => $attributeLabel,
        'input'                      => 'multiselect',
        'type'                       => 'text',
        'backend'                    => 'eav/entity_attribute_backend_array',
        'frontend'                   => null,
        'source'                     => 'storeSwitcher/product_attribute_source_store',
        'global'                     => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
        'required'                   => false,
        'user_defined'               => false,
        'required'                   => true,
        'class'                      => null,
        'unique'                     => false,
        'searchable'                 => false,
        'filterable'                 => false,
        'comparable'                 => false,
        'visible_on_front'           => true,
        'is_configurable'            => false,
        'visible'                    => true,
        'default'                   => 'none',
    );
  • added 'used_in_product_listing' => 1. But still the same problem – Shan Feb 20 '17 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.