Last active
April 11, 2017 21:40
-
-
Save lsolesen/cf1f7e3c95c5f806a9361ad6ac933e08 to your computer and use it in GitHub Desktop.
Shoporama - getting attributes for a product
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<{assign var="profile" value=$product->getProfile()}> | |
<{assign var="attr" value=$profile->getAttributeList()}> | |
<{assign var="attributes" value=""}> | |
<{assign var="variant" value=""}> | |
<{section name="j" loop=$attr}> | |
<{if $attr[j]->getIsVariant() && $attr[j]->getDataType() == "valuelist"}> | |
<{assign var="values" value=$attr[j]->getValues()}> | |
<{section name="k" loop=$values}> | |
<{if $product->getInStock($attr[j]->getAttributeId(), $values[k]->getAttributeValueId()) > 0}> | |
<{assign var="temp" value=$values[k]->getVal()|escape}> | |
<{assign var="variant" value="$variant $temp"}> | |
<{/if}> | |
<{/section}> | |
<{else}> | |
<{assign var="values" value=$attr[j]->getValues()}> | |
<{* Jeg kan ikke få attr til at returnere noget *}> | |
<{* Hvis den gjorde det, vil jeg tro, at jeg kunne få den til kun at hente attributter på produktet *}> | |
<{* og hvis den gjorde - hvordan kunne jeg så få den ind i en variabel? *}> | |
<{attr name=$attr[j]->getName()}> | |
<{* $attributes ender med at få alle de mulige attributter - ikke kun dem på produktet *}> | |
<{section name="l" loop=$values}> | |
<{assign var="temp" value=$values[l]->getVal()|escape}> | |
<{assign var="attributes" value="$attributes $temp"}> | |
<{/section}> | |
<{/if}> | |
<{/section}> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Det kunne fx være ret fedt, hvis
$product->getAttributes()
kun returnerede de attributter, der var sat på det aktuelle produkt.