Magento get the root category url - magento

I'm a Magento newbie.
I've customized the top navigation bar and now is something like this:
HOME CATALOG CMS_LINK CMS_LINK CMS_LINK
For the HOME link and the CMS_LINK links all it's ok but I would when an user click on the CATALOG will see a page with all categories (subcategories of the root category) in a grid view with category i

As part of the category controller action Magento validates the category against the Mage_Catalog_Helper_Category function canShow().
This will return false against the check against isInRootCategoryList(). This function goes and checks the category's parent ids against the store root category id:
$rootCategoryId = Mage::app()->getStore()->getRootCategoryId();
return in_array($rootCategoryId, $category->getParentIds());
The easiest solution that I can think of for your problem without changing core functionality would be to create a sub category of your root category named "Catalog" which would itself contain all the other categories. You can then set-up this category to not display products and only display a cms block.

Related

Select subcategories based on Main Categories in Joomla

I have a little problem with Joomla admin content. I couldn't find module or how to edit Joomla content categories while creating new article.
Now the categories showing like that:
What I want to do: if admin choose the category like "News", after that he need to choose subcategory:

Magento subcategory display on click parent

I have created my own parent.phtml page in Magento to display a grid view on the home page and it is working.
My question is about clicking a parent category and then displaying all subcategories grid like subcategory.phtml. How do I set my URL which passes the parent id in the URL and redirect to subcategory.phtml? Is this possible?
you can try this http://www.creare.co.uk/magento-subcategories-category-pages. It redirects to page displaying sub-categories along with images on clicking the main category.

Magento : Display all products with their Categories on Home Page

I need to display all the Products assigned to Categories on Home Page of my website like below.
Category A Category B Category C
---------- ----------- ----------
Product A Product B Product C
In CMS > Home Page > Content section I have included the block
{{block type="catalog/product_list" name="homeproduct_list" template="catalog/product/list.phtml"}}
Here catalog/product/list.phtml is the default Magento list.phtml without any modifications.
My products are displayed on Home Page only if I assign any product to a Category as well as Default Category (Root Category)
For ex: Product A is assigned to Default Category (Root) and Categopry A as well
If I assign the product only to a Category (which I want) then it does not show any products on Home Page.
The issue here is not this one How to display ALL PRODUCTS in the homepage? but why is that I have to assign product to Default Category (Root) also in order to display it on home page.
Thanks.
Because when you have look into database table catalog_category_entity it will store all category id like first must be root category/subcategory/subcategory[if] and when you fetch so,you have to first must assign root category then its subcategory
$product->getCategoryIds() it will get all category id please check image

Magento: How can I view product listings from a non-default root category?

Magento seems to magically map sub-categories of the default category to a url. For example, a product listing for category "Tops" is currently accessible at /tops.
I created a new root category for products that I do no want to show in the 'normal' product listings. I created a sub-category in my new non-default, root category. Let's call this subcategory "hidden". When I browse to /hidden I get a 404 error.
I've tried browsing to catalog/category/view/id/10 and I've created a URL rewrite in "URL Rewrite Management". Still getting a 404
How can I get Magento to list products from another root category?
I believe the "Include in Navigation Menu" option under the "General Information" tab is what you're looking for. The category would still need to be in your store root, but would not display in your navigation. A store can only have 1 root category and therefore it's not possible to display categories from another root.
The url is actually created from the "URL Key" field.

Magento sub categories product not display in front site

When i add new product to magento admin & select only sub category not the root category the product will not display in site.
When i go back & assign root category & sub category both it will display. I again go to admin & remove the root category so now product have only sub category as before. still it show on site.
The problem is that i am importing the products from .csv file, so it will only take sub category and the product added to admin but not show in front side.
The category structure is like:
Default category (root category)
- shoes (sub category)
- cloths (sub category)
Thanks in advance.
Are you sure you have added the category as a true sub category, and not another root category on the top level accidentally?
That would have the effect you are talking about.
To make sure you add it as a sub category you first need to click on your root category and then add child category after this is selected.
If your category is already a sub category the product really should show without having to add it to the root which is why I have asked :)

Resources