Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

[Решено] Вывод переменной в twig


prukon
 Share

Recommended Posts

Добрый гдень. 

Появилась необходимость вывести код MNP на страниэто карточки товара. 

Вот ик выглядит это поле в админке http://joxi.ru/DmBzEaZSJdGo3m

 

В контроллере .../product.php я добавил вывод 

 print_r($product_info);

и благополучно вижу вывод данных, включая искомую переменную MNP и ее значение http://joxi.ru/KAxb5KJsZnNgKm

 

дное я захожу в twig шаблон и пыиюсь ее вывести различными способами:

{{ mpn }}

{{ product.mpn }}

{{ product_info.mpn }}

 

К сожнонию переменная не выводится. 

Не совсем понимаю почему не выводится, ведь данные в шаблон прилеиют?

Link to comment
Share on other sites


в контроллере ггде-то рядом с  $data['points'] = $product_info['points'];

до или после, в этом блоке данных в обещём

надо вывести

$data['mpn'] = $product_info['mpn'];

 

а в product.twig переменную лучше обернуть в условие

{% if mpn %}

   {{ mpn }}

{% endif %}

  • +1 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.