Magento Fixed – Description not showing, Change on your old template to work with 1.4.1.1

After the new updates to magento, if your template description field suddenly disappear from the frontend, don’t panic. It’s just a simple line of code change will fix this problem. Open catalog.xml and view.phtml, and you will need to make the following change.

This is the code that magento had changed.
Old line of code, this code can be find under this location,
app/design/frontend/default/YOURTHEME/template/catalog/product/view.phtml or
app/design/frontend/base/default/template/catalog/product/view.phtml

<?php echo $this->getChildHtml('description') ?>

New implementation from magento core for 1.4.1.1

<?php foreach ($this->getChildGroup('detailed_info', 'getChildHtml') as $alias => $html):?>
    <div class="box-collateral <?php echo "box-{$alias}"?>">
        <?php if ($title = $this->getChildData($alias, 'title')):?>
        <h2><?php echo $this->escapeHtml($title); ?></h2>
        <?php endif;?>
        <?php echo $html; ?>
    </div>
<?php endforeach;?>

So next you will need to look for the following code in your template file.
Continue Reading »

Shortening Increment ID length for Orders, Invoices, Creditmemo and Shipments

By default, Magento use 8 digits for Orders, Invoices, Creditmemo and Shipments’ increment ID. However, sometime you would like to change the length to meet 3rd party’s system requirement. This can be easily accomplished by:

  • modify the field “increment_pad_length” in the “eav_entity_type” table for whatever entity you’re wanting to modify.
  • modify the field “increment_last_id” in “eav_entity_store” table with the same “entity_type_id” in table “eav_entity_type” which the document type’s increment ID you would like to change. Remember to change all existing records for this “entity_type_id”.

After you changed them, the coming new document will use the new increment ID.

Happy Magento’ing ~

How to get attribute option label in Magento with different store view

In Magento customization, sometimes you may want to get the value of attribute’s option. In below example I will show you how to do it.

Assuming that there is an attribute named “dropdown_field” and contains 4 options label: “Option 1″, “Option 2″, “Option 3″, “Option 4″. The codes below get the option label which is set in product:

// get product Model
$_product = Mage::getModel('catalog/product');

// get the attribute object
$dropdownAttributeObj = $_product->getResource()->getAttribute("dropdown_field");

// if input type for this attribute is dropdown or multi-select
if ($dropdownAttributeObj->usesSource()) {
      // get the option label
      $dropdown_option_label = $dropdownAttributeObj->getSource()->getOptionText($_product->getData('dropdown_field'));
}

How about multiple websites / store / store view? No worry, it’s automatically get the correct label for you; or you can use $this->__() translation method in your template files.

Happy Magento’ing ~

Flash loading external video link in loops for AS2

Today a client would like to create a flash banner that load external flv file and keep the video in loop. Never ending playback. This is a more or less a beginner scripts for flash. There’s much we can do for this, if anyone is more interested on this kinda topics drop me a reply I will write more about this topic.
Continue Reading »

Delete all orders, reset bestseller and most viewed products in Magento

In your Magento development period, you may create many order to test the checkout process. Before the website launch, you should find that there is no “delete” action for orders. What? Is it crazy?

Unfortunately, it’s really crazy (maybe) that you cannot delete order in Magento by default. Like me, there are over hundred orders leave in backend which make our sales confused. In this case, you can execute following SQL statements to delete the ALL orders in MySQL database:

TRUNCATE TABLE {prefix}sales_flat_order;
TRUNCATE TABLE {prefix}sales_order_tax;
TRUNCATE TABLE {prefix}downloadable_link_purchased;
DELETE FROM {prefix}eav_entity_store WHERE entity_type_id IN (SELECT entity_type_id FROM {prefix}eav_entity_type WHERE entity_type_code IN ('order', 'invoice', 'creditmemo', 'shipment'));

Then go to backend, then Reports > Refresh Statistics, select all items and run Refresh Lifetime Statistics.

But wait, most viewed products and bestseller haven’t reset yet. How?

Fine, here is the SQL statement to reset the most viewed products report:

DELETE FROM {prefix}report_event WHERE event_type_id IN (SELECT event_type_id FROM {prefix}report_event_types WHERE event_name IN ('catalog_product_view'));

If you need to delete other reports, you can add the following types to the previous SQL construction in last WHERE statement: ‘sendfriend_product’, ‘catalog_product_compare_add_product’, ‘checkout_cart_add_product’, ‘wishlist_add_product’, ‘wishlist_share’. These types are easily to find in {prefix}report_event_types table.

To truncate Bestsellers you will need to truncate the table ‘sales_bestsellers_aggregated_daily’, ‘sales_bestsellers_aggregated_monthly’ and ‘sales_bestsellers_aggregated_yearly’. Here are the SQL statements to truncate them:

TRUNCATE TABLE {prefix}sales_bestsellers_aggregated_daily;
TRUNCATE TABLE {prefix}sales_bestsellers_aggregated_monthly;
TRUNCATE TABLE {prefix}sales_bestsellers_aggregated_yearly;

That is. It’s not easy job and you may have to get some basic SQL / MySQL knowledge. Of course, using phpMyAdmin is the better way.

Thanks for Magento Support for this help.

Happy Magento’ing ~