using the product specs in the products.rain

ljohnljohn Posts: 4Member
edited August 2018 in Customizations
Hi,

I'm fairly new to lightspeed and to twig, but I'm getting the hang of it.

At the moment I want to customize the standard template that comes with eCom.
In the product grid overview I want to add some specs I had defined for the products. So that certain product features can already be seen in the overview.

here is what I have written in the products.rain:

{% if product.specs %}
   <p>SPECS</p>
   {% for spec in product.specs %}
      <ul>
      {% if spec.value is not empty %}   
            <li>{{ spec.title }}: {{ spec.value }}</li>
      {% endif %}
      </ul>
   {% endfor %}
{% endif%}

I more or less used the same code as in the product.rain to get the spec.title and spec.value. But without success. I'm under the impression that it should be possible to get those values outside of the product.rain, is it not?
Tags:

4 comments

  • JoeyJoey Posts: 172Administrator, Moderator, Lightspeed Staff moderator
    Hi Ljohn,

    Awesome to hear you are getting started with Rain (Twig). The short answer is that the specifications are not availbale on collection (product overview) pages.

    The easiest way to find out which variables are available on the page is by enabling the developers toolbar.

    To enable the toolbar go to the store front (any page) and search for tb/show, the page will refresh and be directed to the home page. You will now see a bar on the bottom of the page, click Template Object to see all available variables for the page you are on.



    Unfortunately this will not resolve the specifications issue but hopefully help with customizing the theme further.

    Let me know if you have any other questions!

    eCom Support Team
    Lightspeed HQ
  • ljohnljohn Posts: 4Member
    Thank you Joey for the tip with the toolbar, that is certainly helpful. I find it confusing, that product.title or product.image is possible but product.specs is not. Isn't it the same object?
  • JoeyJoey Posts: 172Administrator, Moderator, Lightspeed Staff moderator
    Unfortunately not all fields are available everywhere. The reason is that adding all product fields to overview pages would cause a heavy load on the system. Also certain fields cause a higher load on pages, the product specifications is one of them.

    The developer tool will show exactly which fields are available, there is also a help page about Rain Variables which has a full list.
    eCom Support Team
    Lightspeed HQ
  • ljohnljohn Posts: 4Member
    Alright. Thank you, Joey!
Sign In or Register to comment.