Resize A Magento Product Image
Here is a quick snippet that lets you resize a product image (and in this case, set it's url as a variable) when you are writing code outside the media.phtml file:
$thumbnail_image_url = Mage::helper('catalog/image')->init($product, 'image')->resize(235,235);
HOW TO: Show Contents of a Static Block
Static Blocks are a great way to re-use snippets of information, table data or images throughout your shop. Static Blocks can easily be shown in categories, cms pages and php files. Static Blocks are created in the Magento admin under CMS > Static Blocks. Here is how to show the contents of your static block just about anywhere in your site...
Integrating WordPress and Magento: A Fix for Google Analytics
In a previous post we discussed integrating your WordPress installation with your Magento header and footer. One problem we ran into with this approach was that Google Analytics was logging all page views on our blog as "empty.html". Obviously, this isn't ideal for tracking what content our readers are finding useful. It turns out the solution is an easy 4-step process.
Adding Page Titles to Your WordPress/Magento Integration Using CURL
Branko's solution for integrating WordPress with Magento has proven to be easy and popular. However, we have encountered hosting providers that disallow file_get_contents and needed to find a workaround. So we turned to the CURL library, and in the process we were able to pass WordPress page titles into Magento. Read on for step-by-step instructions.
Customize Magento’s Image Resize Functionality
Need to remove the white border around your images? Don't want everything to be square? Here is how to customize the ->resize functionality in Magento.
Retrieve Magento Core Configuration variables on the Magento frontend
Magento has a vast configuration table (core_config_data in your database) that is managed in the Magento admin under System > Configuration. Occasionally you might need to find the value of a core configuration variable to do something on the fronted of your Magento store. To do this you can use the Magento Mage::getStoreConfig() method.
Display A Product Category (With Pagination) On Any Magento CMS Page
Add the following XML to your Layout Update XML on your CMS page in:
Admin > CMS > Pages > Your CMS Page Name > Design > Layout Update XML
<reference name="content"> <block type="catalog/product_list" name="home" template="catalog/product/list.phtml"> <action method="setCategoryId"><category_id>137</category_id></action> <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml"> <block type="page/html_pager" name="product_list_toolbar_pager"/> </block> <action method="setToolbarBlockName"><name>product_list_toolbar</name></action> </block> </reference>
Where "137" in <action method="setCategoryId"><category_id>137</category_id></action> is the ID of your category
Filter Magento product collection using addAttributeToFilter() to create SQL OR(s)
/** Add attribute filter to collection
*
* If $attribute is an array will add OR condition with following format:
* array(
* array('attribute'=>'firstname', 'like'=>'test%'),
* array('attribute'=>'lastname', 'like'=>'test%'),
* )
*/
// Correct application looks like this
$_productCollection->addAttributeToFilter(
array(
array('attribute'=>'name', 'like'=>'%productname%'),
array('attribute'=>'sku', 'like'=>'%productsku%')
)
);
Remove Custom Option data from catalogsearch_fulltext table in the Magento database
When you Rebuild Search Index you may notice Custom Option data in that catalogsearch_fulltext table. This can be turned off by editing the file app/code/core/Mage/CatalogSearch/Model/Mysql4/Fulltext.php. Around line 524 comment out the following 3 lines:
if ($data = $typeInstance->getSearchableData($product)) {
$index = array_merge($index, $data);
}
Show blocks that are not loaded in the current object in Magento
Here is how to show the top search outside the header.phtml file. You can use this method anywhere in the template files to show other blocks that cannot be loaded with $this->getChildHtml()
echo $this->getLayout()->getBlock('top.search')->toHtml()


