<?php
$_category = $this->getCurrentCategory();
$collection = Mage::getModel('catalog/category')->getCategories($_category->entity_id);
$helper = Mage::helper('catalog/category');
?>
<ul>
<?foreach ($collection as $cat):?>
<?php if($_category->getIsActive()):?>
<?php
$cur_category = Mage::getModel('catalog/category')->load($cat->getId());
$_img = $cur_category->getImageUrl();
?>
<li>
<a href="<?php echo $helper->getCategoryUrl($cat);?>">
<img src="<?php echo $_img?>" title="$cat->getName()"/>
<cite><?php echo $cat->getName();?></cite>
</a>
</li>
<?php endif?>
<?php endforeach;?>
</ul>
Friday, July 29, 2011
Show subcategory in a category page
Wednesday, July 27, 2011
Magento form validation from js
If you want to make the field mandatory then must give the id name same with name and add class="input-text required-entry" then the field automatically validate from the js file.
Monday, July 25, 2011
Change category page layout
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template> </action>
</reference>
in the line 81 under
<catalog_category_default translate="label">
<label>Catalog Category (Non-Anchor)</label>
Friday, July 22, 2011
Magento: Display Categories in Sidebar
Magento: Display Categories in Sidebar
It seems my posts lately are always in relation to solving a problem or answering a question for someone else. If you’re looking for a way to display categories in the sidebar, change category display, or create a category menu then this post is probably for you.
Creating the Block
The first thing you need to do is create a block in your layout. Navigate to /app/design/frontend/default/default/layout/catalog.xml
The first thing in your layout is a definition of the default layout noted by the comment “Default layout, loads most of the pages” depending on where you want to put your category nav (right sidebar, left sidebar, footer, etc) you’ll need to define the block a little differently. I’m going to do it with the left sidebar so you see what’s going on.
<reference name="left">
<block type="catalog/navigation" name="catalog.leftnav"
template="catalog/navigation/left_nav.phtml" />
</reference>
Okay, so what i did was locate the left sidebar which is referenced simply as “left” inside those tags i define my block type and template. The next thing you’ll want to do is create that template file, note that i defined it within /app/design/frontend/default/default/template/catalog/navigation/left_nav.phtml so i will need to create that file.
Creating the Template
Once I’ve created the file, it’s time to put in my code to populate my links automatically of all my categories:
<h2>Browse</h2>
<div class="block">
<ul id="nav_category" class="nav_category">
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php echo $this->drawItem($_category) ?>
<?php endforeach ?>
</ul>
</div>
<?php echo $this->getChildHtml('topLeftLinks') ?>
If you want to take this a step further, you can target subcategories based on current page with this little script
<?php $obj = new Mage_Catalog_Block_Navigation();
$store_cats = $obj->getStoreCategories();
$current_cat = $obj->getCurrentCategory();
$current_cat = (is_object($current_cat) ? $current_cat->getName() : '');
foreach ($store_cats as $cat) {
if ($cat->getName() == $current_cat) {
echo '<li class="current"><a href="'.$this->getCategoryUrl($cat).'">'.$cat->getName()."</a>\n<ul>\n";
foreach ($obj->getCurrentChildCategories() as $subcat)
{
echo '<li><a href="'.$this->getCategoryUrl($subcat).'">'.$subcat->getName()."</a></li>\n";
}
echo "</ul>\n</li>\n";
} else {
echo '<li><a href="'.$this->getCategoryUrl($cat).'">'.$cat->getName()."</a></li>\n";
}
}
?>
Thursday, July 21, 2011
how to get best selling product in magento
Wednesday, July 20, 2011
Wednesday, July 13, 2011
How to show all product in a category page
app\code\core\Mage\Catalog\Block\Product\List\Toolbar.php
find this line near line 228
// we need to set pagination only if passed value integer and more that 0
$limit = (int)$this->getLimit();
now chenge it
$limit = 0;
and it will work.
Saturday, July 9, 2011
Create New category via soap api
$proxy = new SoapClient('http://magentosite/api/soap/?wsdl');
$sessionId = $proxy->login('apiuser', 'apikey');
$newCategoryId = $proxy->call($sessionId,'category.create',array(3,array('name'=>'New openerp','is_active'=>1,'include_in_menu'=>2,'available_sort_by'=>'position','default_sort_by'=>'position')) );
//where 3 is the parent category
Friday, July 8, 2011
How to get newsletter block in the footer
Thursday, July 7, 2011
How to add group in register form
app\design\frontend\base\default\template\customer\form\register.phtml
add following code in the page
<div class="input-box">
<label for="group_id" class="required"><?php echo $this->__('Group') ?><em>*</em></label><br/>
<select name="group_id" id="group_id" title="<?php echo $this->__('Group') ?>" class="validate-group required-entry input-text" />
<?php $groups = Mage::helper('customer')->getGroups()->toOptionArray(); ?>
<?php foreach($groups as $group){ ?>
<option value="<?php print $group['value'] ?>"><?php print $group['label'] ?></option>
<?php } ?>
</select>
<br /><p class="required" style="float:left;">Retailer group require admin authentication </p>
</div>
also change some code in app\code\core\Mage\Customer\controllers\AccountController.php
now replace $customer->getGroupId(); with
if($this->getRequest()->getPost('group_id'))
{
$customer->setGroupId($this->getRequest()->getPost('group_id'));
}
else
{
$customer->getGroupId();
}
How to Setup a Multiple Currency Magento
How to Setup a Dual Currency Magento Shop
Login as admin and select System->Configuration, then select ’Currency Setup’ from GENERAL section,
then select Base currency, Default display currency, allowed currencies (press Control Key and Click the needed currencies) and ’Save Config’
Now come to "System->Manage Currencies’ menu
Click in Import currencies to load the exchange rate(s).
You are done. Visit the frontend and reload (you may need to refresh your cache) to see the drop down added to your product pages.