Show attributes and supplier on the product page

LiteCart Fan
Från Germany
Medlem sedan apr. 2024

Hi, 

Is there a way to show attributes and supplier on the product page? 

I did not find a page which displays attributes or supplier at all...

Thx.

tim
Founder
Från Sweden
Medlem sedan maj 2013
tim

We don't have a current way. Ideas are welcome. Suppliers was intended for administration and addons. Attributes is used for category filters.
In 3.0 you will have the option to autogenerate technical data from attributes.

Here is something to play with.

var_dump(reference::product($product_id)->supplier->name);
var_dump(reference::product($product_id)->attributes);

https://www.litecart.net/en/wiki/products
https://www.litecart.net/en/wiki/attributes
https://www.litecart.net/en/wiki/references

LiteCart Fan
Från Germany
Medlem sedan apr. 2024

Hi, thanks for the tips.
The output of the manufacturer works with
echo reference::product($product_id)->supplier->name;

How can you access attributes in the same way?

The background is that a number of necessary fields are missing and we are trying to solve this via supplier and attributes.  To give a concrete example: the "manufacturer" of a work of art is the artist, but there is often also the affiliation to a collection of works of art ("portfolio") or a publisher (supplier), which should also be specified and searchable.  We do not have delivery codes, but we do, for example, have various dimensions (picture size, sheet size, frame size).  If we solve this via attributes, that would be ok - but you should include examples of evaluations in the documentation.

tim
Founder
Från Sweden
Medlem sedan maj 2013
tim

That was the other example:
var_dump(reference::product($product_id)->attributes);
That will show you the contents of the variable. From there you should be able to work out what you need.

foreach (reference::product($product_id)->attributes as $attribute) {
   ...
}

LiteCart Fan
Från Germany
Medlem sedan apr. 2024

Difficult for me as a layman ;-)
With var_dump(reference::product($product_id)->attributes); 

I get an array:


  ["1-1"]=> array(8) {
    ["id"]=> int(8)
    ["product_id"]=> int(9)
    ["group_id"]=> int(1)
    ["value_id"]=> int(1)
    ["custom_value"]=> string(0) ""
    ["code"]=> string(7) "Condition"
    ["group_name"]=> string(7) "Condition"
    ["value_name"]=> string(8) "Flawless"
  }
}```

With

```foreach (reference::product($product_id)->attributes as $attribute) {
  echo functions::escape_html($attribute);
}```

Only "Array" is returned

How do I get the output "Condition: flawless"?
tim
Founder
Från Sweden
Medlem sedan maj 2013
tim

Yes, var_dump shows you the contents of the variable. From there you will know the names of the data you like to address.

Try this:


  echo $attribute['group_name'] .': '. $attribute['value_name'];
}```
LiteCart Fan
Från Germany
Medlem sedan apr. 2024

Thanks. This is working. We just added a paragraph like this:


  echo '<b>'.$attribute['group_name'] .':</b> '. $attribute['value_name'] .' '. $attribute['custom_value'];
} ```

Also the technical data display is working very well. Good job!
tim
Founder
Från Sweden
Medlem sedan maj 2013
tim

Well done :)

Du
Denna webbplats använder inga kakor och ingen spårningsteknik från tredje part . Vi tror att vi kan göra det bättre än andra och tänker verkligen på din integritet.