Автор Тема: Prestashop FAQ - как добавить новое поле к товару  (Прочитано 38070 раз)

03 Июнь 2017, 21:54:07
Ответ #45
  • Старожил
  • ****
  • Сообщений: 259
  • Репутация: +2/-0
  • Сообщество PrestaShop
    • Просмотр профиля
А как добавленное поле в ps_product включить в поисковый индекс?
04 Июнь 2017, 10:14:39
Ответ #46
  • Ветеран
  • *****
  • Сообщений: 16670
  • Репутация: +14630/-5
  • Сообщество PrestaShop
    • Просмотр профиля
В таблице? Или в модуле фильтров?
04 Июнь 2017, 11:07:28
Ответ #47
  • Ветеран
  • *****
  • Сообщений: 86688
  • Репутация: +25428/-0
  • Сообщество PrestaShop
    • Просмотр профиля
Создайте индекс в таблице product.
Измените класс Search.php (также как добавляли новое поле в классе Product.php).
04 Июнь 2017, 11:11:37
Ответ #48
  • Ветеран
  • *****
  • Сообщений: 86688
  • Репутация: +25428/-0
  • Сообщество PrestaShop
    • Просмотр профиля
Включил - в запросе из таблицы ps_cart_rule стоит *
SELECT SQL_NO_CACHE SQL_CALC_FOUND_ROWS
b.*, a.*
FROM `ps_cart_rule` a
LEFT JOIN `ps_cart_rule_lang` b ON (b.`id_cart_rule` = a.`id_cart_rule` AND b.`id_lang` = 1)
WHERE 1 
ORDER BY a.`id_cart_rule` DESC  LIMIT 0, 50

Но я обнаружил много красных надписей - это причины постоянных "тормозов " системы?

1. Еще раз проверьте правильность добавления поля в класс CartRules.
2. Красным выделенны размеры данных.
"Тормоза" определяются по результатам тестирования. Для бд можете проверить лог медленных запросов.
04 Июнь 2017, 11:28:21
Ответ #49
  • Старожил
  • ****
  • Сообщений: 259
  • Репутация: +2/-0
  • Сообщество PrestaShop
    • Просмотр профиля
Цитировать
1. Еще раз проверьте правильность добавления поля в класс CartRules.
Проверил - все в четком соответствии

Но ведь я не смог выполнить п. 5
Цитировать
В файле AdminProductsController.php в методе copyFromPost
потому что в AdminCartRulesController.php нет метода copyFromPost
и далее тоже не смог
Цитировать
в методе initFormInformations
// global informations
потому что в AdminCartRulesController.php нет метода initFormInformations
27 Март 2018, 22:43:46
Ответ #50
  • Новичок
  • *
  • Сообщений: 29
  • Репутация: +0/-0
  • Главное толпами не ходить
    • Просмотр профиля
    • MiMiko

для версии 1.7.3 подойдет данный гайд?
27 Сентябрь 2019, 09:59:55
Ответ #51
  • Новичок
  • *
  • Сообщений: 3
  • Репутация: +0/-0
  • Сообщество PrestaShop
    • Просмотр профиля

для версии 1.7.3 подойдет данный гайд?

