Иногда нужно вывести на странице товара ссылку на категорию, в которой находится продукт с отфильтрованными по производителю товарами

Подводные камни, которые нам могут встретиться:

  • SEO URL категории
  • наличие\отсутствие картинки производителя

 

1.Открываем includes/modules/product_info.php

Находим


$cat_query = vamDBquery("SELECT
categories_name
FROM ".TABLE_CATEGORIES_DESCRIPTION."
WHERE categories_id='".$current_category_id."'
and language_id = '".(int) $_SESSION['languages_id']."'"
);
$cat_data = vam_db_fetch_array($cat_query, true);

$manufacturer_query = vamDBquery("select m.manufacturers_id, m.manufacturers_name, m.manufacturers_image, mi.manufacturers_url from " . TABLE_MANUFACTURERS . " m left join " . TABLE_MANUFACTURERS_INFO . " mi on (m.manufacturers_id = mi.manufacturers_id and mi.languages_id = '" . (int)$_SESSION['languages_id'] . "'), " . TABLE_PRODUCTS . " p where p.products_id = '" . $product->data['products_id'] . "' and p.manufacturers_id = m.manufacturers_id");
$manufacturer = vam_db_fetch_array($manufacturer_query,true);

$info->assign('CATEGORY', $cat_data['categories_name']);
$info->assign('MANUFACTURER',$manufacturer['manufacturers_name']);

меняем на


$cat2_query = vamDBquery("SELECT categories_id, categories_url FROM ".TABLE_CATEGORIES." WHERE categories_id='".$current_category_id."'");
$cat2_data = vam_db_fetch_array($cat2_query, true);
/*Узнаем, есть ли у категории СЕО УРЛ*/
$cat_query = vamDBquery("SELECT
categories_name, categories_id
FROM ".TABLE_CATEGORIES_DESCRIPTION."
WHERE categories_id='".$current_category_id."'
and language_id = '".(int) $_SESSION['languages_id']."'"
);
$cat_data = vam_db_fetch_array($cat_query, true);

$manufacturer_query = vamDBquery("select m.manufacturers_id, m.manufacturers_name, m.manufacturers_image, mi.manufacturers_url from " . TABLE_MANUFACTURERS . " m left join " . TABLE_MANUFACTURERS_INFO . " mi on (m.manufacturers_id = mi.manufacturers_id and mi.languages_id = '" . (int)$_SESSION['languages_id'] . "'), " . TABLE_PRODUCTS . " p where p.products_id = '" . $product->data['products_id'] . "' and p.manufacturers_id = m.manufacturers_id");
$manufacturer = vam_db_fetch_array($manufacturer_query,true);

$info->assign('CATEGORY', $cat_data['categories_id']);
$info->assign('MANUFACTURER',$manufacturer['manufacturers_name']);
if ($cat2_data['categories_url'] !=''){$categ = $cat2_data['categories_url'].'?';}else{$categ = 'index.php?cat='.$cat_data['categories_id'].'&'; }
/*В зависимости от наличия\отсутствия СЕО УРЛ категории, формируем адрес*/
$info->assign('MANUFACTURER_URL',$categ.'filter_id='.$manufacturer['manufacturers_id']);
if ($manufacturer['manufacturers_image'] != ''){$manufacturer_image = DIR_WS_IMAGES.$manufacturer['manufacturers_image'];}
/*Если у производителя есть картинка, назначаем метку*/
$info->assign('MANUFACTURER_IMAGE',$manufacturer_image);

2. Открываем templates/ВАШ_ШАБЛОН_VAMSHOP/module/product_info/product_info_v1.html

И в нужное место вставляем

{if $MANUFACTURER!=»}Бренд: <a href="{$MANUFACTURER_URL}" title="{$MANUFACTURER}">{if $MANUFACTURER_IMAGE !=»}<img src="{$MANUFACTURER_IMAGE}" alt="{$MANUFACTURER}"/>{else}{$MANUFACTURER}{/if}</a>{/if}

тем самым мы получим ссылку вида site.ru/velosipedi.html?filter_id=11