1

recently we decided to set-up some landingpages for specific keywords. I must say I am not a huge fan of it .. but hey let's give it a try.

Normally I would set-up a CMS Page and write some text maybe add products. But thinking about it I would really like to use (dummy) catgeory pages for it: they have a banner, text block, products etc. ..... and they don't break during upgrades. I set them to anchor = no and include in navigation = no.

Situation: So the only thing I miss and would like to ask: is that I do not want to manually add products to this new category. What I would want to do is to select an already existing category and have this category show the member products of the existing category (dynamically, meaning that if I add products to the existing category they are also added to the new landingpage category).

Similar extensions: I had a look at these extensions that seem to do something similar, but not quite what we are hoping for: https://github.com/tzyganu/rule-products and http://amasty.com/landing-pages.html

Question: how can I create new categories that differ only in the way I select the products. Instead of selecting the products individually, I select an other category (ID) to take the products collection (only) from ....

many thanks, Sean

1

Nice question.
Here is how I would do it.
I would add a new category attribute that is actually a dropdown with all the categories in the catalog. Let's call it Get products from category.
This would establish a link between 2 categories. You can even make it a multiselect attribute if you want in your new category to get products from multiple categories.

Then observe the events:

  • catalog_category_save_after - When the main category is saved, check if there are other categories that use this one in the field Get products from category and add the products to them. Also, if the current category must take products from other categories...get them. Just make sure you don't end up in a cycle. I mean If category A should get the products from category B and category B should get the products from A. In this case you need to remember somewhere the categories involved in the same save process and don't process them twice.
  • catalog_category_delete_before - when deleting a category check if there are categories that have a relation to it through Get products from category and remove from them the products from the main category. Again be careful. You might end up in a cycle.
  • catalog_product_save_after - get the categories of the product and the old categories and check the related categories through Get products from category and add them or remove them from the related categories. I thing I mentioned it before...watch out for cycles.

There could be also an other approach. Instead of using observers you can have a cron that calculates the products from these "fake" categories and you can run it once a day, or when you need it.
Sorry but I don't have code for this. But from my point of view it looks like a nice idea for an extension.

  • ahh thanks Marius. You are always so great on answering question. I want to applaud you for it (clap clap clap. Cheer!) ... you really drive this community. (and I hope you dont mind I found an answer that involves less coding - for me -). THANKS AGAIN – snh_nl Oct 15 '14 at 6:23
  • And just to let you know. I was searching for an answer on Google when I found this extension (dont know why I didnt see it yesterday evening) .... and when I found it I literally rushed back to the question because I was expecting you to already have answered it ... ;) – snh_nl Oct 15 '14 at 6:33
  • @snh_nl. I can't believe I forgot about that extension. Yes it's a really nice one. I did't use it, but investigated on it a bit. I'm not sure it does exactly what you need but it's very close. – Marius Oct 15 '14 at 6:40
1

The ideal would be a combination of

https://github.com/firegento/firegento-dynamiccategory

and

https://github.com/magento-hackathon/layered-landing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.