I need to print my products details like name, SKU, price, image.

Code :

//THIS SCRIPT JUST INITIALS THE PROFILE TO BE RUN VIA MAGENTO ADMIN "RUN PROFILE IN POPUP". Its the same thing as click just via this file that you can run via Cron
$profileId = 1; // SYSTEM - IMPORT/EXPORT - DATAFLOW PROFILES PROFILES <-- you need to go into your Magento admin and grab the exact profile ID

require_once 'app/Mage.php';

$sku = 10; //this sku you get it from your text box.
$_product = Mage::getModel('catalog/product')->getCollection()
                  ->addAttributeToSelect(array('name', 'sku', 'price', 'thumbnail'))
                  ->addAttributeToFilter('status', 1)
                  ->addAttributeToFilter('sku', array('in' => $sku));

$imageHelper = Mage::helper('catalog/image');
foreach($_product as $prod){
    $name      = $prod->getName();
    $price     = $prod->getPrice();
    $thumbnail = $imageHelper->init($prod, 'thumbnail')->resize(150,220);


  echo "Name:   ", $name;
  echo "<br>";
  echo "Sku:    ", $sku;
  echo "<br>";
  echo "Price:  ", $price; 
  echo "<br>";
  echo "<img src='".$thumbnail ."'>";   

Everything Okay..

How can I add this to managed products grid, like if I click print, the above details should get them printed?


1 Answer 1


Try this. This will print the grid window.

Navigate to app/design/adminhtml/default/default/layout/local.xml

If there is no local.xml then creates it.

and add below code

<?xml version="1.0"?>

        <reference name="products_list">
            <action method="addButton">
                    <label>Print Grid</label>
        <reference name="content">
            <block type="adminhtml/template" name="my_button_url" template="my_module/printdata.phtml" />

Now navigate to


and add below code

<script type="text/javascript">
    function printgrid(){
  • i have 2 doubts first one,, what i need here " <class>some-class</class>"
    – zus
    Commented Nov 3, 2017 at 4:53
  • and where i can paste my custom code for print... "<block type="adminhtml/template" name="my_button_url" template="my_module/printdata.phtml" />"
    – zus
    Commented Nov 3, 2017 at 4:53
  • You can add your class name anything that you want. And which code you are talking about? In my answer, there are only two files. local.xml for showing print button and printdata.phtml for printing the current window. Commented Nov 3, 2017 at 6:02
  • I have added app/design/adminhtml/default/default/layout/local.xml sourcecode: codepaste.net/6dtdi1 and app/design/adminhtml/default/default/template/my_module/printdata.phtml source code: codepaste.net/hxdtrf
    – zus
    Commented Nov 4, 2017 at 6:14
  • may i know what is the error?
    – zus
    Commented Nov 4, 2017 at 6:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.