Сдается мне, что нет. Не подойдет (
А было бы неплохо
27 Сентябрь 2019, 11:06:10
Ответ #52
  • Ветеран
  • *****
  • Сообщений: 1285
  • Репутация: +13/-1
  • Сообщество PrestaShop
    • Просмотр профиля
Принцип тот-же, так что подходит.
27 Сентябрь 2019, 11:14:38
Ответ #53
  • Модератор
  • Ветеран
  • *****
  • Сообщений: 33325
  • Репутация: +26771/-0
    • Просмотр профиля
для версии 1.7.3 подойдет данный гайд?
Подойдет, только еще нужно вставить новое поле в
/src/PrestaShopBundle/Form/Admin/Product/... в каком табе хотите вывести новое поле, например, ProductInformation.php
/src/PrestaShopBundle/Model/Product/AdminModelAdapter.php
в шаблоне
/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/form.....twig

28 Сентябрь 2019, 11:01:50
Ответ #54
  • Новичок
  • *
  • Сообщений: 3
  • Репутация: +0/-0
  • Сообщество PrestaShop
    • Просмотр профиля
для версии 1.7.3 подойдет данный гайд?
Подойдет, только еще нужно вставить новое поле в
/src/PrestaShopBundle/Form/Admin/Product/... в каком табе хотите вывести новое поле, например, ProductInformation.php
/src/PrestaShopBundle/Model/Product/AdminModelAdapter.php
в шаблоне
/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/form.....twig

Спасибо боженька!!! (здесь смайл с аськи бьющейся об пол головой) Здесь еще есть живые люди!
А еще вы прямо похоже что ответили на мой вопрос. Сейчас пойду смотреть скрипты по указанным путям.
А вообще я боюсь со следующей задачей:
Как добавить еще одно свойство для товара и вывести его в ТАБ?
Вроде PHP знаю... вроде с MVC знаком... и что-то ни как пока не получается.
Может кто знает быстрое решение, буду благодарен.
Либо как добьюсь, выложу свое сюда позже.

Задача: Нужно добавить еще одно поле со свойствами типа существующего "Описание"
Что сделал.
1. Добавил поле в базу.
2. Добавил импорт этого поля в classes/product.php
3. Добавил новый ТАБ в product.tpl (отображается)

А вот в контроллерах админ панели и фронта - затупил. Не могу найти через какой метод они вызывают и потом выводят этот блок с ТАБами. Замылился глаз уже....

Задача то на первый взгляд пустяковая. Просто взять и сдублировать (переименовав) существующий блок на новый. И вывести его рядом. НО.... с наскока не вышло.

Заранее ОГРОМНОЕ СПАСИБО! Даже если ни кто не ответит )
28 Сентябрь 2019, 11:41:49
Ответ #55
  • Модератор
  • Ветеран
  • *****
  • Сообщений: 33325
  • Репутация: +26771/-0
    • Просмотр профиля
Чтобы во фронтенде вывести в табах не обязательно создавать новый таб в админке.
Можете создать модуль с установкой в разные хуки
Для админки карточки товара определены хуки :
- displayAdminProductsExtra
- displayAdminProductsMainStepLeftColumnMiddle
- displayAdminProductsMainStepLeftColumnBottom
- displayAdminProductsMainStepRightColumnBottom
- displayAdminProductsQuantitiesStepBottom
- displayAdminProductsPriceStepBottom
- displayAdminProductsOptionsStepTop
- displayAdminProductsOptionsStepBottom
- displayAdminProductsSeoStepBottom
28 Сентябрь 2019, 13:38:52
Ответ #56
  • Новичок
  • *
  • Сообщений: 3
  • Репутация: +0/-0
  • Сообщество PrestaShop
    • Просмотр профиля
Чтобы во фронтенде вывести в табах не обязательно создавать новый таб в админке.
Можете создать модуль с установкой в разные хуки
Для админки карточки товара определены хуки :
- displayAdminProductsExtra
- displayAdminProductsMainStepLeftColumnMiddle
- displayAdminProductsMainStepLeftColumnBottom
- displayAdminProductsMainStepRightColumnBottom
- displayAdminProductsQuantitiesStepBottom
- displayAdminProductsPriceStepBottom
- displayAdminProductsOptionsStepTop
- displayAdminProductsOptionsStepBottom
- displayAdminProductsSeoStepBottom

Признаться я с престой первую неделю. И еще не до конца въехал в структуру. Но ваша мысль у меня была в голове.
Я так понял, что для этой реализации мне нужен модуль CustomHTML, и тут началось....
1. Этот модуль не имеет вывода в указанные позиции.
2. Для каждого товара мне нужны свои "характеристики". А как я понял, модуль этот вбивается один раз и для всех.
Ну и соответственно, его правка нужна (и удобнее) прямо из окна свойств продукта (товара).
Что как я понял, опять же, не реализуемо "из коробки".
28 Сентябрь 2019, 16:25:16
Ответ #57
  • Ветеран
  • *****
  • Сообщений: 16670
  • Репутация: +14630/-5
  • Сообщество PrestaShop
    • Просмотр профиля
Признаться я с престой первую неделю. И еще не до конца въехал в структуру. Но ваша мысль у меня была в голове.
Я так понял, что для этой реализации мне нужен модуль CustomHTML, и тут началось....
1. Этот модуль не имеет вывода в указанные позиции.
2. Для каждого товара мне нужны свои "характеристики". А как я понял, модуль этот вбивается один раз и для всех.
Ну и соответственно, его правка нужна (и удобнее) прямо из окна свойств продукта (товара).
Что как я понял, опять же, не реализуемо "из коробки".

