RSS

Monthly Archives: May 2012

CONCAT in query , Virtual Fields and make a drop down

I need to make a dropdown list of Locations. In dorpdown i need to put location name and location state name. I already have a column in database name which contain location name and location state name. Here is the steps to do so:

In Location Model(in which database table locations are saved) write the following code

1 var $virtualFields = array('dropdown_name' => 'CONCAT(Location.location_name, " ", Location.location_state)');
In Controller in which you want to show dropdown write this(eg: ShowsController):
2 $this->loadModel('Location');
$loc_list = $this->Location->find("list", array("fields" => array("location_id", 'location_name')));
$this->set('loc_list',$loc_list);
In view template(eg. View/Shows/add.php) add the following
2 $this->loadModel('Location');
$loc_list = $this->Location->find("list", array("fields" => array("location_id", 'location_name')));
$this->set('loc_list',$loc_list);
Advertisements
 
Leave a comment

Posted by on May 14, 2012 in Cake PHP, PHP

 

Tags: , , , ,

Add custom attribute to Magento invoice PDF

Look in the file app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php. That contains the part necessary for product output. Copy the file to a matching directory path but in app/code/local, this is a safe way to override and make edits. You should be able to see how the $lines array is used for positioning text.

Try inserting something like this either just before or just after the custom options.

// The quote item doesn't have any product attributes, it is only a quote! $product = Mage::getModel('catalog/product')->load($item->getProductId()); // Use the actual product object to add a new line. $lines[][] = array(     'text' => Mage::helper('core')->__('Manufacturer SKU: ') . $product->getManufacturerSku(),     'feed' => 35 );
You can try to change the position of attribute value by changing the value of feed. For more detail follow this link:-
http://inchoo.net/ecommerce/magento/how-to-add-custom-attribute-to-magentos-pdf-invoice/
 
Leave a comment

Posted by on May 7, 2012 in Magento, PHP

 

Tags: , , ,

 
%d bloggers like this: