Skip to content

Instantly share code, notes, and snippets.

@americkson
Last active December 16, 2015 01:19
Show Gist options
  • Save americkson/5354605 to your computer and use it in GitHub Desktop.
Save americkson/5354605 to your computer and use it in GitHub Desktop.
Random Magento Snippets

Truncate Text

truncate($STRING, $LENGTH); ?>

Ways to print attributes

  • this should work for drop downs and multi-select
getAttributeText('attribute_name'); ?>
  • this should work for text fields
getAttributeName(); ?>
  • this should work for text areas
productAttribute($_product, nl2br($_product->getAttributeName()), 'attribute_name') ?>
  • this is another possible method
htmlEscape($_product->getData('attribute_name')); ?>

custom list.phtml

put this in local.xml where the '3' is the category ID

<CATEGORY_3>
    <reference name="product_list">
        <action method="setTemplate"><name>catalog/product/software.phtml</name></action>
    </reference>
</CATEGORY_3>

Media Images

When you have the stupid white frame rendering with images and you want to get rid of it. Add the following snippet just before the ->resize() call in the list.phtml or view.phtml.

->keepFrame(false)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment