Set breadcrumb for one of the pages of Magento? - magento

I have this page for instance that doesn't have a proper breadcrumb set: http://www.princessly.com/checkout/cart/
It's just "Home >>" and that's it.
How can I make it "Home >> Shopping Cart"?
Thus far I can only find the breadcrumb template which is template/page/html/breadcrumbs.phtml but I have no idea how to make this change.
I suppose I should add a line in the shopping cart page template?

Try adding the following code to local.xml of your theme:
<checkout_cart_index>
<reference name="breadcrumbs">
<action method="addCrumb">
<crumbName>Home</crumbName>
<crumbInfo><label>Home</label><title>Home</title><link>/home</link></crumbInfo>
</action>
<action method="addCrumb">
<crumbName>Shopping Cart</crumbName>
<crumbInfo><label>Shopping Cart</label><title>Shopping Cart</title><link>/checkout/cart</link></crumbInfo>
</action>
</reference>
</checkout_cart_index>

For some reason sometimes we need to touch the template on code>page>html>breadcrumbs.phtml. Just remember to move before to your template.
<?php if($crumbs && is_array($crumbs)): ?>
<div class="breadcrumbs">
<ul>
<?php foreach($crumbs as $_crumbName=>$_crumbInfo): ?>
<li class="<?php echo $_crumbName ?>">
<?php if($_crumbInfo['link']): ?>
<?php echo $this->__($this->htmlEscape($_crumbInfo['label'])) ?>
<?php elseif($_crumbInfo['last']): ?>
<strong><?php echo $this->__($this->htmlEscape($_crumbInfo['label'])) ?></strong>
<?php else: ?>
<?php echo $this->__($this->htmlEscape($_crumbInfo['label'])) ?>
<?php endif; ?>
<?php if(!$_crumbInfo['last']): ?>
<span>/ </span>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
The translate is performed by
$this->__("someText");

Related

Show categories on left and not on top navigation

I tried implemented a code in my Navigation/left.phtml
The code is as follows
<!-- subcategory code -->
<?php
$category = Mage::getSingleton('catalog/layer')->getCurrentCategory();
if(!$category->getChildren()){
//$parentcat_id = $category->getParentCategory()->getId();
//$category = Mage::getSingleton('catalog/category')->load($parentcat_id);
$category = $category->getParentCategory();
}
$categories = $category->getCollection()
->addAttributeToSelect(array('name', 'thumbnail'))
->addAttributeToFilter('is_active', 1)
->addIdFilter($category->getChildren());
?>
<div class="block">
<div class="block-title">
<span><?php echo $category->getName() ?></span>
</div>
<div class="block-content clearfix">
<ul class="subcategories">
<?php foreach ($categories as $category): ?>
<li>
<a href="<?php echo $category->getUrl() ?>"><!--<img src="<?php echo Mage::getBaseUrl('media') . 'catalog' . DS . 'category' . DS . $category->getThumbnail() ?>" alt="<?php echo $this->htmlEscape($category->getName()) ?>" />-->
<span><?php echo $category->getName() ?>
<?php $collection = Mage::getModel('catalog/product')->getCollection()->addCategoryFilter($category);
echo "(".count($collection).")"; ?></span>
</a>
</li>
<?php endforeach; ?>
</ul></div>
</div>
<!-- subcategory code -->
<!-- List all categories and their second level subcategories -->
<div class="block block-list block-categories">
<div id="block-categories" class="block-title active">
<strong><span>Categories </span></strong>
</div>
<div id="leftnav" class="block-content" style="display:block">
<?php $helper = $this->helper('catalog/category') ?>
<?php $categories = $this->getStoreCategories() ?>
<?php if (count($categories) > 0): ?>
<ul id="leftnav-tree" class="level0">
<?php foreach($categories as $category): ?>
<li class="level0<?php if ($this->isCategoryActive($category)): ?> active<?php endif; ?>">
<?php //if ($this->isCategoryActive($category)): ?>
<?php $subcategories = $category->getChildren() ?>
<?php if (count($subcategories) > 0): ?>
<ul id="leftnav-tree-<?php echo $category->getId() ?>" class="level1">
<?php foreach($subcategories as $subcategory): ?>
<li class="level1<?php if ($this->isCategoryActive($subcategory)): ?> active<?php endif; ?>">
<?php echo $this->escapeHtml(trim($subcategory->getName(), '- ')) ?>
<?php $secondLevelSubcategories = $subcategory->getChildren() ?>
<?php if (count($secondLevelSubcategories ) > 0): ?>
<ul id="leftnav-tree-<?php echo $subcategory->getId() ?>" class="level2">
<?php foreach($secondLevelSubcategories as $secondLevelSubcategory ): ?>
<li class="level2<?php if ($this->isCategoryActive($secondLevelSubcategory )): ?> active<?php endif; ?>">
<?php echo $this->escapeHtml(trim($secondLevelSubcategory ->getName(), '- ')) ?>
</li>
<?php endforeach; ?>
</ul>
<script type="text/javascript">decorateList('leftnav-tree-<?php echo $category->getId() ?>', 'recursive')</script>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<script type="text/javascript">decorateList('leftnav-tree-<?php echo $category->getId() ?>', 'recursive')</script>
<?php endif; ?>
<?php //endif; ?>
</li>
<?php endforeach; ?>
</ul>
<script type="text/javascript">decorateList('leftnav-tree', 'recursive')</script>
<?php endif; ?>
</div>
</div>
But when i set Include in Navigation Menu to No it also disappears from here.
Is there any way I can hide from top menu and show in my side menu?
Demo link is http://infigic.com/ds4u/
If you don't have local.xml file just create one in the layout folder of your theme and populate it with this content:
<?xml version="1.0"?>
<layout>
<default>
<reference name="header">
<action method="unsetChild"><name>top.menu</name></action>
</reference>
<reference name="left">
<action method="insert"><child>top.menu</child></action>
</reference>
</default>
</layout>
Changing your collection request to this should work :
$categories = $category->getCollection()
->addAttributeToSelect(array('name', 'thumbnail'))
->addAttributeToFilter('is_active', 1)
->addAttributeToFilter('include_in_menu', 1) // there is the 'magic'
->addIdFilter($category->getChildren());
Although, I do not recommend you to do it like this.
Because:
You are breaking the MVC pattern of Magento when requesting a model from a view
You are doing over complicated things that you may probably achieve easier by doing a block which extends Mage_Catalog_Block_Navigation, where the category may already be filtered the right way, but not rendered as you would like.
Please have a look at base Magento template (well not only the one in /app/design/frontend/base, but the one coming with a fresh install of Magento) and you'll see that never ever are there going to be a direct call in a view to a model instance.
For Magento good practice, please refer to the perfect blog of Alan Storm (who also is a SO member) here and maybe more specifically to this chart showing how templates (view) should interact with blocks to render models.