1  Для вывода в нужном месте можно создать свой хук, если не хватает хуков prestashop.
2. Не так, все зависит от вас. Создайте таблицы связи ид товара и своих харастеристик, будет у каждого товара свой набор.
3. Вам написали какие хуки админки можно использовать чтобы выводить переменные модуля в карточке товара.
displayAdminProducts...
28 Июль 2021, 13:16:46
Ответ #58
  • Пользователь
  • **
  • Сообщений: 56
  • Репутация: +0/-0
  • Сообщество PrestaShop
    • Просмотр профиля
Ребята спасайте!
В админке все работает, а вот вывести в шаблон поле никак не получается.
Помогите исправить правильно ProductController.php
Поле в таблице назвал skidka
presta 1.6
<?php

class ProductControllerCore extends FrontController
{
public $php_self 'product';

protected $product;
protected $category;

public function setMedia()
{
parent::setMedia();
if (count($this->errors))
return;

if (!$this->useMobileTheme())
{
$this->addCSS(_THEME_CSS_DIR_.'product.css');
$this->addCSS(_THEME_CSS_DIR_.'print.css''print');
$this->addJqueryPlugin(array('fancybox''idTabs''scrollTo''serialScroll''bxslider'));
$this->addJS(array(
_THEME_JS_DIR_.'tools.js',  // retro compat themes 1.5
_THEME_JS_DIR_.'product.js'
));
}
else
{
$this->addJqueryPlugin(array('scrollTo''serialScroll'));
$this->addJS(array(
_THEME_JS_DIR_.'tools.js',  // retro compat themes 1.5
_THEME_MOBILE_JS_DIR_.'product.js',
_THEME_MOBILE_JS_DIR_.'jquery.touch-gallery.js'
));
}

if (Configuration::get('PS_DISPLAY_JQZOOM') == 1)
$this->addJqueryPlugin('jqzoom');
}

public function canonicalRedirection($canonical_url '')
{
if (Tools::getValue('live_edit'))
return;
if (Validate::isLoadedObject($this->product))
parent::canonicalRedirection($this->context->link->getProductLink($this->product));
}

/**
 * Initialize product controller
 * @see FrontController::init()
 */
public function init()
{
parent::init();

if ($id_product = (int)Tools::getValue('id_product'))
$this->product = new Product($id_producttrue$this->context->language->id$this->context->shop->id);

if (!Validate::isLoadedObject($this->product))
{
header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Found');
$this->errors[] = Tools::displayError('Product not found');
}
else
{
$this->canonicalRedirection();
/*
 * If the product is associated to the shop
 * and is active or not active but preview mode (need token + file_exists)
 * allow showing the product
 * In all the others cases => 404 "Product is no longer available"
 */
if (!$this->product->isAssociatedToShop() || !$this->product->active)
{
if (Tools::getValue('adtoken') == Tools::getAdminToken('AdminProducts'.(int)Tab::getIdFromClassName('AdminProducts').(int)Tools::getValue('id_employee')) && $this->product->isAssociatedToShop())
{
// If the product is not active, it's the admin preview mode
$this->context->smarty->assign('adminActionDisplay'true);
}
else
{
$this->context->smarty->assign('adminActionDisplay'false);
if (!$this->product->id_product_redirected || $this->product->id_product_redirected == $this->product->id)
$this->product->redirect_type '404';

switch ($this->product->redirect_type)
{
case '301':
header('HTTP/1.1 301 Moved Permanently');
header('Location: '.$this->context->link->getProductLink($this->product->id_product_redirected));
exit;
break;
case '302':
header('HTTP/1.1 302 Moved Temporarily');
header('Cache-Control: no-cache');
header('Location: '.$this->context->link->getProductLink($this->product->id_product_redirected));
exit;
break;
case '404':
default:
header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Found');
$this->errors[] = Tools::displayError('This product is no longer available.');
break;
}
}
}
elseif (!$this->product->checkAccess(isset($this->context->customer->id) && $this->context->customer->id ? (int)$this->context->customer->id 0))
{
header('HTTP/1.1 403 Forbidden');
header('Status: 403 Forbidden');
$this->errors[] = Tools::displayError('You do not have access to this product.');
}
else
{
// Load category
$id_category false;
if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] == Tools::secureReferrer($_SERVER['HTTP_REFERER']) // Assure us the previous page was one of the shop
&& preg_match('~^.*(?<!\/content)\/([0-9]+)\-(.*[^\.])|(.*)id_(category|product)=([0-9]+)(.*)$~'$_SERVER['HTTP_REFERER'], $regs))
{
// If the previous page was a category and is a parent category of the product use this category as parent category
$id_object false;
if (isset($regs[1]) && is_numeric($regs[1]))
$id_object = (int)$regs[1];
elseif (isset($regs[5]) && is_numeric($regs[5]))
$id_object = (int)$regs[5];
if ($id_object)
{
$referers = array($_SERVER['HTTP_REFERER'],urldecode($_SERVER['HTTP_REFERER']));
if (in_array($this->context->link->getCategoryLink($id_object), $referers))
$id_category = (int)$id_object;
elseif (isset($this->context->cookie->last_visited_category) && (int)$this->context->cookie->last_visited_category && in_array($this->context->link->getProductLink($id_object), $referers))
$id_category = (int)$this->context->cookie->last_visited_category;
}

}
if (!$id_category || !Category::inShopStatic($id_category$this->context->shop) || !Product::idIsOnCategoryId((int)$this->product->id, array('0' => array('id_category' => $id_category))))
$id_category = (int)$this->product->id_category_default;
$this->category = new Category((int)$id_category, (int)$this->context->cookie->id_lang);
if (isset($this->context->cookie) && isset($this->category->id_category) && !(Module::isInstalled('blockcategories') && Module::isEnabled('blockcategories')))
$this->context->cookie->last_visited_category = (int)$this->category->id_category;
}
}
}

/**
 * Assign template vars related to page content
 * @see FrontController::initContent()
 */
public function initContent()
{
parent::initContent();

if (!$this->errors)
{
if (Pack::isPack((int)$this->product->id) && !Pack::isInStock((int)$this->product->id))
$this->product->quantity 0;

$this->product->description $this->transformDescriptionWithImg($this->product->description);

// Assign to the template the id of the virtual product. "0" if the product is not downloadable.
$this->context->smarty->assign('virtual'ProductDownload::getIdFromIdProduct((int)$this->product->id));

$this->context->smarty->assign('customizationFormTarget'Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));

if (Tools::isSubmit('submitCustomizedDatas'))
{
// If cart has not been saved, we need to do it so that customization fields can have an id_cart
// We check that the cookie exists first to avoid ghost carts
if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()]))
{
$this->context->cart->add();
$this->context->cookie->id_cart = (int)$this->context->cart->id;
}
$this->pictureUpload();
$this->textRecord();
$this->formTargetFormat();
}
elseif (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->idTools::getValue('deletePicture')))
$this->errors[] = Tools::displayError('An error occurred while deleting the selected picture.');

$pictures = array();
$text_fields = array();
if ($this->product->customizable)
{
$files $this->context->cart->getProductCustomization($this->product->idProduct::CUSTOMIZE_FILEtrue);
foreach ($files as $file)
$pictures['pictures_'.$this->product->id.'_'.$file['index']] = $file['value'];

$texts $this->context->cart->getProductCustomization($this->product->idProduct::CUSTOMIZE_TEXTFIELDtrue);

foreach ($texts as $text_field)
$text_fields['textFields_'.$this->product->id.'_'.$text_field['index']] = str_replace('<br />'"\n"$text_field['value']);
}

$this->context->smarty->assign(array(
'pictures' => $pictures,
'textFields' => $text_fields));

$this->product->customization_required false;
$customization_fields $this->product->customizable $this->product->getCustomizationFields($this->context->language->id) : false;
if (is_array($customization_fields))
foreach ($customization_fields as $customization_field)
if ($this->product->customization_required $customization_field['required'])
break;

// Assign template vars related to the category + execute hooks related to the category
$this->assignCategory();
// Assign template vars related to the price and tax
$this->assignPriceAndTax();

// Assign template vars related to the images
$this->assignImages();
// Assign attribute groups to the template
$this->assignAttributesGroups();

// Assign attributes combinations to the template
$this->assignAttributesCombinations();

// Pack management
$pack_items Pack::isPack($this->product->id) ? Pack::getItemTable($this->product->id$this->context->language->idtrue) : array();
$this->context->smarty->assign('packItems'$pack_items);
$this->context->smarty->assign('packs'Pack::getPacksTable($this->product->id$this->context->language->idtrue1));

if (isset($this->category->id) && $this->category->id)
$return_link Tools::safeOutput($this->context->link->getCategoryLink($this->category));
else
$return_link 'javascript: history.back();';

$accessories $this->product->getAccessories($this->context->language->id);
if ($this->product->cache_is_pack || count($accessories))
$this->context->controller->addCSS(_THEME_CSS_DIR_.'product_list.css');



$this->context->smarty->assign(array(
'stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'),
'customizationFields' => $customization_fields,
'accessories' => $accessories,
'return_link' => $return_link,
'product' => $this->product,
'product_manufacturer' => new Manufacturer((int)$this->product->id_manufacturer$this->context->language->id),
'token' => Tools::getToken(false),
'features' => $this->product->getFrontFeatures($this->context->language->id),
'attachments' => (($this->product->cache_has_attachments) ? $this->product->getAttachments($this->context->language->id) : array()),
'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int)$this->product->out_of_stock),
'last_qties' =>  (int)Configuration::get('PS_LAST_QTIES'),
'HOOK_EXTRA_LEFT' => Hook::exec('displayLeftColumnProduct'),
'HOOK_EXTRA_RIGHT' => Hook::exec('displayRightColumnProduct'),
'HOOK_PRODUCT_OOS' => Hook::exec('actionProductOutOfStock', array('product' => $this->product)),
'HOOK_PRODUCT_ACTIONS' => Hook::exec('displayProductButtons', array('product' => $this->product)),
'HOOK_PRODUCT_TAB' =>  Hook::exec('displayProductTab', array('product' => $this->product)),
'HOOK_PRODUCT_TAB_CONTENT' =>  Hook::exec('displayProductTabContent', array('product' => $this->product)),
'HOOK_PRODUCT_CONTENT' =>  Hook::exec('displayProductContent', array('product' => $this->product)),
'display_qties' => (int)Configuration::get('PS_DISPLAY_QTIES'),
'display_ht' => !Tax::excludeTaxeOption(),
'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM'),
'ENT_NOQUOTES' => ENT_NOQUOTES,
'outOfStockAllowed' => (int)Configuration::get('PS_ORDER_OUT_OF_STOCK'),
'errors' => $this->errors,
'body_classes' => array(
$this->php_self.'-'.$this->product->id,
$this->php_self.'-'.$this->product->link_rewrite,
'category-'.(isset($this->category) ? $this->category->id ''),
'category-'.(isset($this->category) ? $this->category->getFieldByLang('link_rewrite') : '')
),
'display_discount_price' => Configuration::get('PS_DISPLAY_DISCOUNT_PRICE'),
));
 
 
}
$this->setTemplate(_PS_THEME_DIR_.'product.tpl');

}

/**
 * Assign price and tax to the template
 */
protected function assignPriceAndTax()
{
$id_customer = (isset($this->context->customer) ? (int)$this->context->customer->id 0);
$id_group = (int)Group::getCurrent()->id;
$id_country $id_customer ? (int)Customer::getCurrentCountry($id_customer) : (int)Tools::getCountry();

$group_reduction GroupReduction::getValueForProduct($this->product->id$id_group);
if ($group_reduction === false)
$group_reduction Group::getReduction((int)$this->context->cookie->id_customer) / 100;

// Tax
$tax = (float)$this->product->getTaxesRate(new Address((int)$this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
$this->context->smarty->assign('tax_rate'$tax);

$product_price_with_tax Product::getPriceStatic($this->product->idtruenull6);
if (Product::$_taxCalculationMethod == PS_TAX_INC)
$product_price_with_tax Tools::ps_round($product_price_with_tax2);
$product_price_without_eco_tax = (float)$product_price_with_tax $this->product->ecotax;

$ecotax_rate = (float)Tax::getProductEcotaxRate($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$ecotax_tax_amount Tools::ps_round($this->product->ecotax2);
if (Product::$_taxCalculationMethod == PS_TAX_INC && (int)Configuration::get('PS_TAX'))
$ecotax_tax_amount Tools::ps_round($ecotax_tax_amount * ($ecotax_rate 100), 2);

$id_currency = (int)$this->context->cookie->id_currency;
$id_product = (int)$this->product->id;
$id_shop $this->context->shop->id;

$quantity_discounts SpecificPrice::getQuantityDiscounts($id_product$id_shop$id_currency$id_country$id_groupnulltrue, (int)$this->context->customer->id);
foreach ($quantity_discounts as &$quantity_discount)
{
if ($quantity_discount['id_product_attribute'])
{
$combination = new Combination((int)$quantity_discount['id_product_attribute']);
$attributes $combination->getAttributesName((int)$this->context->language->id);
foreach ($attributes as $attribute)
$quantity_discount['attributes'] = $attribute['name'].' - ';
$quantity_discount['attributes'] = rtrim($quantity_discount['attributes'], ' - ');
}
if ((int)$quantity_discount['id_currency'] == && $quantity_discount['reduction_type'] == 'amount')
$quantity_discount['reduction'] = Tools::convertPriceFull($quantity_discount['reduction'], nullContext::getContext()->currency);
}

$product_price $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INCfalse);
$address = new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$this->context->smarty->assign(array(
'quantity_discounts' => $this->formatQuantityDiscounts($quantity_discounts$product_price, (float)$tax$ecotax_tax_amount),
'ecotax_tax_inc' => $ecotax_tax_amount,
'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax2),
'ecotaxTax_rate' => $ecotax_rate,
'productPriceWithoutEcoTax' => (float)$product_price_without_eco_tax,
'group_reduction' => $group_reduction,
'no_tax' => Tax::excludeTaxeOption() || !$this->product->getTaxesRate($address),
'ecotax' => (!count($this->errors) && $this->product->ecotax Tools::convertPrice((float)$this->product->ecotax) : 0),
'tax_enabled' => Configuration::get('PS_TAX'),
'customer_group_without_tax' => Group::getPriceDisplayMethod($this->context->customer->id_default_group),
));
}

/**
 * Assign template vars related to images
 */
protected function assignImages()
{
$images $this->product->getImages((int)$this->context->cookie->id_lang);
$product_images = array();

if (isset($images[0]))
$this->context->smarty->assign('mainImage'$images[0]);
foreach ($images as $k => $image)
{
if ($image['cover'])
{
$this->context->smarty->assign('mainImage'$image);
$cover $image;
$cover['id_image'] = (Configuration::get('PS_LEGACY_IMAGES') ? ($this->product->id.'-'.$image['id_image']) : $image['id_image']);
$cover['id_image_only'] = (int)$image['id_image'];
}
$product_images[(int)$image['id_image']] = $image;
}

if (!isset($cover))
{
if (isset($images[0]))
{
$cover $images[0];
$cover['id_image'] = (Configuration::get('PS_LEGACY_IMAGES') ? ($this->product->id.'-'.$images[0]['id_image']) : $images[0]['id_image']);
$cover['id_image_only'] = (int)$images[0]['id_image'];
}
else
$cover = array(
'id_image' => $this->context->language->iso_code.'-default',
'legend' => 'No picture',
'title' => 'No picture'
);
}
$size Image::getSize(ImageType::getFormatedName('large'));
$this->context->smarty->assign(array(
'have_image' => (isset($cover['id_image']) && (int)$cover['id_image'])? array((int)$cover['id_image']) : Product::getCover((int)Tools::getValue('id_product')),
'cover' => $cover,
'imgWidth' => (int)$size['width'],
'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
'largeSize' => Image::getSize(ImageType::getFormatedName('large')),
'homeSize' => Image::getSize(ImageType::getFormatedName('home')),
'cartSize' => Image::getSize(ImageType::getFormatedName('cart')),
'col_img_dir' => _PS_COL_IMG_DIR_));
if (count($product_images))
$this->context->smarty->assign('images'$product_images);
}





public function getProduct()
{
    return $this->product;
}

public function getCategory()
{
    return $this->category;
}
}
28 Июль 2021, 16:19:17
Ответ #59
  • Ветеран
  • *****
  • Сообщений: 86688
  • Репутация: +25428/-0
  • Сообщество PrestaShop
    • Просмотр профиля
$this->context->smarty->assign('skidka', $skidka;добавьте определение переменной шаблона в метод initContent