Removing Extra Line Breaks Added To Magento Product Descriptions

In order to remove the extra line breaks that are added to Magento product descriptions. Simply update the following file:

/app/design/frontend/base/default/template/catalog/product/view/description.phtml

Edit the line nl2br($_description) to $_description, removing nl2br.

The added line breaks were causing issues in Firefox when creating unordered lists and such as the list code would have an added line break, <br>, or what appeared to be line spacing added to each item within the list.

Google Analytics Bug Fix for Magento 1.4.0.1

In installing Google Analytics you may notice that your account remains in a waiting to receive data state. Although Google Analytics has been recognized and installed correctly a small correction must be made to the source code of the Mage code.

You will want to edit the following file:
app/code/core/Mage/GoogleAnalytics/Block/Ga.php

…And add this simple line of code to line 179 in order to resolve the issue.

var _gaq = _gaq || [];

This issue has been reported and resolved already by the Magento Team through Issue #21456

How to Change an Existing Products Attribute Set in Magento

Unfortunately Magento does not have the function built into its setup to allow you the option to change a products attribute set once you have created a simple product. However, with the following coding updates, you can add the functionality to change a simple products attribute set directly on the Catalog > Manage Products page:

In app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php around line 253 ad:

$sets = Mage::getResourceModel(‘eav/entity_attribute_set_collection’)
->setEntityTypeFilter(Mage::getModel(‘catalog/product’)
->getResource()->getTypeId())->load()->toOptionHash();

array_unshift($statuses, array(‘label’=>”, ‘value’=>”));
$this->getMassactionBlock()->addItem(‘attribute_set’, array(
‘label’=> Mage::helper(‘catalog’)->__(‘Change attribute set’),
‘url’ => $this->getUrl(‘*/*/massAttributeSet’, array(‘_current’=>true)),
‘additional’ => array(
‘visibility’ => array(
‘name’ => ‘attribute_set’,
‘type’ => ‘select’,
‘class’ => ‘required-entry’,
‘label’ => Mage::helper(‘catalog’)->__(‘Attribute Set’),
‘values’ => $sets
)
)
));

And then in app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php (anywhere in the class) add a new function:

public function massAttributeSetAction(){

$productIds = $this->getRequest()->getParam(‘product’);
$storeId = (int)$this->getRequest()->getParam(‘store’, 0);
if(!is_array($productIds)) {
$this->_getSession()->addError($this->__(‘Please select product(s)’));
} else {
try {
foreach ($productIds as $productId) {
$product = Mage::getSingleton(‘catalog/product’)
->unsetData()
->setStoreId($storeId)
->load($productId)
->setAttributeSetId($this->getRequest()->getParam(‘attribute_set’))
->setIsMassupdate(true)
->save();
}
Mage::dispatchEvent(‘catalog_product_massupdate_after’, array(‘products’=>$productIds));
$this->_getSession()->addSuccess(
$this->__(‘Total of %d record(s) were successfully updated’, count($productIds)));
} catch (Exception $e) {
$this->_getSession()->addError($e->getMessage());
}
}

$this->_redirect(‘*/*/’, array(‘store’=>(int)$this->getRequest()->getParam(‘store’, 0)));
}

Once you have added the two snippets of code you will now be able to select products from teh Manage Products list and update any products Attribute Set from the actions dropdown menu.

Simply Select ‘Change Attribute Set’ and select the appropriate attribute set from the new dropdown menu that appears to the right of Actions.

Pagination Update for Magento 1.4

With the update to Magento 1.4 comes a quick fix to the template file in order to allow your product listings to properly display the subpages or pagination for products.

In order to properly implement pagination into your product listings again, you must simply update your catalog.xml template file located in the layout directory of your template folder:

app/design/frontend/your-template/layout/catalog.xml

Add the follow code to properly call the pagination setup in the pager.phtml file:

<block type=”page/html_pager” name=”product_list_toolbar_pager”/>

Simply look for the toolbar.phtml block and paste in the pager block.

<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>

Add Custom Content to Magento Category Pages

For an updated variation on how to accomplish custom content on Magento Category pages, view this post > Customize the Content Layout on Magento Category Pages

When adding custom content to the category pages on your site, I find the category description to be very limiting and not necessarily give me the type of control I want to have over how much content I can add to a page without pushing the products below the fold. This tutorial outlines how you can use Custom CMS Blocks to design the exact layout you desire for your category pages.

First you will want to create a static block that will end up replacing the category page setup.

CMS > Static Block

Once created you may need to grab some of the template code in order to setup the static block so the text areas match the design of the template.

Personally I create an introductory paragraph followed by the product listings, then adding another section of content below the products that is more expansive and creates more unique content for my main category pages.  Simply update the cat_ID with the corresponding category products you want to display on this page, set the status to ‘Enabled’ and save the CMS Custom Block.

Content

{{block type=”catalog/product_list” column_count=”3″ category_id=”cat_ID” template=”catalog/product/list.phtml”}}

Content

Now you can setup the category page to display the custom block you have created, rather then just using the category description as it limits your control over where you can implement content.

Catalog > Manage Categories

Select the category and click on the Display Settings tab. Under Display Mode select Static Block only as we have used custom code to display the products between our content blocks. Now you simply have to select the CMS Block you created and save the changes.

Disable the Shopping Cart in Magento

System > Configuration

In the right sidebar Under Advanced, click on the Advanced tab and select disable from the Mage_Checkout dropdown menu.