Add A Checkout Block to Header

I'm trying to add a block to my Header that displays Cart information.
I'm not getting any display from this block as of yet.
Here's my checkout.xml:
<reference name="header">
<block type="checkout/cart_sidebar" name="checkout.basket" as="checkoutBasket" />
</reference>
Here's my basket.phtml:
<script>alert("TEST");</script>
<div class="block checkout-basket">
TEST
</div>
Here's my header.phtml:
<?php echo $this->getChildHtml('checkoutBasket'); ?>
I'm fairly new to Magento and it's Block system so I'm not sure I've joined up all the dots correctly to get this block to display.
There template file is missing in the code of xml
<block type="checkout/cart_sidebar" name="checkout.basket" as="checkoutBasket" template="pathoftemplate/basket.phtml" />
if you want to show all cart item just like default
then
<block type="checkout/cart_sidebar" name="checkout.basket" as="checkoutBasket" template="pathoftemplate/basket.phtml">
<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 type="core/text_list" name="cart_sidebar.extra_actions" as="extra_actions" translate="label" module="checkout">
<label>Shopping Cart Sidebar Extra Actions</label>
</block>
And code must be add in basket.phtml
<?php if ($this->getIsNeedToDisplaySideBar()):?>
<div class="block block-cart">
<?php $_cartQty = $this->getSummaryCount() ?>
<div class="block-title">
<strong><span><?php echo $this->__('My Cart') ?></span></strong>
</div>
<div class="block-content">
<?php if ($_cartQty>0): ?>
<div class="summary">
<?php if ($_cartQty==1): ?>
<p class="amount"><?php echo $this->__('There is 1 item in your cart.', $this->getUrl('checkout/cart')) ?></p>
<?php else: ?>
<p class="amount"><?php echo $this->__('There are %s items in your cart.', $this->getUrl('checkout/cart'), $_cartQty) ?></p>
<?php endif ?>
<p class="subtotal">
<?php if ($this->canApplyMsrp()): ?>
<span class="map-cart-sidebar-total"><?php echo $this->__('ORDER TOTAL WILL BE DISPLAYED BEFORE YOU SUBMIT THE ORDER'); ?></span>
<?php else: ?>
<span class="label"><?php echo $this->__('Cart Subtotal:') ?></span> <?php echo Mage::helper('checkout')->formatPrice($this->getSubtotal()) ?>
<?php if ($_subtotalInclTax = $this->getSubtotalInclTax()): ?>
<br />(<?php echo Mage::helper('checkout')->formatPrice($_subtotalInclTax) ?> <?php echo Mage::helper('tax')->getIncExcText(true) ?>)
<?php endif; ?>
<?php endif; ?>
</p>
</div>
<?php endif ?>
<?php if($_cartQty && $this->isPossibleOnepageCheckout()): ?>
<div class="actions">
<?php echo $this->getChildHtml('extra_actions') ?>
<button type="button" title="<?php echo $this->__('Checkout') ?>" class="button" onclick="setLocation('<?php echo $this->getCheckoutUrl() ?>')"><span><span><?php echo $this->__('Checkout') ?></span></span></button>
</div>
<?php endif ?>
<?php $_items = $this->getRecentItems() ?>
<?php if(count($_items)): ?>
<p class="block-subtitle"><?php echo $this->__('Recently added item(s)') ?></p>
<ol id="cart-sidebar" class="mini-products-list">
<?php foreach($_items as $_item): ?>
<?php echo $this->getItemHtml($_item) ?>
<?php endforeach; ?>
</ol>
<script type="text/javascript">decorateList('cart-sidebar', 'none-recursive')</script>
<?php else: ?>
<p class="empty"><?php echo $this->__('You have no items in your shopping cart.') ?></p>
<?php endif ?>
</div>
</div>
<?php endif;?>

