Display Items in Cart with Product Options - magento

Could anyone guide me to display items with product and its options like color,size etc in header block..,Here is my code
<?php
$quote=Mage::getSingleton('checkout/session')->getQuote();
$count=Mage::getSingleton('checkout/cart')->getSummaryQty();
$total=$quote->getGrandTotal();
$cartItems=$quote->getAllVisibleItems();
?>
Your bag contains <?php echo $count ?> item(s) <?php echo Mage::helper('core')->formatPrice($total,false) ?>
<br>
<?php foreach($cartItems as $item): ?>
<?php echo $item->getName() ?>
<?php echo $item->getQty() ?>
<?php echo Mage::helper('core')->formatPrice($item->getPrice(),false) ?>
<?php $productOptions = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct()) ?>
<pre>
<?php //print_r($productOptions)?>
</pre>
<?php foreach($productOptions as $productOption): ?>
<!-- what should come here -->
<?php endforeach; ?>
<?php endforeach ?>

Related

I want to display an option list for configurable attributes on product list page in magento

I want to display an option list for configurable attributes on product list page in magento, just like it appears on product view page for configurable products.I tried everything but nothing is working, looked for some similar topics but they are useless.Please help me resolve this issue.
<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');
$sidebar=Mage::getStoreConfig('buyshoplayout/product_listing/sidebar');
$i=0;
$count=0;
$span=3;
$p_in_row=4;
$type=Mage::getStoreConfig('buyshoplayout/product_listing/product_listing_image_size');
if($type=='small')
{
$span=2;
$p_in_row=6;
}
?>
<?php if(!$_productCollection->count()): ?>
<div class="category-products aligncenter">
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('buyshop_no_products')->toHtml() ?>
</div>
<?php else: ?>
<div class="category-products">
<?php echo $this->getToolbarHtml() ?>
<?php // List mode ?>
<?php if($this->getMode()!='grid'): ?>
<?php foreach ($_productCollection as $_product): ?>
<?php
$widthBig=258;
$heightBig=245;
$widthSmall=71;
$heightSmall=65;
$count++;
?>
<!--PRODUCT-->
<div class="row product-listing">
<?php echo Mage::helper('buyshopconfig')->getProductHtml($_product,$this,$widthBig,$heightBig,$span,false,true,true,false,$this->getPriceHtml($_product, true))?>
<div class="span6 product-detailes">
<h3 class="product-name bottom-line"><?php echo $this->stripTags($_product->getName(), null, true)?></h3>
<div class="bottom-line">
<?php echo $this->getPriceHtml($_product, true) ?>
<div class="product-review">
<?php echo Mage::helper('buyshopconfig')->getStars($_product)?>
</div>
</div>
<div class="bottom-line"><?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?></div>
<div class="product-buttons">
<?php echo Mage::helper('buyshopconfig')->addToCartLink($_product,$this,true)?>
<div class="add-to-links">
<ul>
<?php echo Mage::helper('buyshopconfig')->addWishCompLink($_product,$this,true)?>
</ul>
</div>
</div>
</div>
</div>
<!--PRODUCT EOF-->
<?php endforeach; ?>
<?php else: ?>
<?php // Grid Mode ?>
<?php if(!empty(Mage::registry('current_category')->name)):?>
<h2><?php echo Mage::registry('current_category')->name ?></h2>
<?php endif; ?>
<?php if($sidebar):?><div class="row big_with_description"><?php endif; ?>
<?php foreach ($_productCollection as $_product): ?>
<?php if(!$_product->isSaleable() && !Mage::getStoreConfig('cataloginventory/options/show_out_of_stock'))continue; ?>
<?php
$widthBig=258;
$heightBig=245;
$widthSmall=71;
$heightSmall=65;
$count++;
?>
<?php
if(!$sidebar)
{
$i++;
if($i==1)echo '<div class="row big_with_description">';
}
$price=$this->getPriceHtml($_product, true);
?>
<!--PRODUCT-->
<?php echo Mage::helper('buyshopconfig')->getProductHtml($_product,$this,$widthBig,$heightBig,$span,false,true,false,true,$price)?>
<?php echo Mage::helper('buyshopconfig')->getProductHover($_product,$this,$widthBig,$heightBig,$widthSmall,$heightSmall,$type,true,true,$price)?>
<!--PRODUCT EOF-->
<?php
if(!$sidebar)
{
if($i==$p_in_row || $count==count($_productCollection))
{
echo '</div>';
$i=0;
}
}
?>
<?php endforeach; ?>
<?php if($sidebar):?></div><?php endif; ?>
<?php endif; ?>
<?php echo $this->getToolbarHtml() ?>
</div>
<?php endif; ?>

