Magento Themes and Magento Extensions

Programmatically Add Attribute to an Attribute Set in Magento

Posted on February 9th, 2015 | Posted by admin

Sometimes we need to create attribute and add it to an attribute set or to all attribute sets.In this article, we look how to add an attribute to ‘catalog_product’ entity for both these cases.


Here we instantiate Mage_Eav_Entity_Setup model

'label'=>'Test Attribute',


We just created a new attribute called ‘test_attribute’.

Refresh Magento Cache Programmatically

Posted on April 23rd, 2013 | Posted by admin

When writing processes to automate some of Magento’s normally laborious tasks, perhaps for a product-import script, a mass attribute update script, category import, or inventory adjustment, keep in mind that you may have to refresh some kind of cache — especially when working with attributes. If you are encountering quirks or inconsistencies with your data, try these:

  • Rebuild Catalog Index
  • Rebuild Flat Catalog Product
  • Inventory Stock

Magento: Change order status programmatically

Posted on April 7th, 2013 | Posted by admin

Change order status programmatically in Magento

Load an order using the following code

$order = Mage::getModel('sales/order')->load($orderId);

$incrementId = 1000002;
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);

magento set order status programmatically

Posted on March 9th, 2013 | Posted by admin

magento set order status programmatically

While working on a project this evening, I was tasked with setting the order status of all orders within September to Complete automatically, no notifications to the customer, and a comment was needed for exporting later.

Below is how it was accomplished. This was done on Magento Enterprise 1.12

File: /root/orderUpdates.php

Programmatically Setting a Magento Item’s Price When Adding It to Cart

Posted on February 3rd, 2013 | Posted by admin

Using code, how would we give a Magento item a one-time special price then add that item to the shopping cart?

The process is simple:

  • Create an instance of the Magento product,
    • give it a custom price by calling setSpecialPrice,
    • then save the product instance (store must be running as the admin store).
  • Next, grab the Magento cart object (a singleton),
    • add the product instance to the cart,
    • then save the cart.
Page 1 of 212»