код из ProductView.php
Код: Выделить всё
// Цвета товара
$self_ids = array();
$self_products = array();
foreach($this->products->get_self_products($product->id) as $p)
{
$self_ids[] = $p->related_id;
$self_products[$p->related_id] = null;
}
if(!empty($self_ids))
{
foreach($this->products->get_products(array('id'=>$self_ids, 'in_stock'=>1, 'visible'=>1)) as $p)
$self_products[$p->id] = $p;
$self_products_images = $this->products->get_images(array('product_id'=>array_keys($self_products)));
foreach($self_products_images as $self_product_image)
if(isset($self_products[$self_product_image->product_id]))
$self_products[$self_product_image->product_id]->images[] = $self_product_image;
$self_products_variants = $this->variants->get_variants(array('product_id'=>array_keys($self_products), 'in_stock'=>1));
foreach($self_products_variants as $self_product_variant)
{
if(isset($self_products[$self_product_variant->product_id]))
{
$self_products[$self_product_variant->product_id]->variants[] = $self_product_variant;
}
}
foreach($self_products as $id=>$s)
{
if(is_object($s))
{
$s->image = &$s->images[0];
$s->variant = &$s->variants[0];
}
else
{
unset($self_products[$id]);
}
}
$this->design->assign('color_products', $self_products);
}
Вот так вывожу в шаблоне
Код: Выделить всё
{* Цвета товара *}
{if $color_products}
{foreach $color_products as $color_product}
{if $color_product->variant->hex_color}
<li><a href="/products/{$color_product->url|escape}" title="{if $product->variant->stock > 0}Нет в наличии{else}В наличии{/if}" style="background: #{$color_product->variant->hex_color}"></a></li>
{/if}
{/foreach}
{/if}
в какую сторону копать?
пару скриншотов чтобы было понятнее
1. https://prnt.sc/gpm50w
2. https://prnt.sc/gpm5ad
3. https://prnt.sc/gpm5fv