Some Code Samples In Magento

Share
Posted on March 30th, 2013 | Posted by admin

Some Code Samples In Magento

Get CMS Page ID
$pageId = Mage::getBlockSingleton(‘cms/page’)->getPage()->getIdentifier();

How to get product attributes?
<?php echo $_product->getResource()->getAttribute(‘attribute name’)->getFrontend()->getValue($_product) ?>

How to show breadcrumbs in magento?
<?php echo $this->getLayout()->getBlock(“breadcrumbs”)->toHtml(); ?>

How to show Static Blocks?

Magento Model Code Generation

Share
Posted on March 19th, 2013 | Posted by admin
Magento Model Code Generation

This is a quick one for advanced users, is a recent problem, I answered StackOverflow inspired. Magento as well as about an abstract system as one of the advantages is the opportunity it presents metaprogramming. Drops action in a controller (which is the following code, you can define an internal function in PHP)

Display HTML code (block) of product options in Magento

Share
Posted on January 7th, 2012 | Posted by admin

This simple helper will help you to display html code of your product options. It works with simple, virtual and configurable products. I believe you can use the same approach for other product types as well.

Getting HTML code for options of configurable products its little different from simple and virtual (well they are more or less same).

Update: for all types in configurable product.

With simple products we have a very “clean approach”.

First we are setting a block for product options, then we add item renderers (template and type) to product options block. And the last step is to take the product, create iteration over options and display it with our product options block.

We are seeing here some nice loose coupling. Nice separation of code.

How To Create An Admin Account From Magento Code

Share
Posted on May 23rd, 2011 | Posted by admin

Wondering how to restore your broken Magento admin access? If you have lost your magento admin credentials and you are stuck you should not loose heart. If accidentally you have deleted the admin access you can gain your access again with the help of slight magento code. In this article  i will tell you how you can create another temporary admin account and grant all necessary access to your new account.

Create User

Use a ftp program to edit: /app/code/core/Mage/Adminhtml/controllers/indexController.php

find the function loginAction and replace it by the following code (create a backup which you should restore later) :

Add Adwords tracking code to order confirmation page in Magento

Share
Posted on February 23rd, 2011 | Posted by admin

Add Adwords tracking code to order confirmation page in Magento

Adding an Adwords tracking code to order confirmation page in Magento is relatively easy task. One that can be handled under an hour or so if you choose to implement it the proper way. Here is how.

Modify the “app/design/frontend/default/my_custom_theme/layout/checkout.xml” file. Look for section

1.<checkout_onepage_success>
2.<reference name="root">
3.<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
4.</reference>
5.<reference name="content">
6.<block name="checkout.success" template="checkout/success.phtml" type="checkout/onepage_success" />
7.</reference>
Page 1 of 212»