Executing cron tasks manually in Magento

Share
Posted on January 29th, 2013 | Posted by admin

Usually I’ve been asked about how to run a cron task manually. A cron task defined in Magento is not anything else than a function that belongs to a model that is loaded and executed.

For example, we have this cron task on a config.xml file of a specific module:

1
2
3
4
5
6
7
8
<catgento_sap_sync_nonimages>
<schedule>
<cron_expr>*/15 * * * *</cron_expr>
</schedule>
<run>
<model>sap/cron_sync_nonimages::run</model>
</run>
</catgento_sap_sync_nonimages>

It’s easy to identify the model and function that is being loaded and executed as it is inside the <model> tags. The model that is being loaded is sap/cron_sync_nonimage, and the function inside that model that is being executed is run.

Log all SQL queries in Magento

Share
Posted on January 27th, 2013 | Posted by admin

Log all SQL queries in Magento

In Varien_Db_Adapter_Pdo_Mysql

Magento : lib/varien/Db/Adapter/Pdo/Mysql.php

set

protected $_debug               = true;
protected $_logAllQueries       = true;
 

and (if nor already there) create the folder defined in

how to show tier price in order view page

Share
Posted on January 25th, 2013 | Posted by admin

I have used the following code for showing tier price in order view page in Magento

$tier_prices = Mage::getModel(“catalog/product”)->load($_item->getProductId())->tier_price ;
if(!empty($tier_prices)) {
foreach($tier_prices as $tier_price){
if($tier_price['all_groups']==1){
print  “All – Groups “.number_format($tier_price['price']).” <br> ” ;
}else{
$group = Mage::getModel(“customer/group”)->load($tier_price['cust_group']) ;
echo $group->customer_group_code.” – “.number_format($tier_price['price']).” <br> ” ;
}
}
}

Static callout block for CMS page in magento

Share
Posted on January 22nd, 2013 | Posted by admin

Magento offers lots of flexibility for Magento theme design but it takes a bit of digging and exploring before one can learn to do a new simple trick.

In the Magento default template, it shows us how to place a permanent callout block in the left column by using the

<reference name="left">...</reference>

Example of the code is located in the catalog.xml, right in the <default> section.

MAGENTO BLOCK CACHING NOT WORKING – TRY USING MAGENTO PROTECTED CONSTRUCTOR

Share
Posted on January 21st, 2013 | Posted by admin

You have tried a lot to use Magento block caching, described in but still your block is not being cache. Here’s a solution do not use the public constructor to write your block cache data, just use the protected constructor to add the data. Then you will see your block will be cached.

In fact I think we should always used protected constructor to initialize anything on Magento. Am I right or what do folks has to say about this?

Page 1 of 41234»