Magento - Remove Category from shopping option block from left side bar

Before posting this question I have tried my best to find solution for this. I want to remove category layer from the shopping option block on left sidebar of magento.
http://i59.tinypic.com/35mi22u.jpg
I want to remove the marked option from my left sidebar. I need price and color to appear.
Any help appreciated.
Thanks in Advance.
my app/design/frontend/default/default/template/catalog/layer/view.phtml
<dl id="narrow-by-list">
<?php $_filters = $this->getFilters() ?>
<?php $i=0; foreach ($_filters as $_filter): $i++; ?>
<?php if($_filter->getItemsCount()): ?>
<dt id="filterlabel<?php echo $i;?>"><?php echo $this->__($_filter->getName()) ?></dt>
<dd><?php echo $_filter->getHtml() ?></dd>
<script type="text/javascript" >
<?php if($open == 1): ?>
jQuery('#filterlabel<?php echo $i;?>').each(function(){
jQuery(this).addClass('active');
jQuery(this).toggle(function(){
jQuery(this).removeClass('active').next().slideUp(200);
},function(){
jQuery(this).addClass('active').next().slideDown(200);
})
});
<?php elseif($open == 0): ?>
jQuery('#filterlabel<?php echo $i;?>').each(function(){
jQuery(this).next().hide();
jQuery(this).toggle(function(){
jQuery(this).addClass('active').next().slideDown(200);
},function(){
jQuery(this).removeClass('active').next().slideUp(200);
})
});
<?php endif; ?>
</script>
<?php endif; ?>
<?php endforeach; ?>
</dl>
In your theme catalog.xml file replace
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
with
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml">
<action method="unsetChild"><child>category_filter</child></action>
</block>
This is what I did to remove the “Category” section from my layered navigation
so I wouldnt have any repeat information with the attributes
I wanted in the layered navigation.
go to app/design/frontend/default/default/template/catalog/layer and open up view.phtml for edit.
<dl id="narrow-by-list">
<?php $_filters = $this->getFilters() ?>
<?php $i=0; foreach ($_filters as $_filter): $i++; ?>
<?php if($_filter->getItemsCount()): ?>
<?php if($_filter->getName() != "Category"){ ?>
<dt id="filterlabel<?php echo $i;?>">
<?php echo $this->__($_filter->getName()) ?></dt>
<dd><?php echo $_filter->getHtml() ?></dd>
<?php } endif; ?>
<script type="text/javascript" >
<?php if($open == 1): ?>
jQuery('#filterlabel<?php echo $i;?>').each(function(){
jQuery(this).addClass('active');
jQuery(this).toggle(function(){
jQuery(this).removeClass('active').next().slideUp(200);
},function(){
jQuery(this).addClass('active').next().slideDown(200);
})
});
<?php elseif($open == 0): ?>
jQuery('#filterlabel<?php echo $i;?>').each(function(){
jQuery(this).next().hide();
jQuery(this).toggle(function(){
jQuery(this).addClass('active').next().slideDown(200);
},function(){
jQuery(this).removeClass('active').next().slideUp(200);
})
});
<?php endif; ?>
</script>
<?php endif; ?>
<?php endforeach; ?>
</dl>
After trying and fiddling with the code I managed to solve my problem.
Goto app/design/frontend/default/default/template/catalog/layer/view.phtml
Change:
<dt id="filterlabel<?php echo $i;?>"><?php echo $this->__($_filter->getName()) ?></dt>
to
<dt id="filterlabel<?php echo $i;?>"><?php if ($_filter->getName() != 'Category'): {?><?php echo $this->__($_filter->getName()) ?><?php } endif; ?></dt>
Here above I removed just the label 'Category' that is displayed in sidebar.
After that Goto app/design/frontend/default/default/template/catalog/layer/filter.phtml
Change:
<?php foreach ($this->getItems() as $_item): ?>
<li>
<?php if ($_item->getCount() > 0): ?>
<?php echo $_item->getLabel() ?>
<?php else: echo $_item->getLabel() ?>
<?php endif; ?>
<?php if ($this->shouldDisplayProductCount()): ?>
<!-- (<?php echo $_item->getCount() ?>)-->
<?php endif; ?>
</li>
<?php endforeach ?>
to
<?php foreach ($this->getItems() as $_item): ?>
<?php if ($this->getName() != 'Category'): {?>
<li>
<?php if ($_item->getCount() > 0): ?>
<?php echo $_item->getLabel() ?>
<?php else: echo $_item->getLabel() ?>
<?php endif; ?>
<?php if ($this->shouldDisplayProductCount()): ?>
<!-- (<?php echo $_item->getCount() ?>)-->
<?php endif; ?>
</li>
<?php } endif; ?>
<?php endforeach ?>
Here I removed the list that comes inside the Category layer.

