I am displaying all the products from the subcategories of the parent category. I want to exclude the product of the specific subcategory from that parent category product listing page. ex. I have parent category as fruits and its subcategories as mango banana orange i want to display only mango and banana products on the fruits category page not orange products
You can solve this in 2 ways. First one, You can simply un select the product which are not to be displayed in the Fruits page through Manage Product->[required product]->Categories.Here select the Mango and unselect Orange.
And the next one, You can get the Product Collection and through Mage::getModel(catalog/category) you can get the IDs Of all the top categories and child Categories. Asusal the product which is not to be displayed contains the top category ID and its own ID. Here you can give the ID as statically and remove them.
You can add restrictions by category id. Check your category ids and add one if.
$arrayOfCatToBeExc = array(1,3,4);
// for example id of your categories and write one if to check
if(in_array($_product->getCategory(),$arrayOfCatToBeExc){
continue;
}
Related
I am using Laravel Voyager admin panel.
I have a 'products' table where PRODUCT has parent SUBCATEGORY and CATEGORY. I have also made these relationships: 'product-subcategory' and 'product-category'.
So, when I want to add new product, I can choose CATEGORY and SUBCATEGORY from dropdown.
The problem is, SUBCATEGORY dropdown shows all of the subcategories:
I want see the SUBCATEGORIES only from the CATEGORY I choose. (like we get the column names of specified MODEL(for referencing) when we create relationships in voyager)
The reason I want this is to prevent adding product under wrong Category and Subcategory.
Is there a way to achive this? Should I use some JSON in the 'Optional Details' field?
I want put all the products are in children categories in the parent category that contains. Is that posible?
Yes, you must set the parent category as anchor.
To do that select the parent category (from the Catalog -> Manage Categories), and go to Display settings tab. In there, select the value Yes to Is Anchor field.
That will be all.
I'm using layered navigation for a category in my magento store.
But some products have multiple categories.
Say I have a category she. Again I have some other categories like t-shirt, cosmetics etc. A t-shirt may have both t-shirt and she categories. Again a cosmetics item may have both she and cosmetics categories. So when I'm displaying she category page, I want to show t-shirt and cosmetics categories in layered navigation. When user clicking on one of those categories (say t-shirt) it will show all the t-shirt which also fall in she category.
How to do this?
EDIT: Here one thing I need to make clear. she, t-shirt, cosmetics all are independent categories. none are sub category of another.
This is a Magento feature, if it doesn't work it's because you have deactivate something in your code that break this functionnality.
This should work as a normal filter with name = 'cat' and value = category ids.
Best Regards,
how to move products from subcategory to its root category with out editing each product? Currently root category doesn't contain any product and subcategory contains 58 Products. I need to delete the subcategory and move its products to root category. Any help will be greatly appreciated.
This thread on SO might help if you are determined to do it programmatically;
Copy and Paste Category in Magento
I have to say, for only 58 products I would just spend 10 minutes and do it in the admin interface personally. For completeness here's how that's done;
You'd go into Catalogue->Manage Categories and then click on your root category to edit it. The go into the Category Products tab and hit the 'Reset Filter' button to display all the products. Select the ones you want and then Save the Category and delete the sub category.
Im trying to add a sort by "Category" within the product listings sort order toolbar. This way when a user clicks a top category (lets say hardware) and sorts on Category, all the same products types are listed next to each other by category id.
Does anyone have a clue on how to make this work? Thanks in advance!