Magento: add to cart button is not working
Posted by admin in Magento
In my custom theme there was this code for Add to cart button:
<button type=”button” class=”button-form” onclick=”productAddToCartForm.submit()”><span><?php echo $this->__(’Add to Cart’) ?></span></button>
The problem was that nothing happened when you clicked it. Just remove type="button" so it looks like this:
<button class=”button-form” onclick=”productAddToCartForm.submit()”><span><?php echo $this->__(’Add to Cart’) ?></span></button>
It worked for me…
Magento: error when opening product view page
Posted by admin in Magento
When I try to open product view page I get this error:
Warning: include(/…../…../public_html/magento/app/design/frontend/mytheme/default/template/page/2columns-left) [function.include]: failed to open stream: No such file or directory in /…../…../public_html/magento/app/code/core/Mage/Core/Block/Template.php on line 144
The problem occured because I made a mistake in /app/design/frontend/mytheme/mytheme/layout/catalog.xml. In <catalog_product_view> tags I have set:
<action method=”setTemplate”><template>page/2columns-left</template></action>
where it must be:
<action method=”setTemplate”><template>page/2columns-left.phtml</template></action>
!!!
Magento: how to set number of columns in product list
Posted by admin in Magento
Open /app/design/frontend/your_theme/your_theme/template/catalog/product/list.phtml and find line:
<?php $_columnCount = $this->getColumnCount(); ?>
and replace it with:
<?php $_columnCount = 4; ?>
Set the number of columns as you need.
Make changes on your website witch only you can see
Posted by admin in html / css, tips
Go to this website to get your IP: http://whatismyipaddress.com/
and replace the ‘111.11.11.11′ whit it in the code below.
<?php if($_SERVER[’REMOTE_ADDR’] == ‘111.11.11.11′) { ?>
<!– insert your html or php or whatever code here….. –>
<?php } ?>
The code between { } will be seen only through you IP address. Enjoy.
Magento: set number of products in new products module
Posted by admin in Magento
You can set number of products to be displayed in new product module in your new.phtml file. Find:
<?php $i=0; foreach ($_products->getItems() as $_product): ?>
and add above, so the code looks like this:
<?$_products->setOrder(’news_from_date’)->setPageSize(6)->setCurPage(1);?>
<?php $i=0; foreach ($_products->getItems() as $_product): ?>
Set the number (6) as you like.
On the other hand you can set this number in administration on home cms page. Under Custom desing set the code for new products to look like this:
<reference name=”content”>
<block type=”catalog/product_new” name=”home.new” alias=”product_new” template=”catalog/product/new.phtml”>
<action method=”setProductsCount”><count>8</count></action>
<action method=”addPriceBlockType”>
<type>bundle</type>
<block>bundle/catalog_product_price</block>
<template>bundle/catalog/product/price.phtml</template>
</action>
</block>
</reference>
Just set the number in tags.
Magento: How to move cart block from sidebar to header?
Posted by admin in Magento
Open file: /app/design/frontend/your_theme/your_theme/template/page/html/header.phtml and add this line where you want the cart block to be displayed:
<?php echo $this->getChildHtml(’cart_sidebar_head’) ?>
Open file: /app/design/frontend/your_theme/your_theme/layout/page.xml and insert this in block type page/html_header:
<block type=”checkout/cart_sidebar” name=”cart_sidebar_head” template=”checkout/cart/sidebar.phtml” />
You probably don’t need cart block in you sidebar anymore so open file: /app/design/frontend/your_theme/your_theme/layout/checkout.xml and remove or comment these lines:
<block type=”checkout/cart_sidebar” name=”cart_sidebar” template=”checkout/cart/sidebar.phtml” before=”-”>
<action method=”addItemRender”><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/sidebar/default.phtml</template></action>
<action method=”addItemRender”><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/sidebar/default.phtml</template></action>
<action method=”addItemRender”><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/sidebar/default.phtml</template></action>
</block>
Magento: how to display a certain attribute?
Posted by admin in Magento
Here is how you can display certain attribute on product page. In my case I needed to display cost price:
<?php echo $_helper->productAttribute($_product, $this->htmlEscape($_product->getCost()), ‘cost’) ?>
Or use this for your custom attributes:
<?php echo $_helper->productAttribute($_product, $this->htmlEscape($_product->getCustom()), ‘Custom’) ?>
Magento: remove break (br) tag from textarea
Posted by admin in Magento
After installing WYSIWYG editor to my magento site the <br /> tags were still added after each row in textareas. My main problem was the product description so I opened file /app/design/frontend/my_theme/my_theme/template/catalog/product/view/description.phtml and found line:
<?php echo $this->helper(’catalog/output’)->productAttribute($this->getProduct(), nl2br($this->getProduct()->getDescription()), ‘description’) ?>
and replaced it with:
<?php echo $this->helper(’catalog/output’)->productAttribute($this->getProduct(), $this->getProduct()->getDescription(), ‘description’) ?>
Basically I removed the nl2br() function which inserts the <br /> tags to the description text. You can do the same where ever the breaks are messing up your design view…


