Magento: How to filter current category by another category - layered navigation - php

I have a Magento (1.7.0.2) installation with some products inside.
I have two sibling categories (Brand and Clothes).
Brand contains all the brands of the clothes, and clothes have multiple subcategories (shoes, pants, etc.)
I am using layered navigation. When opening a category (lets say "shoes"), I display a list of the brands in the layered navigatin (I wrote some custom code for this).
Here is the problem:
When I click on a brand, I want magento to filter the products by both categories and display matching results.
Since Magento's default functionality is to just display items from the last category clicked, I need to change this.
Does anyone have any ideas how ?

You need to define attributes for that and you don't need to write custom code for that at all. So it would work for you like double structure there where you add a actual matching attribute and a shadow category for that matching attribute.

Related

All categories are not showing in Manage products?

After I click on Edit link in product grid. In categories section I am getting only one category. But I have lots of categories in store.
If I am going to add new product, all categories are showing.
Existing product, If I want to change subcategories. Its just showing only one always for every existing products.
Maybe these categories are not visible in the same storeview that the product is.

why layered navigation shopping option BRAND not working?

I added custom attribute brand and i want that brand to be in layered navigation to filter the products by brand. But as in the attached picture its not create links for brand section and not showing the total number of products for each brand.
First of all you need to goto "Frontend properties" of attributes and set
Use In Layered Navigation to YES.
Also you have to set is Anchor YES for that category.
And also the category should have some products with brand value.

Magento brand page based on attribute

I want to be able to have a page on Magento which will be a sub category of the parent category. This page needs to be a brand page but based on the brand attribute with my configuration.
It will need to work kind of the same way the layered navigation would on a normal category page. However I need the page to only show the brands attribute that are assigned to products within the parent category and all other sub categories with images that I will assign to each attribute.
Once you click on one of the brands it would act the same as clickng the brand on a normal category page in the layered navigation.
I have been looking around for a way to do this but can't seem to find any so hoping someone can help out.
Solution 1:
add a new attribute to categories : brand_to_display where you can
save the brand value
add all products to said categories
find where the product collection is loaded for the category view
and chack if brand to display is set, if so add an
"addAttributeToFilter" on your collection
Solution 2 (better shop performance):
add a new attribute to categories : brand_to_display where you can
save the brand value
add an event listener for saving product data in admin area and before save find the categories that have brand_to_display = product->getBrand() and attach product to said categories

Layered navigation - filter by other categories

Using layered navigation, how can I let customers filter products based on other categories the products appear in?
I'm working on a clothing store that has products organized into categories like this:
Tops
T-Shirts
Dress Shirts
Bottoms
Jeans
Shorts
Swim Wear
Outerwear
Accessories
Belts
Ties
We'd like to add special collections, such as "Winter Collection" or "Interview Attire". These special categories fall under a separate root category (and have an attribute set to special value, so we can differentiate between normal categories and these special ones). All products within these will also be assigned to the main categories.
If a user is browsing the Winter Collection, they should be able to filter based on those main categories. If a jacket exists in the Winter Collection and the Outwear category, we should show Outerwear as an option to filter on. Only relevant categories should appear; for example, we won't have swim suits in the Winter Collection, so the Swim Wear category should not appear.
The idea is that we don't want to duplicate those main categories for each collection - we already know what type of clothing it is (based on the category), so our collections should be aware of that.
How can this be done?
A long-winded solution is to create a new attribute as a multi-select, and populate this with all of your categories. You would then have to go through every product and select all the 'categories' that apply.
The problem with this approach is that in the filters the categories will appear as a flat list, as opposed to a tree structure, e.g:
I think it would be worse than that. I think the filters auto-sort alphabetically?
There may be a plugin to do what you are after.
I was able to figure out a decent solution which mostly works. I'm posting it here in case someone else has a similar question.
The only drawbacks are:
The categories don't display in a tree structure (yet - working on this)
Clicking to remove the category filter backs up the category tree like usual, except it goes all the way to the root, which was unacceptable. My workaround was to make the X icon completely remove the filter instead of going to the parent category.
The Details
First step was to add a new attribute to categories called "special_type". This dropdown allows admins to select whether the category acts as a core category (per my bullet list) or a special "collection".
The next step was to override the functionality inside Mage_Catalog_Model_Layer_Filter_Category::_getItemsData() where $categories is populated. If $this->getLayer()->getCurrentCategory()->getSpecialType() == the default type, I call the original method (return parent::_getItemsData()). Otherwise...
I pass $this->getLayer()->getProductCollection() into a custom method which determines which standard categories this appears in. I use the following filters in my query:
Exclude non-standard categories
Exclude the currently filtered category
Only show the highest-level categories possible
The last two basically allow this functionality: if I'm currently filtering on Tops, only show child categories of Tops and nothing else.
The custom method returns a collection of categories matching my criteria and get assigned to $categories. The rest of the method is left intact.
Hope this helps somebody in a similar situation.

How could I group attributes values in a category in Magento?

I've created a custom attribute in Magento, called 'brand_name' and 'brand_id'
I need in each categories, to show all the "brands" available for this categories.
Example:
I've a Shoes category, in my Shoes category I've products with brand name like 'Louboutin' 'Dior' etc...
I'd like to show in a page those brand, then when clicking on it I'd like to show all product which are from "Louboutin" in category "Shoes"
The last part is simpler I think, however I don't really know how to start but I'm pretty sure Magento provides such functionnality.
Do you know which method could I use to do that?
I have cut and paste for you from here:
Catalog -> Attributes -> Manage Attributes.
Select brand_name
At the bottom make sure Used for Sorting in Product Listing is set to Yes. <- your design theme must support it.
Then over in Catalog -> Manage Categories, select your category that displays your product listing, select the Display Settings tab.
brand_name should be one of the items in the Available Product Listing Sort by multi select. Go down to the next field Default Product Listing sort by, uncheck Use Config Settings and set the dropdown to brand_name.
To make the system default for product listings be sorted by brand_name, go into System -> Configuration -> Catalog ->Frontend and set Product Listing Sort by dropdown to brand_name. Then you can leave the “Use Config Settings” checkbox in Manage Categories checked

Categories