Вопрос

I have created custom product multiselect attribute successfully.

But when i edit the product in admin and selecting some options(countries) of my multiselect attribute and if i click save its saved successfully.

but when i open same product again its not showing before selected options.that means its not saving my custom product attribute to product model.

can you Please help anyone.I'm very tired.and i tried lot of hours.then i'm placing here.

etc/config.xml file

<config>
    <modules>
        <Exinent_Shiplimit>
            <version>0.1.0</version>
        </Exinent_Shiplimit>
    </modules>

    <global>
    <models>
       <checkout>
         <rewrite>
           <type_onepage>Exinent_Shiplimit_Model_Checkout_Type_Onepage</type_onepage>
         </rewrite>
        </checkout>
      </models>
    <resources>
            <exinent_shiplimit_setup>
                <setup>
                    <module>Exinent_Shiplimit</module>
                    <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
                </setup>
            </exinent_shiplimit_setup>
        </resources>
    </global>
    </config>

app\code\local\Exinent\Shiplimit\sql\exinent_shiplimit_setup\mysql4-install-0.1.0.php

<?php 
$installer = $this;
/* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */

$installer->startSetup();
$installer->addAttribute(
    'catalog_product',
    'custom_countries', 
    array(
        'group'             => 'General',
        'type'              => 'varchar',
        'backend'           => '',
        'user_defined' => '1',
        'frontend'          => '',
        'label'             => 'Shipping Restricted Countries',
        'input'             => 'multiselect',
        'source'            => 'Mage_Catalog_Model_Product_Attribute_Source_Countryofmanufacture',
        'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE

    )
);

$installer->updateAttribute('catalog_product', 'custom_countries', 'backend_model', '');
$installer->endSetup();
?>
Это было полезно?

Решение

You're setting the backend_model to '' it should be 'eav/entity_attribute_backend_array'

And you'll want to define the type as text not varchar, since varchar will have lower limit than what is required of the source model.

Take a look around the eav_attribute table for reference.

Hope this helps.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с magento.stackexchange
scroll top