Navigation block is rendered twice?

i try to include a custom category-navigation in the left column of a custom magento layout template. there fore i placed the following code in my local.xml
<!--Category View-->
<catalog_category_view>
<!--Set Page Template-->
<reference name="root">
<action method="setTemplate">
<template>page/hew_layout_2cl.phtml</template>
</action>
</reference>
<reference name="left">
<block type="catalog/navigation" name="catalog.catleftnav" template="catalog/category/navigation/left.phtml" />
</reference>
</catalog_category_view>
my layout file is placed in design/frontend/###CUSTOM###/default/template/page/layout_2cl.phtml and includes the following line for the left column
<div class="col-left sidebar"><?php echo $this->getChildHtml('left') ?></div>
the left.phtml navigation file is placed in design/frontend/###CUSTOM###/default/template/catalog/category/navigation/left.phtml and looks like this
<?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php $currentCategory = Mage::registry('current_category') ?>
<?php if (count($_categories) > 0): ?>
<ul>
<?php foreach($_categories as $_category): ?>
<?php if ($currentCategory && $currentCategory->getId() == $_category->getId()): ?>
<?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
<?php $_subcategories = $_category->getChildrenCategories() ?>
<?php if (count($_subcategories) > 0): ?>
<?php foreach($_subcategories as $_subcategory): ?>
<li>
<a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">
<?php echo $_subcategory->getName() ?>
</a>
</li>
<?php endforeach; ?>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php endif; ?>
the only problem here is, that the left block is rendered twice. i also followed the bugfix of the following thread, but it didn't help.
any advice on this? thanks!

Hiding or Showing Filters In Certain Categories in magento

