Archive for the ‘General’ Category

To generate pdf from html using tcpdf, follow the below steps:

Step1: Download tcpdf library from below link

Step2: Add tcpdf folder in your project at path :: Your_project/lib/tcpdf

Step3: Create html file at any place you wants.. Than create one function in model file.. to generate pdf like below:

public function generatePdf($couponIds)
$filename = " HERE PATH OF HTML FILE WILL COME" ; //EG: Mage::getBaseDir().'/app/locale/en_US/template/email/coupon.html' this will return file coupon.html
$logoImage = Mage::getBaseDir().'/skin/frontend/default/default/images/logo_pdf.jpg'; //logo image path
$ptemplate = file_get_contents($filename);
$couponFindReplace = array(
'##LOGO_IMAGE##' =>$logoImage ,
'##FOOTER_TEXT_IMAGE##' =>$footertextImage
//Above array is to change content dynamically.
$after_replace = strtr($ptemplate, $couponFindReplace);
$pdf_html = $after_replace;
// create new PDF document

// set document information
$pdf->SetTitle('PDF Title');
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
//set margins
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
//set image scale factor
$lg = Array();
$lg['a_meta_charset'] = 'UTF-8';
$lg['a_meta_dir'] = 'ltr';
$lg['a_meta_language'] = 'en';
$lg['w_page'] = 'page';
$pdf->SetFont('times','',20); //set font of pdf and default font size is 20
//set some language-dependent strings

// add a page
$pdf->writeHTML($coupon_pdf_html, true, 0, true, true);
//$pdf->Output('test.pdf','D'); //this will create pdf and download at a time..
/*START:: To create pdf at particular location in server*/
$file_name = 'test.pdf';
$file_name_path = Mage::getBaseDir().'/media/coupons/'.'test.pdf';
@chmod($file_name_path, 0777);
/*END:: To create pdf at particular location in server*/
return $file_name;

above function will generate pdf

The above are the steps to create simple pdf..

If the above code is helpful to you than do reply….

Bijal Bhavsar 🙂


2010 in review

Posted: January 3, 2011 in General

The stats helper monkeys at mulled over how this blog did in 2010, and here’s a high level summary of its overall blog health:

Healthy blog!

The Blog-Health-o-Meter™ reads Fresher than ever.

Crunchy numbers

Featured image

A helper monkey made this abstract painting, inspired by your stats.

A Boeing 747-400 passenger jet can hold 416 passengers. This blog was viewed about 6,800 times in 2010. That’s about 16 full 747s.

In 2010, there were 31 new posts, growing the total archive of this blog to 69 posts. There were 2 pictures uploaded, taking up a total of 16kb.

The busiest day of the year was July 20th with 96 views. The most popular post that day was Products not showing in category view in magento

Where did they come from?

The top referring sites in 2010 were,,,, and

Some visitors came searching, mostly for magento getsession, how to set session in magento, magento get session, magento jointable, and magento-community/riconeitzel_vertnav.

Attractions in 2010

These are the posts and pages that got the most views in 2010.


Products not showing in category view in magento June 2010


How to write simple Query in magento ? April 2010
1 Like on,


How to set session and get session in magento September 2009


Magento : Get Current Category – Category Id June 2010
1 comment


Fatal error: Call to a member function toOptionArray() on a non-object October 2010

if UPS shipping method for XML is not working then try this

open file :: appcodecoreMageUsaModelShippingCarrierUps.php
on line number 639
code is :: if (in_array($code, $allowedMethods)) {

if you remove this condition the UPS will work for your site.
here it shows every methods provided by UPS….

–Bijal Bhavsar 🙂

$_parent_category = Mage::app()->getStore()->getRootCategoryId();
$storeId = Mage::app()->getStore()->getStoreId();

$_productCollection = Mage::getResourceModel(‘catalog/product_collection’)
->setOrder(‘created_at’, ‘desc limit 1’)

$storeId = Mage::app()->getStore()->getId();

$products = Mage::getResourceModel(‘reports/product_collection’)
->setOrder(‘ordered_qty’, ‘desc’)
->load(); //best sellers on top

Removing CRELoaded footer advertising

Posted: November 6, 2009 in General

On CRE loaded shopping carts, you will find advertising coming directly from CRE If you wish to remove this advertising text, you need to edit the includes/application_bottom.php file. Look for this line and remove it: