ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Need Help: Relationship between Entries in eCommerce site (Products & Manufacture)

October 10, 2012 9:59pm

Subscribe [4]
  • #1 / Oct 10, 2012 9:59pm

    Tyas

    35 posts

    Hello,

    I really need help. a little bit confusing about channel & related entries.

    I have a channel:
    1. Products
    2. Manufactures

    in products channel i have a relationship entries to manufacture (standard case):

    1. I want to have template to show product channel but only some manufacture. This is sample template of manufacture (karcher): http://new.indoteknik.com/v1/mp_new/karcher
    See Top Vacuum Cleaner categories—> The NILFISK (manufacture) product should not show in this categories or in Top High Pressure Washer—> the MAKITA (product) should not show.

    My code:

    {exp:channel:entries channel="store_manufacture" limit="1" disable="categories|member_data|category_fields"}
      {exp:gwcode_categories entry_id="{entry_id}" depth="2" style="linear"}
       {embed="v1_blok/blok_produk_manufacture_v2" category_id="{cat_id}"}
      {/exp:gwcode_categories}
     {/exp:channel:entries}


    The embed of blok_produk_manufacture_v2

    <div class="ym-g960-9 latar_utama_gradient ym-gr">
    
      {exp:gwcode_categories cat_id="{embed:category_id}" limit="1" style="linear"}
      <div class="header_1"><h2>Top {cat_name}</h2>
    <p>   <div>a href="{path='v1/pk'}/kat/{cat_url_title}">{site_url}themes/site_themes/agile_records/images/more.png</a></div><br />
      </div><br />
      {/exp:gwcode_categories}</p>
    
    <p><br />
      {exp:channel:entries channel="products" category="{embed:category_id}" limit="5" dynamic="no" disable="pagination"}<br />
       {related_entries id="brand_manufacture"}<br />
        {title} {!-- HOW TO SHOW ONLY THE SEGMENT_4 (KARCHER) PRODUCTS --}<br />
       {/related_entries}<br />
       {title}</p>
    
    <p>  {/exp:channel:entries}</p>
    
    <p><br />
    </div>

    really need guidance 😊

  • #2 / Oct 11, 2012 8:23am

    Boyink!

    5011 posts

    I’m still drinking my wake-up coffee and your code mixes categories and relationships - so I’m a bit confused.

    At a high level, if you are in a channel:entries tag pair returning entries from the channel that owns the relationship field (Products) the {related_entries} tag will return the manufacturer that it has been assigned to.  The {related_entries} tag pair will only ever return one result.

    If you are in a channel:entries tag pair that is returning entries from the channel that the relationship field points to (Manufacturers), you need the {reverse_related_entries} tag pair. The {reverse_related_entries} tag pair will return multiple results so is often the handier tag.

  • #3 / Oct 12, 2012 3:25am

    Tyas

    35 posts

    Uppss I know what you mean sir. I have like this http://new.indoteknik.com/v1/mp/karcher.
    I already use that method but still no luck to arrange the manufacture product in categories.

    {exp:channel:entries channel="store_manufacture" dynamic="yes"}
     {reverse_related_entries id="brand_manufacture" category="{embed:category_id}" limit="5"}    
      {title}
    
     {/reverse_related_entries}
    {/exp:channel:entries}

    reverse_related_entries can’t use category=”{embed:category_id}”

    any solution to my page http://new.indoteknik.com/v1/mp_new/karcher

  • #4 / Oct 12, 2012 8:20am

    Boyink!

    5011 posts

    I’m still not following.  Your code is a bit all over the place with add-ons, embeds, etc and I can’t figure out the overall goal.

    Are you just trying to display products by manufacturer:  Or are you trying to display a categorized list of products by manufacturer?  Or i the issue not getting one page per manufacturer with the list of products?

     

     

  • #5 / Oct 12, 2012 3:08pm

    Shane Eckert

    7174 posts

    Hey Guys,

    Sounds like you are in the midst of working some things out here.

    Tyas, can you answer Mike’s most recent inquiry?

    Looking forward to getting this resolved for you Tyas.

    Cheers,

  • #6 / Oct 12, 2012 10:22pm

    Tyas

    35 posts

    I’m still not following.  Your code is a bit all over the place with add-ons, embeds, etc and I can’t figure out the overall goal.

    Are you just trying to display products by manufacturer:  Or are you trying to display a categorized list of products by manufacturer?  Or i the issue not getting one page per manufacturer with the list of products?

    This is the scenario.
    1. First i want to show products by manufacturer (already done like this )
    2. Sometimes a manufacturer have so many products and categories, so i create (manually) in manufacturers channel few categories (product category) related to manufacturer. Ex: karcher—> have vacuum cleaner, high pressure cleaner etc.

    So in order to organise the look of manufacturers front page, i must create categorized list of products by manufacturer, like this http://new.indoteknik.com/v1/mp_new/karcher. the problem is to show categorized list of products by manufacturer (in manufacturers url).

    note: can you see the link, i am in indonesia and have little international bandwidth in my site.

  • #7 / Oct 13, 2012 4:41pm

    Boyink!

    5011 posts

    I think I get it now.  You need three levels of hierarchy:

    Manufacturer
      Category
      Product

    Any reason your manufacturers couldn’t be categories?  And categories then could be subcategories.  And products all assigned into the subcategories.  You could then use Low seg2cat to display a Manufacturer URL without the /category/segment in the URL.

  • #8 / Oct 13, 2012 7:46pm

    Tyas

    35 posts

    I dont think to change the hierarchy to
    Manufaturer
      Category
      Product

    It wont effective ex:
      Karcher (category)—> vacuum cleaner (subcategory)—> product (channel)
      Nilfisk (category)—> vacuum cleaner (subcategory)—> product (channel)

    There will be 2 different vacuum cleaner subcategory. Its better (in my case) to be like this
      Manufacturer (category a)
      Category (category b)
      Product (channel)

    Never try this method, since i always think using manufacturer as channe) most flexible. Other solution or add-ons for my current hierarchy? Or maybe should use sql query manually?
      Manufacturer (channel) <—> Product (channel)
      Product Categories (category)

    Thanks before

  • #9 / Oct 13, 2012 7:53pm

    Boyink!

    5011 posts

    Do you need to see all the vacuum cleaners regardless of manufacturer?  If not, then I dont see any problem if the subcategory is in there >1 time.

    Otherwise I’ve done this type of thing using all relationships and queries or embedded templates.  Products relate to categories which relate to manufacturers.

  • #10 / Oct 15, 2012 8:23pm

    Robin Sowell

    13255 posts

    I think Michael’s right- the easy way is to go with categories for both, rather than related entries.

    That said- your approach is very clever.  It’s already in place and changing to a pure category approach isn’t an option?  Then I think what you’d need is either a reverse related - which doesn’t exist so you’d likely need to custom code it.  If you had the manufacturer’s entry_id and the category id (presumably passed in the url), it wouldn’t be too bad.

    But pure categories will be easier.

    That help clarify at all?  Michael’s pretty much nailed down the options.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases