We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36446
    • 184 Posts
    Hi Forum!
    I am trying to achieve the following:

    I have a website with products on it. I want to show my visitors where they can buy these products in stores. Each Product can be bought in different stores. Now - I created some ressources for my products e.G.:

    PRODUCTS:
    Product 1
    Product 2
    Product 3

    and some stores
    STORES:
    Store 1
    Store 2
    Store 3

    Now the stores should be assigned to multiple products and it should be possible to assign multiple stores to products. E.G. Product 1 can be bought in Store 1 and 3 - Product 2 can be bought in Store 2,3 and so on.

    I figured that i could use the TV "Ressource List" for this to assign ressources to each other but unfortunately this is not working because i can only select ONE Item in the ressource list TV. Does anyone have a suggestion on how this could be done? For instance in enabling the ressource list to be multiselect. Thanks for your hints!
      https://www.beautyislife-shop.de - premium make-up!
      https://www.topsterne.de - sell it here!
      ---------------------------------------------------------
      • 36446
      • 184 Posts
        https://www.beautyislife-shop.de - premium make-up!
        https://www.topsterne.de - sell it here!
        ---------------------------------------------------------
        • 3749
        • 24,544 Posts
        What you have is a database design problem. You have a many-to-many relationship between products and stores. I don't think a multi-select TV is going to be a good solution in the long run. As the number of stores and products grows, it's going to be more and more difficult (and *very* slow) to display all the products for one store or all the stores for one product.

        What you need is a custom database table for an object called productStores. Each record will have two fields: 'product_id' (containing the ID of a product -- usually the ID of the resource for that product) and 'store_id' (usually the ID of the resource for that store).

        Now, in a single database query you can say 'get all records for this store' -- that will give you all the products the store sells. Or, you can say 'get all records for this product; -- that will give you all the stores that carry the product.

        Trying to do the same thing with TVs is very slow and cumbersome unless you have very few stores and very few products.
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 36446
          • 184 Posts
          Hey BobRay!
          Thank you for answering my question. However the solution with a multiselect tv seems to be very convenient for the client - he just needs to select at which store the products are sold.
          We are talking about prox. 20 Products at about 50 stores.

          However - your solution seems to be the way to go - is there an easy way to implement this, so that an admin can edit the databasetable? thanks again for your help!

            https://www.beautyislife-shop.de - premium make-up!
            https://www.topsterne.de - sell it here!
            ---------------------------------------------------------
            • 4172
            • 5,888 Posts
            also possible with tagger and a special tagger-group.

            give each store one unique tag (the store-name, for example)

            Then they can select the related stores at the product-page with tagger and you can select the related ids with the

            TaggerGetRelatedWhere - snippet.
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 3749
              • 24,544 Posts
              I'm afraid I don't know any easy way to do it. The solution I suggested would require some custom code as well as the development of a front-end form or CMP to let the client enter the data.

              Tagger is an interesting idea, though, you might give that a try. It does create a custom DB table for you and I believe it has a UI for entering data.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting