Hello Spree community, I realize this is a very old post and lots of things
have probably changed. For one, in the current version of this extension I
don't see any "plug in" that is created. Matteo's example seems like a good
start but it doesn't work. I'd really like to use this extension so does
anyone have an updated example of how they made the view to show the
related products?

Thanks for any help,

Steven


On Monday, November 21, 2011 2:40:24 PM UTC-6, AnthonyD wrote:

I was able to figure it out. Using the related products plug in.

I just called in the partial that was created when the extension was
created. Didnt realize it

On Nov 18, 11:51 am, AnthonyD wrote:
did you modify your products_controller_decorator to accept a relation
type paramater in the show action? I tried something similar to what
you have posted and i get a error.

undefined method `related' for #<Product:0x0000010751bf00>

relatedis the name of the relation I have set up in the back end.

On Nov 18, 6:13 am, matteo folin wrote:






In a spree 0.60 project I add this code overriding "app/views/products/
show.html.erb" :
<div id="related-products">
<% RelationType.all.each do |rt| %>
<% if (relateds = @product.send(rt.name.downcase)).empty? %>
<%= "#{t('product_has_no').capitalize} #{t(:related_products)}"
%>
<% else %>
<span class="title"><%= t(:related_products) %></span>
<ul>
<% relateds.each do |r| %>
<li class="related-product">
<%= link_to mini112_image(r), product_path(r) %>
</li>
<% end %>
</ul>
<% end %>
<% end %>
</div>
You must adapt this for your project, but this the idea.
If you are on 0.70.x it would be better add this as a partial via
Deface override.
On 17 Nov, 18:54, AnthonyD wrote:

I am using the official spreerelatedproductsextension. It is all
installed. I am creating product relations but I do not see the
relatedproductson my product description page.With further
investigation I noticed there is nothing on my product description
page that calls inrelatedproducts.
Does anyone know how I can go about addingrelatedproductsto the
product description page?
--
You received this message because you are subscribed to the Google Groups "Spree" group.
To view this discussion on the web visit https://groups.google.com/d/msg/spree-user/-/MJHAZlxc7oYJ.
To post to this group, send email to spree-user@googlegroups.com.
To unsubscribe from this group, send email to spree-user+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.

Search Discussions

  • Niklas Oppermann at May 28, 2013 at 2:41 pm
    Hi, just had the same issue and made this workaround. It's probably ugly
    but works for me.

    <ul>
    <% @product.relations.each do |relation| %>
       <% related_product = Spree::Product.find_by_id( relation.related_to_id )%>
         <li class="related-product">
           <%= link_to related_image(related_product), product_path(
    related_product) %>
         </li>
       <% end %>
    </ul>

    Hope it helps!
    On Friday, January 11, 2013 12:18:22 AM UTC+5:30, Steven Southard wrote:

    Hello Spree community, I realize this is a very old post and lots of
    things have probably changed. For one, in the current version of this
    extension I don't see any "plug in" that is created. Matteo's example seems
    like a good start but it doesn't work. I'd really like to use this
    extension so does anyone have an updated example of how they made the view
    to show the related products?

    Thanks for any help,

    Steven


    On Monday, November 21, 2011 2:40:24 PM UTC-6, AnthonyD wrote:

    I was able to figure it out. Using the related products plug in.

    I just called in the partial that was created when the extension was
    created. Didnt realize it

    On Nov 18, 11:51 am, AnthonyD wrote:
    did you modify your products_controller_decorator to accept a relation
    type paramater in the show action? I tried something similar to what
    you have posted and i get a error.

    undefined method `related' for #<Product:0x0000010751bf00>

    relatedis the name of the relation I have set up in the back end.

    On Nov 18, 6:13 am, matteo folin wrote:






    In a spree 0.60 project I add this code overriding
    "app/views/products/
    show.html.erb" :
    <div id="related-products">
    <% RelationType.all.each do |rt| %>
    <% if (relateds = @product.send(rt.name.downcase)).empty? %>
    <%= "#{t('product_has_no').capitalize} #{t(:related_products)}"
    %>
    <% else %>
    <span class="title"><%= t(:related_products) %></span>
    <ul>
    <% relateds.each do |r| %>
    <li class="related-product">
    <%= link_to mini112_image(r), product_path(r) %>
    </li>
    <% end %>
    </ul>
    <% end %>
    <% end %>
    </div>
    You must adapt this for your project, but this the idea.
    If you are on 0.70.x it would be better add this as a partial via
    Deface override.
    On 17 Nov, 18:54, AnthonyD wrote:

    I am using the official spreerelatedproductsextension. It is all
    installed. I am creating product relations but I do not see the
    relatedproductson my product description page.With further
    investigation I noticed there is nothing on my product description
    page that calls inrelatedproducts.
    Does anyone know how I can go about addingrelatedproductsto the
    product description page?
  • Niklas Oppermann at May 28, 2013 at 2:53 pm
    Oh, and the related_image refers to a custom image size i have.
    small_image, thumb_image etc are the standard sizes i believe.
    On Tuesday, May 28, 2013 8:11:28 PM UTC+5:30, Niklas Oppermann wrote:

    Hi, just had the same issue and made this workaround. It's probably ugly
    but works for me.

    <ul>
    <% @product.relations.each do |relation| %>
    <% related_product = Spree::Product.find_by_id( relation.related_to_id )%>
    <li class="related-product">
    <%= link_to related_image(related_product), product_path(
    related_product) %>
    </li>
    <% end %>
    </ul>

    Hope it helps!
    On Friday, January 11, 2013 12:18:22 AM UTC+5:30, Steven Southard wrote:

    Hello Spree community, I realize this is a very old post and lots of
    things have probably changed. For one, in the current version of this
    extension I don't see any "plug in" that is created. Matteo's example seems
    like a good start but it doesn't work. I'd really like to use this
    extension so does anyone have an updated example of how they made the view
    to show the related products?

    Thanks for any help,

    Steven


    On Monday, November 21, 2011 2:40:24 PM UTC-6, AnthonyD wrote:

    I was able to figure it out. Using the related products plug in.

    I just called in the partial that was created when the extension was
    created. Didnt realize it

    On Nov 18, 11:51 am, AnthonyD wrote:
    did you modify your products_controller_decorator to accept a relation
    type paramater in the show action? I tried something similar to what
    you have posted and i get a error.

    undefined method `related' for #<Product:0x0000010751bf00>

    relatedis the name of the relation I have set up in the back end.

    On Nov 18, 6:13 am, matteo folin wrote:






    In a spree 0.60 project I add this code overriding
    "app/views/products/
    show.html.erb" :
    <div id="related-products">
    <% RelationType.all.each do |rt| %>
    <% if (relateds = @product.send(rt.name.downcase)).empty? %>
    <%= "#{t('product_has_no').capitalize} #{t(:related_products)}"
    %>
    <% else %>
    <span class="title"><%= t(:related_products) %></span>
    <ul>
    <% relateds.each do |r| %>
    <li class="related-product">
    <%= link_to mini112_image(r), product_path(r) %>
    </li>
    <% end %>
    </ul>
    <% end %>
    <% end %>
    </div>
    You must adapt this for your project, but this the idea.
    If you are on 0.70.x it would be better add this as a partial via
    Deface override.
    On 17 Nov, 18:54, AnthonyD wrote:

    I am using the official spreerelatedproductsextension. It is all
    installed. I am creating product relations but I do not see the
    relatedproductson my product description page.With further
    investigation I noticed there is nothing on my product description
    page that calls inrelatedproducts.
    Does anyone know how I can go about addingrelatedproductsto the
    product description page?

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupspree-user @
categoriesrubyonrails
postedJan 10, '13 at 6:58p
activeMay 28, '13 at 2:53p
posts3
users2
websitespreecommerce.com
irc#RubyOnRails

2 users in discussion

Niklas Oppermann: 2 posts Steven: 1 post

People

Translate

site design / logo © 2022 Grokbase