How to display Option List in wishlist sidebar magento

How to display Option List in wishlist sidebar magento?
I use this code!
However, it is not working. Thanks in advance.
<?php if ($_options = $this->getOptionList()):?>
<div class="truncated">
<div class="truncated_full_value">
<dl class="item-options">
<?php foreach ($_options as $_option) : ?>
<dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
<dd>
<?php if (is_array($_option['value'])): ?>
<?php echo nl2br(implode("\n", $_option['value'])) ?>
<?php else: ?>
<?php echo $_option['value'] ?>
<?php endif; ?>
</dd>
<?php endforeach; ?>
</dl>
</div>
<?php echo $this->__('Details') ?>
</div>
<?php endif; ?>
try this:
<?php $options = $this->getOptionList(); ?>
<?php if ($options): ?>
<div class="truncated">
<div class="truncated_full_value">
<div class="item-options">
<p><?php echo $this->__('Options Details'); ?></p>
<dl>
<?php foreach ($options as $option): ?>
<dt><?php echo $this->escapeHtml($option['label']) ?></dt>
<dd>
<?php if (is_array($option['value'])): ?>
<?php echo nl2br(implode("\n", $option['value'])) ?>
<?php else: ?>
<?php echo $option['value'] ?>
<?php endif; ?>
</dd>
<?php endforeach; ?>
</dl>
</div>
</div>
<?php echo $this->__('View Details') ?>
</div>
<?php endif ?>

count subcategory of current category in magento

magento,in if statement im using a condition for two option, first one is current category has zero sub category and second one is current category has more than zero subcategory, but this condition is not working with this code
<?php $helper = $this->helper('catalog/category') ?>
<?php $categories = $this->getStoreCategories() ?>
<?php if (count($categories) > 0): ?>
<?php $_filters = $this->getFilters() ?>
<?php foreach ($_filters as $_filter): ?>
<?php if($_filter->getName() == 'Brand' || $_filter->getName() == 'Category' || $_filter->getName() == 'Store' || $_filter->getName() == 'Price' ): ?>
<?php if($_filter->getItemsCount()): ?>
<dt><div style="background-color:#cdcdcd;padding:4px;border-radius:3px;"><?php echo $this->__($_filter->getName()) ?></div></dt>
<dd><div style="max-height:150px;overflow:auto;padding-top:5px;"><?php echo $_filter->getHtml() ?></div></dd>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php else : ?>
<?php $_filters = $this->getFilters() ?>
<?php foreach ($_filters as $_filter): ?>
<?php if($_filter->getItemsCount()): ?>
<dt>
<div style="background-color:#cdcdcd;padding:4px;border-radius:3px;"><?php echo $this->__($_filter->getName()) ?></div>
<?php if ($removeUrl = Mage::helper('layerednavigation')->getRemoveUrl($_filter)): ?>
<a class="btn-remove" href="<?php echo $removeUrl ?>" title="<?php echo $this->__('Clear All') ?>"><?php echo $this->__('Clear All') ?></a>
<?php endif ?>
</dt>
<dd><div style="max-height:150px;overflow:auto;padding-top:5px;"><?php echo $_filter->getHtml() ?></div></dd>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
</dl>
<script type="text/javascript">decorateDataList('narrow-by-list')</script>
<?php endif; ?>
ckeck its first statement and give me solution
Hello check below code may be help you
<?php
$layer = Mage::getSingleton('catalog/layer');
$_category = $layer->getCurrentCategory();
$currentCategoryId= $_category->getId();
$children = Mage::getModel('catalog/category')->getCategories($currentCategoryId);
$countSubcategory=0;
foreach ($children as $category)
{
$countSubcategory++;
}
echo $countSubcategory;
?>

