4

I added new attribute

src/app/code/local/PACK/MODUL/sql/pack_modul_setup/mysql4-upgrade-2.1.6-2.1.7.php :

<?php

$installer = $this;
$installer->startSetup();

$installer->addAttribute('catalog_product', 'passhub_contract', array(
    'group'             => 'Pass',
    'sort_order'        => 50,
    'type'              => 'string',
    'frontend'          => '',
    'label'             => 'PassHub Contract Holder',
    'input'             => 'text',
    'input_renderer'    => '',
    'class'             => '',
    'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
    'frontend_model'    => '',
    'visible'           => true,
    'required'          => false,
    'user_defined'      => true,
    'default'           => '',
    'searchable'        => false,
    'filterable'        => false,
    'comparable'        => false,
    'option'            => array(),
    'frontend_class'    => 'validate-number',
    'visible_on_front'  => false,
    'unique'            => false,
    'apply_to'          => Mage_Catalog_Model_Product_Type::TYPE_VIRTUAL,
));

$installer->addAttribute('catalog_product', 'passhub_contract_id', array(
    'group'             => 'Pass',
    'sort_order'        => 50,
    'type'              => 'int',
    'frontend'          => '',
    'label'             => 'PassHub Contract Holder ID',
    'input'             => 'text',
    'input_renderer'    => '',
    'class'             => '',
    'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
    'frontend_model'    => '',
    'visible'           => true,
    'required'          => false,
    'user_defined'      => true,
    'default'           => '',
    'searchable'        => false,
    'filterable'        => false,
    'comparable'        => false,
    'option'            => array(),
    'frontend_class'    => 'validate-number',
    'visible_on_front'  => false,
    'unique'            => false,
    'apply_to'          => Mage_Catalog_Model_Product_Type::TYPE_VIRTUAL,
));

$installer->endSetup();

At the admin panel it's ok. But if I try

$product = Mage::getModel('catalog/product')->load('product_id');

I haven't it. Where is my mistake? $product->getAttributeText('passhub_contract'); also doesn't work.

2

Try to use this code :

$_product = Mage::getModel('catalog/product')->load($product->getId());
$strPasshubContract = $_product->getPasshubContract();

or

$_product = Mage::getModel('catalog/product')->load($product->getId());
$strPasshubContract = $_product->getData('passhub_contract');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.