我有一个关于Magento属性的问题。我创建了一个自定义产品输入文本属性,用于保存整数数据类型,但是Magento将其存储为varchar。我在stackoverflow上询问了此问题,他们告诉我没有办法将产品属性类型从字符串更改为整数。
所以我的解决方案是创建一个自定义整数产品属性。我在Google上搜索了几天,找到了一篇文章,其中提供了一个可以创建自定义属性的脚本http://magentotutorialbeginners.blogspot.com/2014/03/create-product-attribute.html?showComment=1442885130592#c2319234413343201281。
问题是我不知道如何运行或使用它。
问题:
这个脚本怎么运行?您能给我一个逐步指南吗?
所以我的解决方案是创建一个自定义整数产品属性。我在Google上搜索了几天,找到了一篇文章,其中提供了一个可以创建自定义属性的脚本http://magentotutorialbeginners.blogspot.com/2014/03/create-product-attribute.html?showComment=1442885130592#c2319234413343201281。
问题是我不知道如何运行或使用它。
问题:
这个脚本怎么运行?您能给我一个逐步指南吗?
$installer = $this;
$installer->startSetup();
$installer->addAttribute('catalog_product', 'custom_mprice', array(
'input' => 'text',
'type' => 'int',
'label' => 'Enter Max Price',
'backend' => '',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'searchable' => 0,
'filterable' => 0,
'sort_order' => 30,
'comparable' => 0,
'visible_on_front' => 0,
'visible_in_advanced_search' => 0,
'is_html_allowed_on_front' => 0,
'is_configurable' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, ));
$installer->endSetup();
我的目标是创建这个属性,以便我可以在算术表达式中使用它,如小于或等于。
谢谢。
Zend_Db_Expr
是一个特殊的类,用于特定地准备 SQL 表达式。请记住,它将为您提供一个有效的字符串作为输出结果。因此$expr
变量保存一个字符串类型的 SQL 表达式。该表达式被定义为将$metric
变量视为整数。$metric
不是从数据库获取的,而是一个 PHP 变量,应在加载集合之前进行定义,尤其是$metric
代表数据字段。 - Rajeev K Tomye
.*,at_product_classification
.value
ASproduct_classification
FROMcatalog_product_entity
ASe
INNER JOINcatalog_product_entity_int
ASat_product_classification
ON (at_product_classification
.entity_id
=e
.entity_id
) AND (at_product_classification
.attribute_id
= '136') AND (at_product_classification
.store_id
= 0) WHERE (at_product_classification.value = '7') AND (CAST (max_ft_lbs AS UNSIGNED) >= 1500) AND (CAST (max_ft_lbs AS UNSIGNED) <= 2000) - rodge(CAST (max_ft_lbs AS UNSIGNED) >= 1500) AND (CAST (max_ft_lbs AS UNSIGNED) <= 2000)
添加的条件。在我看来,它看起来很好。阴谋围绕着max_ft_lbs
字段展开,你需要找出原因。 - Rajeev K Tomy