1) Ensure that “Used in Product Listing” of the attribute is set to “yes”
2) Then use the code ?php echo $_helper->productAttribute($_product, $_product->getAttricuteCode(), attricutecode) ?>
Tag Archives: Magento
How to set product position Magento
1) Go to catalog > catalog > Manage categories and click on the category name that the product associated with
2) Click on the tab “Category Products” and there you can set the product position
Disable layered navigation Magento
Removed the below given code from catalog.xml
<reference name=”left”>
<block type=”catalog/layer_view” name=”catalog.leftnav” before=”-” template=”catalog/layer/view.phtml”/>
</reference>
Change the layout of category page Magento
Include The Below given code
<reference name=”root”>
<action method=”setTemplate”><template>page/2columns-left.phtml</template></action>
</reference>
right under the default tag in in catalog.xml page
OR
Edit the page page.xml and replace the code
<block type=”page/html” name=”root” output=”toHtml” template=”page/3columns.phtml”>
With
<block type=”page/html” name=”root” output=”toHtml” template=”page/2columns-left.phtml”>
Magento Admin login failing in chrome browser
Edit the page appcodelocalMageCoreModelSessionAbstractVarien.php
Search for the code
if (isset($cookieParams[‘domain’])) {
$cookieParams[‘domain’] = $cookie->getDomain();
}
and replace with
if (isset($cookieParams[‘domain’]) && !in_array(“127.0.0.1”, self::getValidatorData())) {
$cookieParams[‘domain’] = $cookie->getDomain();
}
Getting selected simple product id in configurable product Magento
1) place the code right after “ var spConfig = new Product.Config(getJsonConfig() ?>);”
spConfig.getIdOfSelectedProduct = function()
{
var existingProducts = new Object();
for(var i=this.settings.length-1;i>=0;i–)
{
var selected = this.settings[i].options[this.settings[i].selectedIndex];
if(selected.config)
{
for(var iproducts=0;iproducts<selected.config.products.length;iproducts++)
{
var usedAsKey = selected.config.products[iproducts]+””;
if(existingProducts[usedAsKey]==undefined)
{
existingProducts[usedAsKey]=1;
}
else
{
existingProducts[usedAsKey]=existingProducts[usedAsKey]+1;
}
}
}
}
for (var keyValue in existingProducts)
{
for ( var keyValueInner in existingProducts)
{
if(Number(existingProducts[keyValueInner])<Number(existingProducts[keyValue]))
{
delete existingProducts[keyValueInner];
}
}
}
var sizeOfExistingProducts=0;
var currentSimpleProductId = “”;
for ( var keyValue in existingProducts)
{
currentSimpleProductId = keyValue;
sizeOfExistingProducts=sizeOfExistingProducts+1
}
if(sizeOfExistingProducts==1)
{
alert(“Selected product id is: “+currentSimpleProductId)
}
}
2) call the function on the change event of dropdown
1) place the code right after “ var spConfig = new Product.Config(getJsonConfig() ?>);”
spConfig.getIdOfSelectedProduct = function()
{
var existingProducts = new Object();
for(var i=this.settings.length-1;i>=0;i–)
{
var selected = this.settings[i].options[this.settings[i].selectedIndex];
if(selected.config)
{
for(var iproducts=0;iproducts<selected.config.products.length;iproducts++)
{
var usedAsKey = selected.config.products[iproducts]+””;
if(existingProducts[usedAsKey]==undefined)
{
existingProducts[usedAsKey]=1;
}
else
{
existingProducts[usedAsKey]=existingProducts[usedAsKey]+1;
}
}
}
}
for (var keyValue in existingProducts)
{
for ( var keyValueInner in existingProducts)
{
if(Number(existingProducts[keyValueInner])<Number(existingProducts[keyValue]))
{
delete existingProducts[keyValueInner];
}
}
}
var sizeOfExistingProducts=0;
var currentSimpleProductId = “”;
for ( var keyValue in existingProducts)
{
currentSimpleProductId = keyValue;
sizeOfExistingProducts=sizeOfExistingProducts+1
}
if(sizeOfExistingProducts==1)
{
alert(“Selected product id is: “+currentSimpleProductId)
}
}
2) call the function on the change event of dropdown
<select onchange=”spConfig.getIdOfSelectedProduct()”
Magento store back URL
<?php
echo $_SESSION[‘core’][‘last_url’];
?>
Number Of Products in Cart Magento
<?php
echo Mage::helper(‘checkout/cart’)->getSummaryCount();
?>
Modify the range of page for the pagination in Magento
Include a phtml page in CMS Page – Magento
{{block type=”core/template” name=”list-categories” template=”catalog/category/newPage.phtml”}}