How to Add a Line Break to Product Descriptions in Magento

This is one of those things you would think would already be in place with Magento Commerce but it isn’t. We want to have line breaks in our product descriptions in our Magento stores. Our clients want these as well so you don’t have to teach someone to add the <br> tags at each line break.

So here is how to add line breaks to product descriptions in Magento:

  1. Open /app/design/frontend/default/yourtheme/template/catalog/product/view/attributes.phtml
  2. Find this bit of code: productAttribute($_product, $_data['value'], $_data['code']) ?>
  3. Change that code to this: productAttribute($_product, nl2br ($_data['value']), $_data['code']) ?>
  4. Save your file.

Add Changing Images to Magento Home Page

Found this code that uses javascript to change images on your home page in Magento Commerce.

Simply edit your home landing CMS Page and add this code. You’ll have to change the names of the files below and add the complete URL of where you want to be taken when clicking a particular image.

<!–Image Slider Start–> <div align=”center”> <script type=”text/javascript”> var image1=new Image() image1.src=”{{skin url=images/work-truck-equipment.jpg}}” var image2=new Image() image2.src=”{{skin url=images/banner_2.jpg}}” var image3=new Image() image3.src=”{{skin url=images/banner_3.jpg}}” </script> <a href=”http://##”> <img src=”{{skin url=images/work-truck-equipment.jpg}}” border=”2″ name=”slide” width=”890″ height=”277″ /></a> <script> //variable that will increment through the images var step=1 function slideit(){ //if browser does not support the image object, exit. if (!document.images) return document.images.slide.src=eval(”image”+step+”.src”) if (step<3) step++ else step=1 //call function “slideit()” every 2.5 seconds setTimeout(”slideit()”,5000) } slideit() </script> </div> <!–Image Slider End–>

How To Add PDF File to Products in Magento

Let’s say you have brochures or additional product information you want to add to products in Magento and you want to allow people to download this information from your Magento Commerce site.

We’ve come up with a little cheat on how to add PDF files to products in Magento. It may not be perfect, but it works for us.

  1. First, go to your admin section of Magento and go to Catalog>Manage Categories
  2. Now select “Add Subcategory”
  3. Fill in all the info for your new category and click “Save Category”
  4. Go to Catalog>Manage Products
  5. Click “Add Product”
  6. As a helpful note, click “Save and Continue Edit” button regularly to keep from being kicked out of Magento Admin.
  7. For Product Type, select “Downloadable Product” then click continue
  8. Fill in all your information for your PDF file like any other product. We like to add an image as well for the file.
  9. In the “Related Products” section in the left menu, select all the products that this PDF file is related to.
  10. Now, notice in the menu on the left, there is an additional choice, one for “Downloadable Information“.
  11. Click the expand arrow for “Samples” and rename this to what you like. We’ll call this one “Download Information”.
  12. Now click “Add a Row” and name it for the file you want to add. For this example, we did “Backup Camera Installation Guide For Mobile Awareness Backup Cameras
  13. Save your new “Downloadable Product
  14. Now for the little bit tedious procedure. In the “Manage Products” section of Magento Admin, search for the products that are related to your PDF file. In this example, products would be “backup cameras“. Now open each product and select your new PDF file as a related item and save that product.

Now, when someone goes to your product, they can see in the related items section, your information file which is available for download.

    Get rid of Total Shipping Charges on packing slip in Magento

    This was another tough one here. Magento uses tons of files to accomplish different bits of tasks for all kinds of things. One of those tasks is creating the PDF packing slip that Magento generates when you are printing a “Shipment”. When you click “Print” on the Shipments section of Magento Admin, Magento automatically creates a PDF file for you to use for whatever reason. We use this “Packing Slip” as a purchase order with our vendors who then are supposed to “Blind Drop Ship” the product directly to our customers, including this Packing Slip we email them. The blind shipping is another story there, but if you’re a non-stocking dealer like we are, you can only do so much.

    Back to the modification. On this Magento Packing Slip, one thing that annoyed me was the fact that in the Shipping Methods box, there was text “Total Shipping Charges” followed by the amount of shipping. This is a packing slip, not an invoice, so to me, the shipping charges are irrelevant. It’s probably just me, since in searching Google, I found no one else with this question, How To Get Rid of Total Shipping Charges on packing slip in Magento, but maybe someone else will want this. I just don’t think it should be on the packing slip!

    MAKE A BACKUP OF YOUR FILE FIRST. YOU HAVE BEEN WARNED!

    1. Navigate through the files on your server to /app/code/local/Mage/Sales/Model/Order/Pdf/Abstract.php
    2. Open the file Abstract.php.
    3. On our version (1.3.2.3) the line that needs modification is on #309.
    4. You’ll see where it reads: $totalShippingChargesText = “(” . Mage::helper(’sales’)->__(’Total Shipping Charges’) . ” ” . $order->formatPriceTxt($order->getShippingAmount()) . “)”;
    5. Change it to read: ¬†$totalShippingChargesText = “”;
    6. Color of text above was done by me just for emphasis.
    7. Save your file, do not close it yet in case you messed up.
    8. Go to your shipments section of Magento Admin, open a shipment and click print. You should come up with a nice clean packing slip with no Shipping Charges Total line!