Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Kent 30 posts 54 karma points
    Jun 21, 2013 @ 18:51
    Kent
    0

    How to create mutually exclusive categories

    Is there a way to create mutually exclusive categories in uCommerce? For example, I have a 'Shoe' product definition. Among the categories for this shoe are 'Mens' and 'Womens'. But a shoe can only be one or the other. So is there a way to ensure that if a user checks off the 'Mens' category that the 'Womens' category is unchecked? Perhaps there is a pipeline or something I can override to add my own logic ? The case cited is just an example; I have other mutually exclusive categories that have 5 or 6 possibilities.

  • Kent 30 posts 54 karma points
    Jun 24, 2013 @ 22:19
    Kent
    0

    bump.

    Still struggling with this one. Looks like there is a SaveProduct pipeline I can hook into, but I still need a way to update the UI (i.e. if both Men's and Women's are checked when the user saves, I can override that in the pipeline, but the UI will still show both as checked). I'd prefer a JavaScript method, but hacking the uCommerce UI looks messy!

  • Jesper Nielsen 141 posts 498 karma points
    Jun 28, 2013 @ 09:58
    Jesper Nielsen
    0

    Hi Kent,

    You can do the data check in the  pipeline, as you sugests. But there is no way to update the UI.

    One possibility would be to ovrewrite the category handling in uCommerce. This is a bit bigger change, but it is possible.

    Yet another option would be to have all the shoes in one category, and have the "Mens"/"Womens" options as a product property. And then have two virtual categories for "Mens shoes" and "Womens shoes".

    The last option would also work pretty well with the soon-to-be-released facettet search.

    Kind regards,

    Jesper

  • Kent 30 posts 54 karma points
    Jun 30, 2013 @ 20:56
    Kent
    0

    Jesper, some clever rearranging of categories has gotten me partially there. First, I created a new category definition called 'CategoryGroup' and added a boolean property to it called 'MutuallyExclusive'. Then I nested my existing categories under some newly created CategoryGroup's (by setting the ParentCategoryId column in the db). Here is a screenshot that shows the category tree on the left and the EditProductCategory view on the right. So now at least there is a visual separation of categories, BUT it does not enforce any sort of mutual exclusivity.

    The next step is to create my own Categories tab so that I can write my own custom logic to enforce mutual exclusivity(via the 'MutuallyExclusive' property on the parent category). Problem now is...how do I modify products programatically? Is there an API to change a product's categories, properties, etc?

  • Jesper Nielsen 141 posts 498 karma points
    Jul 01, 2013 @ 15:24
    Jesper Nielsen
    0

    Hej Kent,

    Yes you can modify the products programmatically.

    Assuming you have a product object in hand, you can:

    Add/remove ProductProperty instances through the "ProductProperties" property. And in the end simply call product.Save().

    The product categories are handled using the CategoryProductRelations property. There is actually a helper method called RemoveCategory(Category) on Product, to help you remove a product from a category. To add it to a category add a new CategoryProductRelation object to the CategoryProductRelations property. (A similar helper method for adding a category is on its way in the near future! :-) ) In the end again simply call product.Save() to save the changes.

    Kind regards,

    Jesper

  • Kent 30 posts 54 karma points
    Jul 03, 2013 @ 20:37
    Kent
    0

    This worked great. Thanks Jesper!

  • Jesper Nielsen 141 posts 498 karma points
    Jul 05, 2013 @ 09:20
    Jesper Nielsen
    0

    Glad iit worked! :-) Happy to help.

    If there is nothing else, could you please mark the question as answered?

    Kind regards,

    Jesper

Please Sign in or register to post replies

Write your reply to:

Draft