3

I am creating a module to insert a new attribute and a new type of product in my store. As template, I use the same registration screen of the Virtual Product type and include new options ONLY this type of product. For this, in my config.xml, I used:

<catalog>
        <product>
            <type>
                <incomm_virtual translate="label" module="incomm">
                    <label>Incomm Virtual</label>
                    <model>incomm/product_type</model>
                    <price_model>incomm/product_price</price_model>
                    <is_qty>1</is_qty>
                    <composite>0</composite>
                    <can_use_qty_decimals>0</can_use_qty_decimals>
                </incomm_virtual>
            </type>
        </product>
    </catalog>

and to configure the installation with the sql in same config.xml:

    <resources>
        <abc_incommproduct_setup>
            <setup>
                <module>ABC_Incomm</module>
                <class>Mage_Catalog_Model_Resource_Setup</class>
            </setup>
        </abc_incommproduct_setup>
    </resources>

The next file was used mymodule / model / product / type.php containing:

class ABC_Incomm_Model_Product_Type
    extends Mage_Catalog_Model_Product_Type_Virtual
{
    const TYPE_INCOMM          = 'incomm';
    const XML_PATH_AUTHENTICATION = 'catalog/incomm/authentication';

    protected function _prepareProduct(Varien_Object $buyRequest, $product, $processMode)
    {
        if ($this->_isStrictProcessMode($processMode)) {
            return Mage::helper('ABC_Incomm_Helper_Data')->__(
                'Incomm product %s cannot be added to cart. ' .
                ' On the product detail page click the "Go to parent site"'.
                ' button to access the product.',
                $product->getName()
            );
        }
        return parent::_prepareProduct($buyRequest, $product, $processMode);
    }
}

In the same folder, the virtual.php:

class ABC_Incomm_Model_Product_Virtual extends Mage_Catalog_Model_Product_Type_Virtual {   
}

Finally, the SQL installation file in sql folder / abc_incommproduct_setup / mysql-install-4-0.1.0.php:

$this->startSetup();

$this->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'terms_of_use', array(
    'group'         => 'General',
    'input'         => 'textarea',
    'type'          => 'text',
    'sort_order' => 4,
    'label'         => 'Terms of use',
    'backend'       => '',
    'visible'       => true,
    'required'      => true,
    'wysiwyg_enabled' => true,
    'visible_on_front' => true,
    'apply_to'                => 'incomm', //only in this type of product
    'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));

$this->endSetup();

My problem is this, after disabling the cache in magento, clear the cache and include a new type of product, in the Product Types list appears my NEW type of product, but the options NOT load the new attribute inserted via SQL. Did sqlinstall.php not run?

  • Is there abc_incommproduct_setup in core_resource? If so, does it have the version you specified in config.xml? What happens if you remove that record from core_resource, clear the cache, clear the sessions and give it another go? – Henry's Cat May 14 '15 at 13:23
  • Did you update the config.xml file version in the module where the SQL upgrade file is located? – eetzen May 14 '15 at 17:16
  • is not core_resource because i have used a model in my folder /model , dont work ... and yes, my config.xml have same version of the sql upgrade, – Matheus Silva Itep May 14 '15 at 23:24
0

Try this:

$this->startSetup();

$this->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'terms_of_use', array(
    'group'            => 'General',
    'input'            => 'textarea',
    'type'             => 'text',
    'sort_order'       => 4,
    'label'            => 'Terms of use',
    'backend'          => '',
    'visible'          => true,
    'required'         => true,
    'wysiwyg_enabled'  => true,
    'visible_on_front' => true,
    'global'           => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));

$installer->updateAttribute(Mage_Catalog_Model_Product::ENTITY, 'terms_of_use', 'apply_to', 'incomm');

$this->endSetup();

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.