3

我只是想知道,有没有办法将 Magento 内置的 country_of_manufacturer 的值(基本上是所有国家的列表)复制到一个新属性中?

我知道这是一个有趣的问题,而我们可以只使用内置属性。但我需要将该值用于另一个属性(即 country_region)。那么我该怎么做呢?

PS请不要投反对票,因为我搜索了很多但找不到答案。也不知道我还能怎么做。:/

4

2 回答 2

6

您要做的是配置您的新属性以使用catalog/product_attribute_source_countryofmanufacture源模型(请参阅Mage_Catalog_Model_Product_Attribute_Source_Countryofmanufacture::getAllOptions()[链接]。此模型从目录表中获取选项。

理想情况下,您将在模块的升级脚本中创建和配置此属性。您需要必要的配置来为您的模块运行升级脚本,然后您可以将其用作脚本的基础:

$installer = Mage::getResourceModel('catalog/setup','default_setup');
/* @var $installer Mage_Catalog_Model_Resource_Setup */

$installer->startSetup();

$installer->addAttribute(
    Mage_Catalog_Model_Product::ENTITY,
    'your_attr_code',
    array(
        'type'      => 'varchar',
        'input'  => 'select',
        'source'    => 'catalog/product_attribute_source_countryofmanufacture',
        // other settings as desired...
    )
);

$installer->endSetup();

您还可以在管理员中创建一个“下拉”属性,在eav_attribute表中找到它,然后编辑其source_model列以具有列出的源模型。对于适当的设置,请运行此 sql 语句...

SELECT * FROM eav_attribute WHERE attribute_code = 'country_of_manufacture';`

...或首先查看country_of_manufacture属性是如何创建的。

于 2012-10-18T12:31:44.243 回答
-1

您可以设置自己的扩展并在 中fieldsets声明config.xml以将值从一个表复制到另一个表。但在你的情况下,我真的不知道该怎么做。只需搜索“magento 字段集”...</p>

<config>
    <global>
        <fieldsets>
            <checkout_onepage_billing>
                <username><to_customer>*</to_customer></username>
            </checkout_onepage_billing>
        </fieldsets>
        <!-- … -->
    </global>
</config>
于 2012-10-18T09:27:36.687 回答