on our highest level category there are about 50 shop-by options, i m trying to hide attribute filter with xml code in custom layout of categories. with this code
<reference name="em.catalog.leftnav">
<action method="setData">
<instruction>hide_attribute_code</instruction>
<value>1</value>
</action>
But not hide filter attribute in that category, check it on image
in catalog.xml
<catalog_category_layered translate="label">
<label>Catalog Category (Anchor)</label>
<reference name="left">
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
</reference>
<catalog_category_layered translate="label">
follow the template ... catalog/layer/view.phtml
Open this file and made there conditions for filters to appear on frontend, by name or id
<?php $_filters = $this->getFilters() ?>
<?php foreach ($_filters as $_filter): ?>
<?php if($_filter->getName() == 'Price' || $_filter->getName() == 'Category' || $_filter->getName() == 'Manufacturer' ): ?>
<?php if($_filter->getItemsCount()): ?>
<dt><?php echo $this->__($_filter->getName()) ?></dt>
<dd><?php echo $_filter->getHtml() ?></dd>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
I do not know your extension that is reliable for layered navigation, but this should work:
<reference name="em.catalog.leftnav">
<action method="hideAttributes">
<code>hide_attribute_code</code>
</action>
</reference>
Go to the file in app/code/POOL/YOUR/MODULE/Blocks/... that builds your filter. If your template has something like getFilters() you can try echo get_class($this) to get the correct class/file. There you have to do two things:
1.) add a new method (in this case you can set comma seperate the attribute codes)
public function hideAttributes($attributeCodes)
{
$attributeCodes = array_map('trim', explode(',', $attributeCodes));
$this->setData('hide_attributes', $attributeCodes);
}
2.) search for the function that collects the filters, e.g. getFilters() and add
$filterableAttributes = // some code
foreach ($filterableAttributes as $attribute) {
if (!in_array($attribute->getAttributeCode(), $this->getHideAttributes())) {
...
}
}
You will need to unset the attribute name on view layer, so find this file:
magento/app/design/frontend/base/default/template/catalog/layer/view.phtml
edit:
<?php if($this->canShowBlock()): ?>
<div class="block block-layered-nav">
<div class="block-title">
<strong><span><?php echo $this->__('Shop By') ?></span></strong>
</div>
<div class="block-content">
<?php echo $this->getStateHtml() ?>
<?php if($this->canShowOptions()): ?>
<p class="block-subtitle"><?php echo $this->__('Shopping Options') ?></p>
<dl id="narrow-by-list">
<?php $_filters = $this->getFilters() ?>
<?php foreach ($_filters as $_filter): ?>
<?php if($_filter->getItemsCount()): ?>
<!-- add this line start-->
<?php if($_filter->getName() != "Color"): ?>
<!-- add this line end-->
<dt><?php echo $this->__($_filter->getName()) ?></dt>
<dd>
<?php echo $_filter->getHtml() ?>
</dd>
<!-- add this line start-->
<?php endif; ?>
<!-- add this line end-->
<?php endif; ?>
<?php endforeach; ?>
</dl>
<script type="text/javascript">decorateDataList('narrow-by-list')</script>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
Hope you can get working now !

I want to display the category and its child category structure on my page like below in magento 1.7

I'm new in magento and having problem with the category and its child category and their products structure .
plz can anyone give me the code to implement exactly the same structure .
I want structure like this on the content area ,not in the any side bar or header navigation :-
Main Category Name
Subcategory1 Name
Product 1
Product 2
.
.
Subcategory2 Name
Product 1
Product 2
.
.
and this should be work for every category.
Can anyone solve this ?
Thanks in advance :)
Here is some code I have used to display sub category tiles on a category page.
https://www.evernote.com/shard/s4/sh/cc805407-a0d5-4d74-8cd2-b2d7513262f1/9934b5a9f09962b90fe5ecf76f06deb5
I would suggests not to ask the for code better you try this people here can give idea.
Then also...
Go to following path in your magento(Note: Here I am using base/default/default you have to use in your template file).
/app/design/frontend/base/default/template/catalog/navigation
Create New file vert-navigation.phtml
<?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php $currentCategory = Mage::registry('current_category') ?>
<?php if (count($_categories) > 0): ?>
<div class="vertical-nav">
<div class="navi-title"><h2>BROWSE BY CATEGORY</h2></div>
<?php echo $this->getChildHtml('topSearch') ?>
<ul>
<?php foreach($_categories as $_category): ?>
<li>
<a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
<?php echo $_category->getName() ?>
</a>
<?php //if ($currentCategory->getName() == $_category->getName()): ?>
<?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
<?php $_subcategories = $_category->getChildrenCategories();
//$count=0; ?>
<?php if (count($_subcategories) > 0): ?>
<!--li>
<a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
<?php echo $_category->getName() ?>
</a-->
<ul>
<?php foreach($_subcategories as $_subcategory): ?>
<li>
<a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">
<?php echo $_subcategory->getName() ?>
</a>
</li>
<?php //$count++; ?>
<?php //if($count==4) break; ?>
<?php endforeach; ?>
</ul>
<?php //endif; ?>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
Then go to /app/design/frontend/base/default/layout/catalog.xml place the below code
<reference name="content">
<!--block type="catalog/navigation" name="catalog.leftnav" after="currency" template="catalog/navigation/left.phtml"/-->
<block type="catalog/navigation" before="-" name="catalog.vertnav" template="catalog/navigation/vert-navigation.phtml"/>
</reference>
You will see the full listing of Category do style as you requirement.

Resources