Product PDF price-list extension Magento

It’s not a valid Magento extension , you can use Magento Connect install and uninstall it.

I’m not very good at MVC and Zend Framework and the Magento DOC is a horrible thing to read and understand it.
I need this function and I can’t find some good extension and do this job. So I use some trick tip to solve this problem.

I use FPDF Class to create PDF file.It’s easy and safe.
Full Demo:http://www.adelaidecartridge.com/pricelist.php
Code:
Cartridge Demo:http://www.adelaidecartridge.com/cartridgepricelist.php
Print Demo:http://www.adelaidecartridge.com/printerpricelist.php

// Define path to Magento
define ( "MAGE_BASE_DIR", '/var/www/vhosts/adelaidecartridge.com/httpdocs/' );
 
// Kick-start the Magento stack
require_once MAGE_BASE_DIR . '/app/Mage.php';
Mage::app ();
 
$collection = Mage::getModel ( 'catalog/product' )->getCollection ()->setOrder ( 'manufacturer', 'asc' )->setOrder ( 'oemcode', 'asc' )->setOrder ( 'price', 'desc' );
$collection->addAttributeToSelect ( '*' );
 
define ( 'FPDF_FONTPATH', MAGE_BASE_DIR . 'font/' );
require ('fpdf.php');
 
class PDF extends FPDF {
 
	//Page header
	function Header() {
 
		global $title;
		//Logo
		$this->Image ( MAGE_BASE_DIR . '/skin/frontend/default/hellopress/images/logo.gif', 10, 10, 20 );
		//Arial bold 15
		$this->SetFont ( 'Arial', 'B', 15 );
		//Move to the right
		$this->Cell ( 80 );
		//Title
		$this->Cell ( 30, 8, $title, 0, 0, 'C' );
		//Line break
		$this->Ln ( 11 );
		$header = array ('SKU', 'Cartridge Name', 'OEM Code', 'Price' );
		//Column widths
		$w = array (25, 125, 25, 15);
		//Colors, line width and bold font
		$this->SetFillColor ( 255, 0, 0 );
		$this->SetTextColor ( 255 );
		$this->SetDrawColor ( 128, 0, 0 );
		$this->SetLineWidth ( .3 );
		$this->SetFont ( 'Arial', 'B', 10 );
		//Header
		for($i = 0; $i < count ( $header ); $i ++) 			$this->Cell ( $w [$i], 6, $header [$i], 1, 0, 'C', true );
		$this->Ln ();
	}
 
	//Page footer
	function Footer() {
 
		//Position at 1.5 cm from bottom
		$this->SetY ( - 10 );
		//Arial italic 8
		$this->SetFont ( 'Arial', 'I', 8 );
		//Page number
		$this->Cell ( 70, 10, 'Page ' . $this->PageNo () . '/{nb}', 0, 'L' );
		$this->Cell ( 30, 10, 'Last update:'.date('d-m-Y').' by james@AdelaideCartridge.Com', 0, 'C' );
		$this->Cell ( 0, 10, 'Ph: 08-82989260 ', 0, 0, 'R' );
	}
 
	//Load data
	function LoadData($file) {
 
		//Read file lines
		$lines = file ( $file );
		$data = array ();
		foreach ( $lines as $line )
			$data [] = explode ( ';', chop ( $line ) );
		return $data;
	}
 
	// My Table
	function AccTable($data) {
 
		//Column widths
		$w = array (25, 125, 25, 15 );
 
		//Color and font restoration
		$this->SetFillColor ( 224, 235, 255 );
		$this->SetTextColor ( 0 );
		$this->SetFont ( 'Times', '', 9 );
		//Data

3 responses to “Product PDF price-list extension Magento”

  1. amine

    Many thanks for sharing these information .. Very helpfull !!!! :)

  2. Patrick Hooper

    Are you able to provide the full source to have a look at?

    I am thinking about doing the same thing.

    If I make some enhancements I will pass back the updates.

    I want to add in thumbnails and have a category structure as well.

Leave a Reply