Magento: Can't get categories children

For some reason this code is returning NULL when trying to get a categories subcategories.
<?php var_dump($_category->getChildrenCategories()); ?>
Here is the full code from a .phmtl file.
<ul id="nav_vert">
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php if ($_category->getIsActive()) { ?>
<?php $open = $this->isCategoryActive($_category); ?>
<?php $potential = $_category->hasChildren(); ?>
<li><a href="<?php echo $this->getCategoryUrl($_category); ?>"<?php if($open) { echo ' class="open"'; } ?><?php if($potential) { echo ' class="potential"'; } ?> ><?php if($potential&&$open) { echo 'v '; } elseif($potential) { echo '> '; }else{ echo ' '; }?><?php echo $_category->getName();?></a>
<?php if ($open && $potential): ?>
<?php var_dump($_category->getChildrenCategories()); ?>
<ul>
<?php foreach ($_category->getChildrenCategories() as $subcategory): ?>
<?php $subCat = Mage::getModel('catalog/category')->load($subcategory); ?>
<?php $open = $this->isCategoryActive($subCat); ?>
<?php $potential = $subCat->hasChildren(); ?>
<li><a href="<?php echo $this->getCategoryUrl($subCat); ?>"<?php if($open) { echo ' class="subopen"'; } ?><?php if($potential) { echo ' class="potential"'; } ?><?php if(!$potential&&$open) { echo ' class="final"'; } ?> ><?php if($potential&&$open) { echo ':: '; } elseif($potential) { echo '> '; }?><?php echo $subCat->getName(); ?> (<?php echo $subCat->getProductCount(); ?>)</a>
<?php if ($open && $potential): ?>
<ul>
<?php foreach ($subcategory->getChildrenCategories() as $subsubcategory): ?>
<?php $subsubCat = Mage::getModel('catalog/category')->load($subsubcategory); ?>
<?php $open = $this->isCategoryActive($subsubCat) ?>
<li><a href="<?php echo $this->getCategoryUrl($subsubCat); ?>" <?php if($open) { echo ' class="final"'; } ?>><?php echo $subsubCat->getName(); ?> (<?php echo $subsubCat->getProductCount(); ?>)</a></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</li>
<?php } ?>
<?php endforeach ?>
</ul>
This line always returns true
<?php $potential = $_category->hasChildren(); ?>
And I know that the category has children.
Can anyone suggest why this doesn't work?
This is how I place the phtml in the page:
<reference name="left">
<block type="catalog/navigation" name="catalog.vertnav" template="catalog/navigation/vert_nav.phtml" before="-" />
</reference>
Magento version 1.5.1.0
Try using $_category->getChildren() (instead of $_category->getChildrenCategories() )
Have an easy day,
Pesach
You might also like to try this,
foreach ($_category->getCategories($_category) as $subcategory):
getCategories() is a more complex form but it allows you more control too. By specifying a recursion level you can retrieve not just the children but grand-children too...
Try with this code,
$this->getCurrentCategory()->getChildrenCategories()
Hope this helps
<?php $helper = $this->helper('catalog/category') ?>
<?php $categories = $this->getStoreCategories() ?>
<?php foreach($categories as $category): ?>
<?php $subcategories = $category->getChildren() ?>
<?php foreach($subcategories as $subcategory): ?>
<?php $subsubcategories = $subcategory->getChildren() ?>
<?php foreach($subsubcategories as $subsubcategory): ?>
<?php endforeach; ?><!-- end foreach subsubcategories -->
<?php endforeach; ?><!-- end foreach subcategories -->
<?php endforeach; ?><!-- end foreach categories -->
This is the basic idea behind extracting children categories.
So accordingly you can work on it.

Resources