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.
Related
I'm trying to change the order of specific categories using a php script. The script below runs fine, and I'm seeing the position change values in catalog_category_entity, but order is unaffected in the admin, and in the front.
Please use drag and drop from admin
And reindex than flush cache
are you using your script like this ?
<?php
$_categories = $this->getStoreCategories();
?>
<?php foreach ($_categories as $_category) : ?>
<li class="<?php if($_category->getId() == $this->getCurrentCategoryId()) echo "active"; ?>">
<?php echo $_category->getName(); ?>
</li>
<?php endforeach; ?>
if not use it like this.
I am trying to add a homepage link to the main menu of Magento. I have modified top.phtml in my template/catalog/navigation and added the line
<li>
<?php echo $this->__('Home'); ?>
</li>
between the <ul>'s but it doesn't work?
Try
<li>
<?php echo $this->__('Home'); ?>
</li>
Then flush cache if any
Try using this. It will return the base url of your site.
<?php echo Mage::getBaseUrl(); ?>
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>
On a magento site, we've got one menu where we would like to always show all the products below a parent node, let's say we have got
Root
- category 1
- category 2
---- subcategory 2-1
---- subcategory 2-2
When clicking on category 2, we would like to see all products assigned to category2, 2-1 and 2-2. When clicking on Root, it should show ALL the products of the store. However, when selecting category1 from within the other sections of the store, we would like to have a default behaviour.
Normally, we would just assign a product to various categories - but as we only want this behaviour on one single section of the site, I'm not sure how to handle this.
Any ideas?
Thanks in advance.
You can use the "Anchor" attribute of a category to achieve this, this setting controls how Magento 'rolls up' products from categories below the one it's applied to and in doing so also sets a scope for layered navigation controls (if you are using them).
To work as described you'll need to tick/untick the "Is Anchor" box on each child category under the parent appropriately.
Go to Catalog > Manage Catagories > Select a category > Display Settings > Is Anchor? (tick)
To get the behaviour you're after you'll need to set the "Is Anchor" box as follows:
Root - tick
- category 1 - untick
- category 2 - tick
-- foreach child of category 2 - tick
Then reindex anything category related.
Display top level and all sub categories :
$collection= Mage::helper('catalog/category');
$categories = $collection->getStoreCategories();
$currentCategory = Mage::registry('current_category');
<ul>
<?php foreach($categories as $category): ?>
<li><a href="<?php echo $collection->getCategoryUrl($category) ?>">
<?php echo $category->getName() ?>
</a>
<?php $category = Mage::getModel('catalog/category')->load($category->getId()) ?>
<?php $subCategory = $category->getChildrenCategories() ?>
<?php if(count($subCategory > 0)): ?>
<ul>
<?php foreach($subCategory as $_subCategory):) ?>
<li>
<a href="<?php echo $collection->getCategoryUrl($_subCategory) ?>">
<?php echo $_subCategory->getName() ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
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.