1

noob here. I have tried to add a few attributes to my custom product (customproduct) but they end up on all products as well.

I would like to get a Group/Tab (Custom Settings) of attributes to show just under the General Tab on my Custom Product (customproduct) only. Someone who can guide me the right way?

My code looks like this: (mysql4-install-0.1.0.php)

$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
$setup->addAttribute('catalog_product', 'PartnerID', array(
        'group'         => 'Custom Settings',
        'input'         => 'text',
        'type'          => 'text',
        'label'         => 'Partner ID',
        'backend'       => '',
        'visible'       => 1,
        'required'      => 0,
        'user_defined' => 1,
        'searchable' => 0,
        'filterable' => 0,
        'comparable'    => 0,
        'visible_on_front' => 0,
        'visible_in_advanced_search'  => 0,
        'is_html_allowed_on_front' => 0,
        'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
        'apply_to'      => 'customproduct',
    ));
3
  • Impossible, becouse product and custom product is the same thing and use same model. What its possible, is control on .phtml what will be show to product or custom product. Commented Aug 21, 2012 at 11:19
  • You should use product custom options instead. Commented Aug 21, 2012 at 12:04
  • Thanks for the comments, just discovered them today ;-) Could anyone guide me to a tutorial on custom options then? Commented Aug 27, 2012 at 8:02

1 Answer 1

2

To answer my own question, here is the answer: I needed to add the attributes to the following array and re-run the installscript. (Also, I had an error in my configuration of my new product type customproduct)

$fieldList = array(
            'PartnerId'
                        ...
    );

    // make these attributes applicable to customproduct
    foreach ($fieldList as $field) {
        $applyTo = split(',', $installer->getAttribute('catalog_product', $field, 'apply_to'));
        if (!in_array('customproduct', $applyTo)) {
            $applyTo[] = 'customproduct';
            $installer->updateAttribute('catalog_product', $field, 'apply_to', join(',', $applyTo));
        }
    }

Now the new attribute(s) are only available for customproduct.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.