If you have written your own modules, and need to rearrange the order that your attributes or displayed in, or change anything else, you can use the following SQL statements to fix their order.
First you need to get the attribute group that the attributes are under. This can be done by running the following
[mysql]
SELECT attribute_group_id, attribute_group_name FROM eav_attribute_group
[/mysql]
This will give all of the different tabs for categories as well as the products. Find the group ID that you need and then run the following command to see all of the attributes associated with it
[mysql]
SELECT eea.*, ea.attribute_code FROM eav_entity_attribute AS eea JOIN eav_attribute AS ea ON eea.attribute_id = ea.attribute_id WHERE eea.attribute_group_id = 4
[/mysql]
Here we are using the group_id of 4 which gives the following result

The sort_order is the attribute that you need to change to move the attributes around the page. If the sort order is sequential then a simple trick to add some padding is to run the following command
[mysql]
UPDATE eav_entity_attribute SET sort_order = (sort_order*10) WHERE attribute_group_id = 4;
[/mysql]
Which will multiple each sort order by 10 allowing you to move the attributes around easier.
If you ever need to create a custom field to save data against a customer in Magento you will probably need to create a custom attribute.
Creating the attribute is easy, in your modules install script you do:
<?php
$installer = $this;
$installer->startSetup();
$installer->addAttribute('customer', 'my_custom_attribute', array('type'=>'text'));
$installer->endSetup();
Then on the customer object you can update and save it accordingly:
<?php
$customer = Mage::getModel('customer/customer')->load($customerId);
$customer->setMyCustomAttribute("Some custom data that needs to be saved")->save();
echo Mage::getModel('customer/customer')->load($customerId)->getMyCustomAttribute(); // Outputs 'Some custom data that needs to be saved'
To make your installer work you need to create a folder in the root of your module sql/mymodule_setup
In there create the file mysql4-install-0.1.0.php
And put the above installer code (plus any other install related code) in there.
You also need to add the following to your modules etc/config.xml file
<resources>
<mymodule_setup>
<setup>
<module>EdmondsCommerce_Mymodule</module>
<class>Mage_Sales_Model_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</mymodule_setup>
</resources>
If you are scratching your head trying to figure out why Magento Dataflow seems to be totally ignoring the values you are putting in some columns (for me it was qty_increments and enable_qty_increments) then this is your solution.
In a nutshell, Dataflow totally ignores some columns despite including them in the output file – quite a few actually.
I am planning to release an extension that generally tidies up the behaviour of Dataflow and also includes creation of Attribute Sets and Categories which has come up as a requirement for a client project. However this little nugget of fun has cost me a few hours so I thought I would share the solution straight away.
The columns that are updated by dataflow are controlled by the modules (in this case Mage_Catalog) config.xml file. If you want to enable extra columns you need to create a simple custom module to override that xml.
This is the contents of the config.xml
<?xml version="1.0"?>
<!--
/**
* EdmondsCommerce
* www.edmondscommerce.co.uk
* info@edmondscommerce.co.uk
* +44 (0)844 357 0201
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* It is available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
*
* @category EdmondsCommerce
* @package EdmondsCommerce_DataFlow
* @copyright Copyright (c) 2010 Edmonds Commerce (http://www.edmondscommerce.co.uk)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
-->
<config>
<modules>
<EdmondsCommerce_DataFlow>
<depends>
<Mage_Catalog />
<Mage_Dataflow />
</depends>
<version>0.1.0</version>
</EdmondsCommerce_DataFlow>
</modules>
<admin>
<fieldsets>
<catalog_product_dataflow>
<qty>
<inventory>1</inventory>
<to_number>1</to_number>
<product_type>
<simple />
<virtual />
</product_type>
</qty>
<min_qty>
<inventory>1</inventory>
<to_number>1</to_number>
<use_config>1</use_config>
<product_type>
<simple />
<virtual />
</product_type>
</min_qty>
<is_qty_decimal>
<inventory>1</inventory>
<product_type>
<simple />
<virtual />
</product_type>
</is_qty_decimal>
<backorders>
<inventory>1</inventory>
<use_config>1</use_config>
<product_type>
<simple />
<virtual />
</product_type>
</backorders>
<min_sale_qty>
<inventory>1</inventory>
<to_number>1</to_number>
<use_config>1</use_config>
<product_type>
<simple />
<virtual />
</product_type>
</min_sale_qty>
<max_sale_qty>
<inventory>1</inventory>
<to_number>1</to_number>
<use_config>1</use_config>
<product_type>
<simple />
<virtual />
</product_type>
</max_sale_qty>
<is_in_stock>
<inventory>1</inventory>
<inventory_other>1</inventory_other>
<product_type>
<simple />
<virtual />
<configurable />
<grouped />
</product_type>
</is_in_stock>
<notify_stock_qty>
<inventory>1</inventory>
<use_config>1</use_config>
<product_type>
<simple />
<virtual />
</product_type>
</notify_stock_qty>
<manage_stock>
<inventory>1</inventory>
<use_config>1</use_config>
<product_type>
<simple />
<virtual />
<configurable />
<grouped />
</product_type>
</manage_stock>
<!-- EdmondsCommerce added //-->
<enable_qty_increments>
<inventory>1</inventory>
<use_config>1</use_config>
<product_type>
<simple />
<virtual />
<configurable />
<grouped />
</product_type>
</enable_qty_increments>
<qty_increments>
<inventory>1</inventory>
<use_config>1</use_config>
<product_type>
<simple />
<virtual />
<configurable />
<grouped />
</product_type>
</qty_increments>
<!-- EdmondsCommerce ends //-->
<image><img>1</img></image>
<small_image><img>1</img></small_image>
<thumbnail><img>1</img></thumbnail>
<store><external>1</external></store>
<websites><external>1</external></websites>
<sku><external>1</external></sku>
<attribute_set><external>1</external><ignore>1</ignore></attribute_set>
<type><external>1</external><ignore>1</ignore></type>
<name><external>1</external><required>1</required></name>
<description><external>1</external><required>1</required></description>
<short_description><external>1</external><required>1</required></short_description>
<weight><external>1</external><required>1</required></weight>
<price><external>1</external><required>1</required></price>
<tax_class_id><required>1</required></tax_class_id>
<category_ids><system>1</system><ignore>1</ignore></category_ids>
<entity_id><system>1</system><internal>1</internal><ignore>1</ignore></entity_id>
<old_id><internal>1</internal></old_id>
<tier_price><internal>1</internal></tier_price>
<media_gallery><internal>1</internal></media_gallery>
<entity_type_id><system>1</system></entity_type_id>
<attribute_set_id><system>1</system><ignore>1</ignore></attribute_set_id>
<type_id><system>1</system><ignore>1</ignore></type_id>
<created_at><system>1</system></created_at>
<updated_at><system>1</system></updated_at>
<item_id><system>1</system></item_id>
<product_id><system>1</system></product_id>
<stock_id><system>1</system></stock_id>
<required_options><system>1</system><ignore>1</ignore></required_options>
</catalog_product_dataflow>
</fieldsets>
</admin>
</config>
If you look towards the middle you will see this bit:
<!-- EdmondsCommerce added //-->
<enable_qty_increments>
<inventory>1</inventory>
<use_config>1</use_config>
<product_type>
<simple />
<virtual />
<configurable />
<grouped />
</product_type>
</enable_qty_increments>
<qty_increments>
<inventory>1</inventory>
<use_config>1</use_config>
<product_type>
<simple />
<virtual />
<configurable />
<grouped />
</product_type>
</qty_increments>
<!-- EdmondsCommerce ends //-->
If there are any other columns you need to enable then you will need to do something similar.
One of the really cool and powerful features of Magento compared to other more traditional ecommerce platforms is the way that product information is handled. On a traditional system you will likely have one or a small number of tables to store product information. For each element of product information there is a column on these tables. This might be things like price, weight, model code etc etc.
But lets imagine that you sell T shirts. So you decide that you want to add a new column to your system to store the following bits of info:
size
material
male/female
Ok no problem, you add these columns to your table, modify your administration system and front end to display this extra info. Easy enough. You also decide to modify your search page so that people can search by T shirt size, material or mens/womens so your search is much easier to use.
However, lets say you find a new supplier for footwear. You want to add all these new products to your system but you also want to be able to store the extra information related to shoes, for example:
UK Size
European Size
Upper
Sole
Of course you can go ahead and add a bunch more columns to your table and store this info. However, now you have the issue that you need to edit your front end to only display the shoe related info for shoes and only the T shirt related info for T shirts. You can probably figure out a way to handle this, but I’m sure you can start to see the problem. This approach doesn’t scale well. Lets say instead of 2 main product types you have 200 or even 2000.
In the end what ends up happening is that you only store basic specific information about a product and then all the finer details go into the product description. Thats fine, but its not great. Also you have to lose your nice new search functionality.
Magento deals with this in an entirely different way. Instead of having the traditional spreadsheet like database table relationships (1 row for each product), Magento does things differently and stores 1 item of information per row (over simplified but enough to illustrate my point). This means that there is no limit to how many elements of information can be stored for each product.
Magento Groups these attributes (as it calls them) into attribute sets. An attribute set is simply enough a collection of attributes. There is a default attribute set which you would generally make a copy of and then customise for each kind of product you want to have custom attributes for. So continuing our T shirts and shoes example, you would make a new attribute set called T shirts, based on the Default set, and also one for shoes.
The T shirts attribute set will contain all the standard attributes (such as price, title etc) inherited from the default set, but we can also add in our custom attributes. Same goes for the shoes.
Then when we want to add a new product (lets say a T shirt) we select the T shirts attribute set so that we then have fields to enter information for our custom T shirt attributes.