Jump to content

Свойства в кратком описании


Recommended Posts

  • Replies 54
  • Created
  • Last Reply

Top Posters In This Topic

нет, нужно "view/ProductsView.php
Добавить
foreach($products as &$product)
{
$product->variants = array();
$product->images = array();
$product->properties = array();
$product->features = array();
}
$features = $this->features->get_product_options($products_ids);
foreach($features as &$feature)
{
$products[$feature->product_id]->features[] = $feature;
}

Link to post
Share on other sites

/view/ProductsView.php

foreach($products as &$product)
{
$product->variants = array();
$product->images = array();
$product->properties = array();
$product->features = array();
}
$features = $this->features->get_product_options($products_ids);
foreach($features as &$feature)
{
$products[$feature->product_id]->features[] = $feature;
}



/design/default/html/products.tpl

{foreach $product->features as $f} {$f->name} - {$f->value}{/foreach}


Так???
Link to post
Share on other sites

в View.php нужно заменить

foreach($products as &$product)
{
if(isset($product->variants[0]))
$product->variant = $product->variants[0];
if(isset($product->images[0]))
$product->image = $product->images[0];
}


на

foreach($products as &$product){if(isset($product->variants[0]))$product->variant = $product->variants[0];if(isset($product->images[0]))$product->image = $product->images[0];$product->features = array();}$features = $this->features->get_product_options($products_ids);foreach($features as &$feature){$products[$feature->product_id]->features[] = $feature;}
Link to post
Share on other sites

Для main.tpl все правильно.
Там в View.php отдельно для Новых поступлений, Рекомендуемых и Товаров со скидкой надо править. Функции get_featured_products_plugin, get_new_products_plugin, get_discounted_products_plugin.

Link to post
Share on other sites

public function get_featured_products_plugin($params, &$smarty)	{		if(!isset($params['visible']))			$params['visible'] = 1;		$params['featured'] = 1;		if(!empty($params['var']))		{			foreach($this->products->get_products($params) as $p)				$products[$p->id] = $p;			if(!empty($products))			{				// id выбраных товаров				$products_ids = array_keys($products);						// Выбираем варианты товаров				$variants = $this->variants->get_variants(array('product_id'=>$products_ids, 'in_stock'=>true));												// Для каждого варианта				foreach($variants as &$variant)				{					// добавляем вариант в соответствующий товар					$products[$variant->product_id]->variants[] = $variant;				}								// Выбираем изображения товаров				$images = $this->products->get_images(array('product_id'=>$products_ids));				foreach($images as $image)					$products[$image->product_id]->images[] = $image;					foreach($products as &$product)				{					if(isset($product->variants[0]))						$product->variant = $product->variants[0];					if(isset($product->images[0]))						$product->image = $product->images[0];					$product->features = array();				}				$features = $this->features->get_product_options($products_ids);				foreach($features as &$feature)				{					$products[$feature->product_id]->features[] = $feature;				}										}			$smarty->assign($params['var'], $products);					}	}
Link to post
Share on other sites
  • 3 months later...
  • 1 month later...

Примерно так

foreach($products as &$product)

{

$product->variants = array();

$product->images = array();

$product->properties = array();

$product->features = array();

}

$features = $this->features->get_product_options($products_ids);

foreach($features as &$feature)

{

$products[$feature->product_id]->features[] = $feature;

}

productsview.php отредактировал. Изменения с 41-54 строчку. В products.tpl вставил код:

{foreach $product->features as $f}
{$f->name} - {$f->value}
{/foreach}

Сайт: http://magest.bget.ru/ хочу чтобы при наведении на картинку появлялась всплывашка как раз с этими характеристиками. Что я делаю неправильно. Заранее благодарен за любую помощь.

ProductsView.php

Link to post
Share on other sites
  • 1 year later...

 

Если первые 4, то можно что-то вроде этого:

{$n=0}
{foreach}
 {$n=$n+1}
 {if $n<5}
  Выводим свойство
 {/if}
{/foreach}

Мне нужно вывести первые 3 свойства, куда вставить этот код?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...