Skip to content

Instantly share code, notes, and snippets.

@adamburvill
Last active August 29, 2015 13:57
Show Gist options
  • Save adamburvill/9814252 to your computer and use it in GitHub Desktop.
Save adamburvill/9814252 to your computer and use it in GitHub Desktop.
Magento Useful Tips

Troubleshooting Data with Magento:

How to backup from bundles and get general product info:

Gets the Product ID of the selection

$_selectionID = $_selection->getProductId();

Loads the product model

$_newProduct = Mage::getModel('catalog/product')->load($_selectionID);

Now you can run either a foreach on $_newProduct using:

foreach(($_newProduct->getData())) 

or use var_dump( $_newProduct->getData() )

Or you can dial in on the method you want:

$_newProduct->getTierPrice etc 

You can do the same for the selection or option itself by using:

$_selection OR $this->getSelection()

$_selection->getData(); etc…..

Determining Block Name in template:

<?php die(get_class($this)); ?>

Get Store Base URL

Mage::getBaseUrl()

Get Product Attribute By Name

$this->getProductAttribute('product_attribute')

Get Store Currency Code/Symbol

Mage::app()->getStore()-> getCurrentCurrencyCode();
Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();

Troubleshooting New Install:

  • Htaccess
  • File Permissions (especially on root folder, 755 for directories, 644 for files)
  • Check var/report for basic error reporting
  • Check that database info in app/etc/local.xml is correct

Debugging

Zend_Debug::dump($variable)
https://github.com/netz98/n98-magerun - Command line debugger
https://github.com/firegento/firegento-debug - Awesome backend integrated debugger

Useful Stack Overflow Posts

Module Incompatibility / Class Rewrites
http://stackoverflow.com/questions/15636423/magento-invalid-method-mage-bundle-block-catalog-product-view-type-bundle-optio

Show Thumbnail Images in Order Emails

templates/email/order/items/order/default.phtml

<?php $_product = Mage::getModel('catalog/product')->load($_item->getProductId()) ;?>
<img src="<?php echo Mage::helper('catalog/image')->init($_product, 'thumbnail')->resize(75, 75); ?>" alt="<?php echo $this->htmlEscape($_product['name']); ?>;" border="0" width="75" />

templates/email/order/items.phtml
    <thead>
    <tr style="border-bottom: 1px solid #999;">
        <th align="left" bgcolor="#FFF" style="font-size:13px; padding:18px 9px"><?php echo $this->__('Image') ?></th>
        <th align="left" bgcolor="#FFF" style="font-size:13px; padding:18px 9px"><?php echo $this->__('Item') ?></th>
        <th align="left" bgcolor="#FFF" style="font-size:13px; padding:18px 9px"><?php echo $this->__('Sku') ?></th>
        <th align="center" bgcolor="#FFF" style="font-size:13px; padding:18px 9px"><?php echo $this->__('Qty') ?></th>
        <th align="right" bgcolor="#FFF" style="font-size:13px; padding:18px 9px"><?php echo $this->__('Subtotal') ?></th>
    </tr>
</thead>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment