Output a Product Specification on the Product Page

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
Hi,

Is it possible to output a Product Specification directly from a function rather than going into a loop on the Product Page.

Something like outputProductSpecification("video_url")

At the moment we can only output the Product Specifications in a loop checking each spec in the model.

Cheers
4 years ago
Could you elaborate further? If I understand correctly you are talking about in the product view and how we loop through the Model to output each item?

I don't see how this could be done elsewise, if it were placed in a function(Component) we'll still need to loop through the specification to output them.

If you're just looking to clean up your view you can try placing that section of code in a component but the loop will remain just separated from the original view.

Maybe someone else can share their opinion of how this can be achieved.
4 years ago
I'll explain what we are trying to do then you may be able to suggest the best method rather than me trying to use product specification attributes.

We would like to add extra fields to the product page admin to ouput extra information on the product page front end.

Example 1: add a video field where the admin can input a youtube url, this can then be output on the product page below the full description.

Example 2: add a testimonial field where the admin can input a testimonial, this can then be output on the product page below the full description.

Should we be using product specification attributes for this?

How do we output just one product specification attribute and then remove it from being output in the normal product specification attributes table on the product page front end?

Any help would be much appreciated! :)
4 years ago
You could try using something like this in your view.



if (item.SpecificationAttributeName == "SPEC_ATTR_NAME")
if (item.SpecificationAttributeName != "SPEC_ATTR_NAME")



Display or do not the display the items you would like.
4 years ago
never heard of linq? something like..

var videoUrl = Product.ProductSpecifications.FirstOrDefault(ps => ps.Name == "VideoUrl");

if (videoUrl != null)
    ....
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.