I'm working on a website. Upon clicking the product it shows all the details of it. But my client want me to show parent category of categroy of the product at top, above the image. Please help me about it. I'm a budding developer.
Try this may be help someone else.
<?php $_helper = $this->helper('catalog/output');?>
<?php $_category_detail=Mage::registry('current_category');?>
<?php $_category_detail->getName();?>
<?php $_category_detail->getId(); ?>
You can get the category data from your product object: $_product->getCategory()->getName();. You will have to edit the template at template/catalog/product/view.phtml. In the template file look for <div class="product-img-box"> and add:
<div class="product-img-box">
<h4><?php echo $_product->getCategory()->getName(); ?></h4>
<?php echo $this->getChildHtml('media') ?>
</div>
Related
I want to show the category description of each category dynamically on category list page. First I try to set condition for each category but that was not perfect solution late I found a best way to do this so I thought I should share it to prevent someone time.
By using below code you can check the current category on catalog list template of your theme.
$metaDescription = Mage::getSingleton('catalog/layer')->getCurrentCategory()->getMetaDescription();
if(!empty($metaDescription)): ?>
<div class="col-md-12 std">
<p><?php echo $metaDescription; ?></p>
</div>
<?php endif; ?>
Follow the screenshot to add meta description of category in magento admin section.
i try to add "short description" on my category list of my products but nothing happend on my list.phtml
i try on: app/design/frontend/base/default/template/catalog/product/list.phtml
in my lit view are there this code:
(and i copy this code to grid block but nothing happend)
<div class="desc std">
<h1>test</h1>
<?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
<?php echo $this->__('Learn More') ?>
</div>
Go to Catalog->Attributes->Manage attributes, search for the short_description attribute, edit it and set the field Used in product listing to Yes. Reindex everything and it should work.
[EDIT]
Or you can simply use this:
<?php echo $_product->getShortDescription();?>
I am new to Magento; now I am trying to develop a simple example site.
My question is this: how can we add pages to main menu?
create one static block with "Your page name"
Create new category with display mode "Static block only" and "include in navigation menu = YES" and select your cms block and save category. And see in front-end side this will be added in navigation item.
Here is the official Magento recommendation on how to do this: http://www.magentocommerce.com/knowledge-base/entry/adding-page-links-in-the-navigation-bar
To add a CMS page link to top navigation the hard way, you should override /mnt/www/x1886/app/design/frontend/default/default/template/catalog/navigation/top.phtml.
There are plenty tutorials out there about how to override files in Magento.
Change a change where I placed a comment:
<div class="header-nav-container">
<div class="header-nav">
<h4 class="no-display"><?php echo $this->__('Category Navigation:') ?></h4>
<ul id="nav">
<!-- ADD ADDITIONAL LINKS HERE -->
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php echo $this->drawItem($_category) ?>
<?php endforeach ?>
</ul>
</div>
<?php echo $this->getChildHtml('topLeftLinks') ?>
</div>
I'm new to magento when i list categories in sidebar. when i click the category name means it will go to 404 error page. If you have any idea Please tell me as soon as possible..
and my code is
<?php
$_categories = Mage::getModel('catalog/category')->load(3)->getChildrenCategories();
if($_categories->count()):
$categorycount = 0;
foreach ($_categories as $_category):
if($_category->getIsActive()):
$cur_category=Mage::getModel('catalog/category')->load($_category->getId());
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($cur_category);
?>
<li><a href="<?php echo $_category->getURL() ?>" title="<?php echo
$this->htmlEscape($_category->getName()) ?>"><span class="categoriesHead"><?php
echo $this->htmlEscape($_category->getName()) ?></span>
</a>
</li>
<?php
endif;
endforeach;
endif;
?>
I had the same issue in 1.5.1 and in my case it was the category url suffix which was expecting a .html suffix but the links were giving me blank. I changed Admin>>System>>Configuration>>Catalog>>Search Engine Optimisations>>category suffix from ".html" to "" (blank) and it's working fine now.
I spend so much time on this problem.... You might have made your categories root categories and not subcategories. Simply drag and drop them into the default category and see if that gives you a better url.
You can see if you are getting a bad url by just appending index.php/name of category in small case/ to the base url
Try this:
Go in admin>>System>>Configuration>>Catalog and under Category permissions select No at Enable option.
Then click Save config and clear Magento cache.
I have the following requirement;
I want to show a products configured related products on the category listing page (list.phtml).
I figured I could make some call on the list.phtml inbetween the for each loop for each product using the [b]$_product[/b] variable but I can't seem to populate the relatedProductCollection
sorry new to all this is it even possible.
<?php foreach ($_productCollection as[b] $_product[/b]):?>
<li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?>last<?php endif; ?>" >
<div class="product-shop">
<div class="f-fix">
<?php $product->getRelatedProductCollection(); ?>
</li>
<?php endforeach; ?>
$product has been used to call the getRelatedProductCollection function.
but,
In that foreach loop you have taken it as $_product.
Can you see the difference ??
Underscore is missing. This is taken from your code. Make the variable same in both the places and try.