0

How can i get the Attribute Text just on simple products? and hide on configurable? in Product View Magento.

Thanks

Dar
  • 159
  • 1
  • 4
  • 15

2 Answers2

2

This code should be on any place, and have to run just 1 time. After run this code you can remove it.

 $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,
        ));
Guerra
  • 2,792
  • 1
  • 22
  • 32
  • Thanks for this Solution, but i need to show the same attribute on configurables. So, this will not help me. Thanks – Dar Nov 16 '12 at 18:55
  • you've said you need only for simple product. – Guerra Nov 16 '12 at 19:11
  • You can change the code from 'apply_to' => 'simple', to 'apply_to' => array('simple','configured', 'grouped','virtual', 'bundle', 'downloadable') – Guerra Nov 16 '12 at 19:15
  • Yes you are right, this is a nice solution, and really work. Thanks – Dar Nov 16 '12 at 20:01
  • @Guerra The best place to out that code is actually a setup script. That way Magento will take care of running it once for you. Once you start using setup scripts in this way, keeping development, staging and production environments in sync becomes much easier. – Jim OHalloran Nov 18 '12 at 05:53
1

Why not just do an exception in view.phtml based on type id?

<?php if($_product->getTypeId() == "configurable"){ ?>
            <div class="product-view"> ... </div>

        <?php  } else { ?> 
            <div class="product-view"> ... </div>
        <?php  } ?>
Rounder
  • 350
  • 3
  • 14