Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8189229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:12:27+00:00 2026-06-07T03:12:27+00:00

I made my module in Magento, but it needs additional attribute assigned to all

  • 0

I made my module in Magento, but it needs additional attribute assigned to all products. I made installation script, but it doesn’t work:

<?php

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

$installer->run("
    INSERT IGNORE INTO `{$installer->getTable('eav/attribute')}` (`attribute_id`, `entity_type_id`, `attribute_code`, `attribute_model`, `backend_model`, `backend_type`, `backend_table`, `frontend_model`, `frontend_input`, `frontend_label`, `frontend_class`, `source_model`, `is_required`, `is_user_defined`, `default_value`, `is_unique`, `note`) VALUES
    SELECT 1 + coalesce((SELECT max(attribute_id) FROM `{$installer->getTable('eav/attribute')}`),0),4,`is_accepted`,NULL,NULL,`int`,NULL,NULL,`boolean`,`Accepted`,NULL,`eav/entity_attribute_source_boolean`,1,1,'0',0,NULL);
");

$installer->endSetup();

Config.xml file:

<adminhtml>
<acl>
    <module_setup>
                    <setup>
                        <module>My_module</module>
                    </setup>
                    <connection>
                        <use>core_setup</use>
                    </connection>
                </module_setup>

                <module_write>
                    <connection>
                        <use>core_write</use>
                    </connection>
                </module_write>

                <module_read>
                    <connection>
                        <use>core_read</use>
                    </connection>
                </module_read>
            </resources>
        </acl>
</adminhtml>

What is wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:12:29+00:00Added an answer on June 7, 2026 at 3:12 am

    First, this is not a valid config.xml. The setup class is configured as follows:

    <config>
        ...
        <global>
            ...
            <resources>
                ...
                <your_module_setup>
                    <setup>
                        <module>Your_Module</module>
                        <class>Mage_Eav_Model_Entity_Setup</class>
                    </setup>
                </your_module_setup>
                ...
            </resources>
            ...
        </global>
        ...
    </config>
    

    instead of Mage_Eav_Model_Entity_Setup you could also use your own setup class but it should inherit Mage_Eav_Model_Entity_Setup, so you can use addAttribute instead of forging the SQL queries by hand.

    Then your setup script should look similar to this:

    $installer = $this;
    $installer->startSetup();
    /*
     * adds product unit attribute to product
     */
    $installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'productunit_id', array(
        'label' => Mage::helper('productunits')->__('Quantity Unit'),
        'type' => 'int',
        'input' => 'select',
        'source' => SGH_ProductUnits_Model_Entity_Attribute_Source_Units::MODEL,
        'backend' => SGH_ProductUnits_Model_Entity_Attribute_Backend_Units::MODEL,
        'required' => 1,
        'global' => 1,
        'note' => Mage::helper('productunits')->__('This will be displayed next to any Qty value.')
    ));
    $installer->endSetup();
    

    It’s my code that adds a quantity unit attribute, don’t be confused by the use of class constants, those are just the corresponding class aliases.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i made a magento module to handle my bank vpc system, all good until
I have made my custom module in magento, in which I have set discount
I have a custom module I made for Magento. From the admin, there is
I have a custom module I made to show featured products on the homepage.
i have made a module using hook function . its working but when i
I have created a module that works on a vanilla installation of Drupal but
I have made Magento controller that redirects to url, but for some reason url
I have a PHP web application where I've made a little module system, that
I have extended Magento’s customer information form to store an additional attribute for customer.
I have made a module which is transmitting but I don't know whether the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.