Following post includes the code that can be used to create a configurable product in Magento.
Brief introduction about configurable product
When adding new products to your Magento store you have the option to select the type of the product. The most basic option is simple product.
That’s just a single item with no specific attributes/options that can be changed by the buyer.
With the configurable product type you can offer an item with some options that can be configured by the customers themselves.
For example, you can sell the same model of shoes that are offered in different colors, sizes, etc. Instead of creating several simple
products for each size of the same shoe model that will be displayed individually on the frontend,
for instance, you can create a configurable product which will allow the customer to select the size before ordering the product.
To understand the code, one must have a basic understanding of how configurable product works in a Magento store.
Magento provides Index Management to reindex content such as Product Attributes, catalog URL Rewrites, Catalog Search Index etc from admin panel.
But sometimes we are unable to access the backend and the need for reindexing arises or Reindexing error comes when trying from backend.
Create a file in root of your magento with following code to update the indexes programmatically.
//Following 3 lines will load the magento admin environment.
$app = Mage::app('admin');
// to reindex the processes we require their ids
// for default magento there are 9 processes to reindex, numbered 1 to 9.
$ids = array(1,2,3,4,5,6,7,8,9);
// Sometimes there are processes from our custom modules that also require reindexing
// We need to add those ids to our existing array of ids
// To know the id of process, just hover on each process in your
// admin panel-> System-> Index Management
// You will get a url : admin/process/some_id/......
// this id corresponds to the process
$ids = array(1,2,3,4,5,6,7,8,9,390,391,478);
foreach($ids as $id)
//load each process through its id
$process = Mage::getModel('index/process')->load($id);
echo "Indexing for Process ID # ".$id." Done<br />";
Thats all, the above code will reindex your magento content.
Or. . .
you can do it directly from command line :
– Index all indexers
php -f shell/indexer.php –reindex all
Note : your current directory should be magento root.
-Below are give two small scripts, one is HTML and other is PHP.
-Paste below piece of code in a “input.html” file
<form action=”download.php” method=”post”>
<h2>Enter File Name </h2>
<input type=”text” name=”filename” size=”150″>
<input type=”submit” value=”submit”>