Thanks for your answer but the problem is not to have access to
product variations, the problem is to access the current product
variation. I can't see no other way to achieve that than alter the
core view.
To be clear a demonstration with demo data, just try to paste the
following within your detail_configurableproduct.html :
<code>
<div>
<h1>Available templates tags in Current product page</h1><br />
<h3>product_id : {{
product.id }}</h3>
<h3>name : {{
product.name }}</h3>
<h3>sku : {{ product.sku }}</h3>
<h3>slug : {{ product.slug }}</h3>
<p><strong>details : </strong>{{ details|as_json }}</p>
<p><strong>st_variations : </strong>{{ st_variations|as_json }}</
p>
<p>But what is the way to access to my current product (my current
variation) ? : {{current_product|as_json}}
</p>
</div>
</code>
Now go to (example with demo data) :
http://127.0.0.1:8000/shop/product/dj-rocks/
http://127.0.0.1:8000/shop/product/dj-rocks-s-b/
if the page your are viewing is a "model", a "parent product",
(
http://127.0.0.1:8000/shop/product/dj-rocks/) you can access relative
variations via details and st_variations tags, it's ok.
But if the page you are viewing is a product variation, a "child
product", you can only access to the model informations, not the
current viewed variation. There is no way to access to the current
slug for example or simply the current object ?!? I just want to know
and display the good slug or sku but it's a pain...
How can i deal with that if i want to display photos attached to the
current variation ?
How logical is it to have one slug in url and another result if i call
the slug tag ?
By the way Is there here any problems relative to google duplicate
content seo problematic ?
I'm working on satchmo for weeks now and i admit that i was a bit
disapointed when i've found that in product/view/__init__.py (+/- line
130)
<code>
if 'ProductVariation' in subtype_names:
selected_options = product.productvariation.unique_option_ids
#Display the ConfigurableProduct that this ProductVariation
belongs to.
product = product.productvariation.parent.product
</code>
The only way i've found is to do the following but if there is a more
elegant solution that doesn't need to modify satchmo core...
<code>
# Clone product object in order to have current product variations
in context (extra_context)
current_product = product
if 'ProductVariation' in subtype_names:
selected_options = product.productvariation.unique_option_ids
#Display the ConfigurableProduct that this ProductVariation
belongs to.
product = product.productvariation.parent.product
subtype_names = product.get_subtypes()
best_discount = find_best_auto_discount(product)
extra_context = {
'product': product,
'current_product' : current_product,
'default_view_tax': default_view_tax,
'sale': best_discount,
'error_message' : errors,
}
</code>
So if someone can answer with a smart solution i'll take it !
Thank's in advance
Franck
On Nov 9, 3:01 pm, Bob Waycott <
bobwayc...@gmail.com> wrote:
> You should be able to access any product-related information via Django's
> related syntax for objects.
>
> I'd suggest pulling up /admin/docs in your store & checking through the
> Model docs there. You should be able to see all the attributes on a
> ProductVariation and walk through the various relations, which you can then
> translate directly to view & template queries.
>