Jump to content
Pawlowski

Вывод из бд в каталог (Карточку товара)

Recommended Posts

spacer.png

Добрый день!Не могу вывести собственно добавленный столбец (alt_name) в таблице (oc_product_description) в каталог на карточку товара в строке Альтернативное имя.

Вот что добавил в model\catalog\product.php
 

   public function getAltName($product_id) {
        $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "alt_name WHIERE product_id = '" . (int)$product_id. "'");

        return $query->rows;
    }

Дальше в контроллере controller\product\product.php

$this->data['alt_name'] = $this->model_catalog_product->getAltName($product_id);

Не знаю что добавлять в шаблон product.twig, просто вардампил $alt_time;

 

<h1>{{ heading_title }}</h1>
          {{ text_alt_name }} <?php $alt_name; ?>
 		
          <ul class="list-unstyled">
            {% if manufacturer %}

Буду очень благодарен за помощь!

Share this post


Link to post
Share on other sites
8 минут назад, Pawlowski сказал:

alt_name WHIERE product_id

WHERE

Share this post


Link to post
Share on other sites
9 минут назад, Pawlowski сказал:

<?php $alt_name; ?>

{{ alt_name }}

Share this post


Link to post
Share on other sites
Posted (edited)

Все исправил, получилась ошибочка
Fatal error: Uncaught Error: Call to a member function getAltName() on null in D:\xampp\htdocs\opencart\catalog\controller\product\product.php:70 Stack trace: #0 D:\xampp\htdocs\opencart\system\storage\modification\system\engine\action.php(79): ControllerProductProduct->index() #1 D:\xampp\htdocs\opencart\catalog\controller\startup\router.php(25): Action->execute(Object(Registry)) #2 D:\xampp\htdocs\opencart\system\storage\modification\system\engine\action.php(79): ControllerStartupRouter->index() #3 D:\xampp\htdocs\opencart\system\engine\router.php(67): Action->execute(Object(Registry)) #4 D:\xampp\htdocs\opencart\system\engine\router.php(56): Router->execute(Object(Action)) #5 D:\xampp\htdocs\opencart\system\framework.php(168): Router->dispatch(Object(Action), Object(Action)) #6 D:\xampp\htdocs\opencart\system\startup.php(104): require_once('D:\\xampp\\htdocs...') #7 D:\xampp\htdocs\opencart\index.php(19): start('catalog') #8 {main} thrown in D:\xampp\htdocs\opencart\catalog\controller\product\product.php on line 70

Edited by Pawlowski

Share this post


Link to post
Share on other sites
1 час назад, Pawlowski сказал:

Call to a member function getAltName() on null

это значит что у вас это

this->data['alt_name'] = $this->model_catalog_product->getAltName($product_id);

перед этим

$this->load->model('catalog/product');

нужно наоборот

Share this post


Link to post
Share on other sites
В 05.07.2019 в 23:08, fanatic сказал:

это значит что у вас это


this->data['alt_name'] = $this->model_catalog_product->getAltName($product_id);

перед этим


$this->load->model('catalog/product');

нужно наоборот

Спасибо за советы.
Попробую разобраться дальше сам.

Share this post


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
You are posting as a guest. If you have an account, please sign in.
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.


  • Recently Browsing   0 members

    No registered users viewing this page.

×

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.