获取简单产品的属性文本,并在产品视图magento中隐藏可配置的属性文本
如何仅在简单产品上获取属性文本?然后躲在桌子上?在产品视图Magento中获取简单产品的属性文本,并在产品视图magento中隐藏可配置的属性文本,magento,configurable,Magento,Configurable,如何仅在简单产品上获取属性文本?然后躲在桌子上?在产品视图Magento中 谢谢这段代码应该放在任何地方,并且只需运行一次。运行此代码后,可以将其删除 $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $setup->addAttribute('catalog_product', 'attributename', array( 'group' => 'Ge
谢谢这段代码应该放在任何地方,并且只需运行一次。运行此代码后,可以将其删除
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('catalog_product', 'attributename', array(
'group' => 'Geral',
'label' => 'Backend label',
'note' => '',
'type' => 'int', //backend_type
'input' => 'text', //frontend_input
'frontend_class' => '',
'source' => 'sourcetype/attribute_source_type',
'backend' => '',
'frontend' => '',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE,
'required' => true,
'visible_on_front' => false,
'apply_to' => 'simple',
'is_configurable' => false,
'used_in_product_listing' => false,
'sort_order' => 5,
));
此代码应该位于任何位置,并且只需运行1次。运行此代码后,可以将其删除
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('catalog_product', 'attributename', array(
'group' => 'Geral',
'label' => 'Backend label',
'note' => '',
'type' => 'int', //backend_type
'input' => 'text', //frontend_input
'frontend_class' => '',
'source' => 'sourcetype/attribute_source_type',
'backend' => '',
'frontend' => '',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE,
'required' => true,
'visible_on_front' => false,
'apply_to' => 'simple',
'is_configurable' => false,
'used_in_product_listing' => false,
'sort_order' => 5,
));
为什么不根据类型id在view.phtml中执行异常呢
<?php if($_product->getTypeId() == "configurable"){ ?>
<div class="product-view"> ... </div>
<?php } else { ?>
<div class="product-view"> ... </div>
<?php } ?>
...
...
为什么不根据类型id在view.phtml中执行异常
<?php if($_product->getTypeId() == "configurable"){ ?>
<div class="product-view"> ... </div>
<?php } else { ?>
<div class="product-view"> ... </div>
<?php } ?>
...
...
感谢您提供此解决方案,但我需要在可配置文件上显示相同的属性。所以,这对我没有帮助。谢谢你说过你只需要简单的产品。你可以将代码从“apply_改为“=>”simple”,改为“apply_改为“=>array”(“simple”)、“configured”、“grouped”、“virtual”、“bundle”、“downloadable”)。是的,这是一个很好的解决方案,非常有效。Thanks@Guerra最好的方法是编写一个安装脚本。这样,Magento将为您管理一次。一旦开始以这种方式使用安装脚本,保持开发、登台和生产环境的同步就变得容易多了。感谢此解决方案,但我需要在可配置文件上显示相同的属性。所以,这对我没有帮助。谢谢你说过你只需要简单的产品。你可以将代码从“apply_改为“=>”simple”,改为“apply_改为“=>array”(“simple”)、“configured”、“grouped”、“virtual”、“bundle”、“downloadable”)。是的,这是一个很好的解决方案,非常有效。Thanks@Guerra最好的方法是编写一个安装脚本。这样,Magento将为您管理一次。一旦开始以这种方式使用安装脚本,保持开发、登台和生产环境的同步就变得容易多了。谢谢,我应用了此解决方案。谢谢,我应用了此解决方案。