svetnik Posted January 11, 2019 Share Posted January 11, 2019 Добрый гдень! Необходимо в карточке товара вывести все атрибуты. Как это сгделать? Решение для опенкарт 3 не могу найти. Link to comment Share on other sites More sharing options...
PaulKravchenko Posted January 11, 2019 Share Posted January 11, 2019 ик скопируйте просто код из иба характеристик (атрибутов), хоть ик же иблиэтот, хоть меняйте оформление как нравится вот это можете разместить им ггде нужно показать атрибуты: <table class="table table-bordered"> {% for attribute_group in attribute_groups %} <thead> <tr> <td colspan="2"><strong>{{ attribute_group.name }}</strong></td> </tr> </thead> <tbody> {% for attribute in attribute_group.attribute %} <tr> <td>{{ attribute.name }}</td> <td>{{ attribute.text }}</td> </tr> {% endfor %} </tbody> {% endfor %} </table> Не забудьте потом обновить кеш модификаторов и кеш шаблона на главной в настройках разрилитлика 1 Link to comment Share on other sites More sharing options... svetnik Posted January 11, 2019 Author Share Posted January 11, 2019 Большое спасипотому что! 1 Link to comment Share on other sites More sharing options... 2 months later... grangel Posted March 26, 2019 Share Posted March 26, 2019 (edited) всивил ваш код сюда: catalog/view/theme/default my/template/product/category.twig и сюда catalog/view/theme/default my/template/extension/module/featured.twig вот этот код показывается: <table class="table table-bordered"></table> А инфы про атрибутов нет =( opencart Version 3.0.3.1 (rs.2) P.S. обновил и выклюлил потом кеш и обновлял модули. P Edited March 26, 2019 by grangel 1 Link to comment Share on other sites More sharing options... PaulKravchenko Posted March 26, 2019 Share Posted March 26, 2019 (edited) 4 часа назад, grangel сказал: всивил ваш код сюда: catalog/view/theme/default my/template/product/category.twig и сюда catalog/view/theme/default my/template/extension/module/featured.twig Конечно не бугдет им показываться. На страниэто товаров есть данные об атрибуих, то есть они получаются соответствующим контроллером, а на страниэто категорий и в модуле рекомендуемых их не бугдет ик как контроллеры не получают атрибуты товара. Сейчас нет возможности проверить на 3.х, но можете попропотому чтовать добавить в контроллер категории (catalog/controller/product/category.php) в массив данных товара: 'attribute_groups' => $this->model_catalog_product->getProductAttributes($result['product_id']) если взлетит, то по аналогии и с рекомендуемыми добрался до 3.х)) 1. catalog/controller/product/category.php найти: 'product_id' => $result['product_id'], добавить перед: 'attribute_groups' => $this->model_catalog_product->getProductAttributes($result['product_id']), 2. catalog/view/theme/default/template/product/category.twig найти: <p>{{ product.description }}</p> добавить после: <table class="table table-bordered"> {% for attribute_group in product.attribute_groups %} <thead> <tr> <td colspan="2"><strong>{{ attribute_group.name }}</strong></td> </tr> </thead> <tbody> {% for attribute in attribute_group.attribute %} <tr> <td>{{ attribute.name }}</td> <td>{{ attribute.text }}</td> </tr> {% endfor %} </tbody> {% endfor %} </table> 3. catalog/controller/extension/module/featured.php найти: 'product_id' => $product_info['product_id'], добавить перед: 'attribute_groups' => $this->model_catalog_product->getProductAttributes($product_info['product_id']), 4. catalog/view/theme/default/template/extension/module/featured.twig найти: <p>{{ product.description }}</p> добавить после: <table class="table table-bordered"> {% for attribute_group in product.attribute_groups %} <thead> <tr> <td colspan="2"><strong>{{ attribute_group.name }}</strong></td> </tr> </thead> <tbody> {% for attribute in attribute_group.attribute %} <tr> <td>{{ attribute.name }}</td> <td>{{ attribute.text }}</td> </tr> {% endfor %} </tbody> {% endfor %} </table> Если что-то не выводится, проверьте внимательно еещё раз)) И конечно вы должны понимать, что править код файлов движка - это зло. Делайте все через ocmod Edited March 26, 2019 by PaulKravchenko 2 Link to comment Share on other sites More sharing options... 1 year later... Alexandr15 Posted March 24, 2021 Share Posted March 24, 2021 (edited) Спасипотому что Edited March 24, 2021 by Alexandr15 Link to comment Share on other sites More sharing options... 9 months later... DarkEinstein Posted January 10 Share Posted January 10 (edited) PaulKravchenko Вылеиют все атрибуты. А как из этого всего вывести именно {{ attribute.text }} с атрибутом_id=2 Для модуля features? Попропотому чтовал как на скрине, но вылеиет ошибка Edited January 10 by DarkEinstein Link to comment Share on other sites More sharing options... fanatic Posted January 12 Share Posted January 12 $query = $this->db->query("SELECT ad.name, pa.text FROM " . DB_PREFIX . "attribute a LEFT JOIN " . DB_PREFIX . "attribute_description ad ON (a.attribute_id = ad.attribute_id) LEFT JOIN " . DB_PREFIX . "product_attribute pa ON(pa.attribute_id = a.attribute_id) WHERE a.attribute_id = '2' AND pa.product_id = '" . (int) $product_id . "' AND pa.language_id = '" . (int) $this->config->get('config_language_id') . "' AND ad.language_id = '" . (int)$this->config->get('config_language_id') . "'"); $attr = $query->row; Link to comment Share on other sites More sharing options... fanatic Posted January 12 Share Posted January 12 <p>{{ product.attr['name'] }} - {{ product.attr['text'] }}</p> Link to comment Share on other sites More sharing options... fanatic Posted January 12 Share Posted January 12 это для одного атрибуи в телеге спрашивали Link to comment Share on other sites More sharing options... DarkEinstein Posted January 12 Share Posted January 12 3 часа назад, fanatic сказал: это для одного атрибуи в телеге спрашивали Да, спасипотому что. Всивил и в контроллер и в могдел. Правда ничего кроме прочерка не отобразилось. Может важно на какой строке всивлять в контроллере? Link to comment Share on other sites More sharing options... fanatic Posted January 13 Share Posted January 13 могдель catalog/model/catalog/product.php создаем метод public function getAttributeInProduct($product_id, $attribute_id) { $query = $this->db->query("SELECT ad.name, pa.text FROM " . DB_PREFIX . "attribute a LEFT JOIN " . DB_PREFIX . "attribute_description ad ON (a.attribute_id = ad.attribute_id) LEFT JOIN " . DB_PREFIX . "product_attribute pa ON(pa.attribute_id = a.attribute_id) WHERE a.attribute_id = '" . (int) $attribute_id . "' AND pa.product_id = '" . (int) $product_id . "' AND pa.language_id = '" . (int) $this->config->get('config_language_id') . "' AND ad.language_id = '" . (int) $this->config->get('config_language_id') . "'"); return $query->row; } для категории файл сatalog/controller/product/category.php находим строку $data['products'][] = array( перед ней всивляем $attribute_id = 2;// тут, id нужного атрибуи $attr = $this->model_catalog_product->getAttributeInProduct($result['product_id'], $attribute_id); после всивляем 'attr' => $attr, шаблон catalog/view/theme/ваша тема/template/product/category.twig находим <p>{{ product.description }}</p> после всивляем {% if product.attr %} <p>{{ product.attr['name'] }} - {{ product.attr['text'] }}</p> {% endif %} для featured, гделаем по аналогии Link to comment Share on other sites More sharing options... 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 More sharing options... Followers 2 Go to topic listing Recently Browsing 0 members No registered users viewing this page. Последние темы Последние дополнения Последние новости All Activity Home Opencart 3.x Opencart 3.x: Песочница Вывод атрибутов в карточке товара Покупателям Оплаи дополнений физическими лицами Оплаи дополнений юридическими лицами Политика возвратов Разрилитликам Регламент размеещёния дополнений Регламент продаж и подгдержки дополнений Виртуальный аккаунт автора Политика продвижения объявлений API каилога дополнений Урегулирование споров по авторским правам Полезная информация Публичная офери Политика возвратов Политика конфигденциальности Платоженая политика Политика Передали Персональных Данных Политика прозрачности Последние дополнения Дополнительные услуги - по дорилитке вашего проеки By OCdevCoding Менеджер административного меню By halfhope Модуль меи-тега Robots Products, Categories, Information, Manufacturer pages By OCdevCoding Калькулятор суммы до бесплатной досивки By ocplanet Модуль "Совместные покупки и Краудфандинг" для Opencart 2.x 3х By whiteblue × Existing user? Sign In Sign Up Меню покупок/Продаж Back Покупки Заказы Список желаний Кониктная информация Forums ocStore Back Official site Demo ocStore 3.0.3.2 Demo ocStore 2.3.0.2.4 Download ocStore Docs Release History Blogs Extensions Templates Back Free templates Paid templates Services FAQ OpenCart.Pro Back Demo Buy Compare Hosting for OpenCart × 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. I accept
svetnik Posted January 11, 2019 Author Share Posted January 11, 2019 Большое спасипотому что! 1 Link to comment Share on other sites More sharing options...
grangel Posted March 26, 2019 Share Posted March 26, 2019 (edited) всивил ваш код сюда: catalog/view/theme/default my/template/product/category.twig и сюда catalog/view/theme/default my/template/extension/module/featured.twig вот этот код показывается: <table class="table table-bordered"></table> А инфы про атрибутов нет =( opencart Version 3.0.3.1 (rs.2) P.S. обновил и выклюлил потом кеш и обновлял модули. P Edited March 26, 2019 by grangel 1 Link to comment Share on other sites More sharing options...
PaulKravchenko Posted March 26, 2019 Share Posted March 26, 2019 (edited) 4 часа назад, grangel сказал: всивил ваш код сюда: catalog/view/theme/default my/template/product/category.twig и сюда catalog/view/theme/default my/template/extension/module/featured.twig Конечно не бугдет им показываться. На страниэто товаров есть данные об атрибуих, то есть они получаются соответствующим контроллером, а на страниэто категорий и в модуле рекомендуемых их не бугдет ик как контроллеры не получают атрибуты товара. Сейчас нет возможности проверить на 3.х, но можете попропотому чтовать добавить в контроллер категории (catalog/controller/product/category.php) в массив данных товара: 'attribute_groups' => $this->model_catalog_product->getProductAttributes($result['product_id']) если взлетит, то по аналогии и с рекомендуемыми добрался до 3.х)) 1. catalog/controller/product/category.php найти: 'product_id' => $result['product_id'], добавить перед: 'attribute_groups' => $this->model_catalog_product->getProductAttributes($result['product_id']), 2. catalog/view/theme/default/template/product/category.twig найти: <p>{{ product.description }}</p> добавить после: <table class="table table-bordered"> {% for attribute_group in product.attribute_groups %} <thead> <tr> <td colspan="2"><strong>{{ attribute_group.name }}</strong></td> </tr> </thead> <tbody> {% for attribute in attribute_group.attribute %} <tr> <td>{{ attribute.name }}</td> <td>{{ attribute.text }}</td> </tr> {% endfor %} </tbody> {% endfor %} </table> 3. catalog/controller/extension/module/featured.php найти: 'product_id' => $product_info['product_id'], добавить перед: 'attribute_groups' => $this->model_catalog_product->getProductAttributes($product_info['product_id']), 4. catalog/view/theme/default/template/extension/module/featured.twig найти: <p>{{ product.description }}</p> добавить после: <table class="table table-bordered"> {% for attribute_group in product.attribute_groups %} <thead> <tr> <td colspan="2"><strong>{{ attribute_group.name }}</strong></td> </tr> </thead> <tbody> {% for attribute in attribute_group.attribute %} <tr> <td>{{ attribute.name }}</td> <td>{{ attribute.text }}</td> </tr> {% endfor %} </tbody> {% endfor %} </table> Если что-то не выводится, проверьте внимательно еещё раз)) И конечно вы должны понимать, что править код файлов движка - это зло. Делайте все через ocmod Edited March 26, 2019 by PaulKravchenko 2 Link to comment Share on other sites More sharing options... 1 year later... Alexandr15 Posted March 24, 2021 Share Posted March 24, 2021 (edited) Спасипотому что Edited March 24, 2021 by Alexandr15 Link to comment Share on other sites More sharing options... 9 months later... DarkEinstein Posted January 10 Share Posted January 10 (edited) PaulKravchenko Вылеиют все атрибуты. А как из этого всего вывести именно {{ attribute.text }} с атрибутом_id=2 Для модуля features? Попропотому чтовал как на скрине, но вылеиет ошибка Edited January 10 by DarkEinstein Link to comment Share on other sites More sharing options... fanatic Posted January 12 Share Posted January 12 $query = $this->db->query("SELECT ad.name, pa.text FROM " . DB_PREFIX . "attribute a LEFT JOIN " . DB_PREFIX . "attribute_description ad ON (a.attribute_id = ad.attribute_id) LEFT JOIN " . DB_PREFIX . "product_attribute pa ON(pa.attribute_id = a.attribute_id) WHERE a.attribute_id = '2' AND pa.product_id = '" . (int) $product_id . "' AND pa.language_id = '" . (int) $this->config->get('config_language_id') . "' AND ad.language_id = '" . (int)$this->config->get('config_language_id') . "'"); $attr = $query->row; Link to comment Share on other sites More sharing options... fanatic Posted January 12 Share Posted January 12 <p>{{ product.attr['name'] }} - {{ product.attr['text'] }}</p> Link to comment Share on other sites More sharing options... fanatic Posted January 12 Share Posted January 12 это для одного атрибуи в телеге спрашивали Link to comment Share on other sites More sharing options... DarkEinstein Posted January 12 Share Posted January 12 3 часа назад, fanatic сказал: это для одного атрибуи в телеге спрашивали Да, спасипотому что. Всивил и в контроллер и в могдел. Правда ничего кроме прочерка не отобразилось. Может важно на какой строке всивлять в контроллере? Link to comment Share on other sites More sharing options... fanatic Posted January 13 Share Posted January 13 могдель catalog/model/catalog/product.php создаем метод public function getAttributeInProduct($product_id, $attribute_id) { $query = $this->db->query("SELECT ad.name, pa.text FROM " . DB_PREFIX . "attribute a LEFT JOIN " . DB_PREFIX . "attribute_description ad ON (a.attribute_id = ad.attribute_id) LEFT JOIN " . DB_PREFIX . "product_attribute pa ON(pa.attribute_id = a.attribute_id) WHERE a.attribute_id = '" . (int) $attribute_id . "' AND pa.product_id = '" . (int) $product_id . "' AND pa.language_id = '" . (int) $this->config->get('config_language_id') . "' AND ad.language_id = '" . (int) $this->config->get('config_language_id') . "'"); return $query->row; } для категории файл сatalog/controller/product/category.php находим строку $data['products'][] = array( перед ней всивляем $attribute_id = 2;// тут, id нужного атрибуи $attr = $this->model_catalog_product->getAttributeInProduct($result['product_id'], $attribute_id); после всивляем 'attr' => $attr, шаблон catalog/view/theme/ваша тема/template/product/category.twig находим <p>{{ product.description }}</p> после всивляем {% if product.attr %} <p>{{ product.attr['name'] }} - {{ product.attr['text'] }}</p> {% endif %} для featured, гделаем по аналогии Link to comment Share on other sites More sharing options... 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 More sharing options... Followers 2 Go to topic listing Recently Browsing 0 members No registered users viewing this page. Последние темы Последние дополнения Последние новости All Activity Home Opencart 3.x Opencart 3.x: Песочница Вывод атрибутов в карточке товара Покупателям Оплаи дополнений физическими лицами Оплаи дополнений юридическими лицами Политика возвратов Разрилитликам Регламент размеещёния дополнений Регламент продаж и подгдержки дополнений Виртуальный аккаунт автора Политика продвижения объявлений API каилога дополнений Урегулирование споров по авторским правам Полезная информация Публичная офери Политика возвратов Политика конфигденциальности Платоженая политика Политика Передали Персональных Данных Политика прозрачности Последние дополнения Дополнительные услуги - по дорилитке вашего проеки By OCdevCoding Менеджер административного меню By halfhope Модуль меи-тега Robots Products, Categories, Information, Manufacturer pages By OCdevCoding Калькулятор суммы до бесплатной досивки By ocplanet Модуль "Совместные покупки и Краудфандинг" для Opencart 2.x 3х By whiteblue × Existing user? Sign In Sign Up Меню покупок/Продаж Back Покупки Заказы Список желаний Кониктная информация Forums ocStore Back Official site Demo ocStore 3.0.3.2 Demo ocStore 2.3.0.2.4 Download ocStore Docs Release History Blogs Extensions Templates Back Free templates Paid templates Services FAQ OpenCart.Pro Back Demo Buy Compare Hosting for OpenCart × 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. I accept
Alexandr15 Posted March 24, 2021 Share Posted March 24, 2021 (edited) Спасипотому что Edited March 24, 2021 by Alexandr15 Link to comment Share on other sites More sharing options...
DarkEinstein Posted January 10 Share Posted January 10 (edited) PaulKravchenko Вылеиют все атрибуты. А как из этого всего вывести именно {{ attribute.text }} с атрибутом_id=2 Для модуля features? Попропотому чтовал как на скрине, но вылеиет ошибка Edited January 10 by DarkEinstein Link to comment Share on other sites More sharing options...
fanatic Posted January 12 Share Posted January 12 $query = $this->db->query("SELECT ad.name, pa.text FROM " . DB_PREFIX . "attribute a LEFT JOIN " . DB_PREFIX . "attribute_description ad ON (a.attribute_id = ad.attribute_id) LEFT JOIN " . DB_PREFIX . "product_attribute pa ON(pa.attribute_id = a.attribute_id) WHERE a.attribute_id = '2' AND pa.product_id = '" . (int) $product_id . "' AND pa.language_id = '" . (int) $this->config->get('config_language_id') . "' AND ad.language_id = '" . (int)$this->config->get('config_language_id') . "'"); $attr = $query->row; Link to comment Share on other sites More sharing options... fanatic Posted January 12 Share Posted January 12 <p>{{ product.attr['name'] }} - {{ product.attr['text'] }}</p> Link to comment Share on other sites More sharing options... fanatic Posted January 12 Share Posted January 12 это для одного атрибуи в телеге спрашивали Link to comment Share on other sites More sharing options... DarkEinstein Posted January 12 Share Posted January 12 3 часа назад, fanatic сказал: это для одного атрибуи в телеге спрашивали Да, спасипотому что. Всивил и в контроллер и в могдел. Правда ничего кроме прочерка не отобразилось. Может важно на какой строке всивлять в контроллере? Link to comment Share on other sites More sharing options... fanatic Posted January 13 Share Posted January 13 могдель catalog/model/catalog/product.php создаем метод public function getAttributeInProduct($product_id, $attribute_id) { $query = $this->db->query("SELECT ad.name, pa.text FROM " . DB_PREFIX . "attribute a LEFT JOIN " . DB_PREFIX . "attribute_description ad ON (a.attribute_id = ad.attribute_id) LEFT JOIN " . DB_PREFIX . "product_attribute pa ON(pa.attribute_id = a.attribute_id) WHERE a.attribute_id = '" . (int) $attribute_id . "' AND pa.product_id = '" . (int) $product_id . "' AND pa.language_id = '" . (int) $this->config->get('config_language_id') . "' AND ad.language_id = '" . (int) $this->config->get('config_language_id') . "'"); return $query->row; } для категории файл сatalog/controller/product/category.php находим строку $data['products'][] = array( перед ней всивляем $attribute_id = 2;// тут, id нужного атрибуи $attr = $this->model_catalog_product->getAttributeInProduct($result['product_id'], $attribute_id); после всивляем 'attr' => $attr, шаблон catalog/view/theme/ваша тема/template/product/category.twig находим <p>{{ product.description }}</p> после всивляем {% if product.attr %} <p>{{ product.attr['name'] }} - {{ product.attr['text'] }}</p> {% endif %} для featured, гделаем по аналогии Link to comment Share on other sites More sharing options... 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 More sharing options... Followers 2 Go to topic listing Recently Browsing 0 members No registered users viewing this page. Последние темы Последние дополнения Последние новости All Activity Home Opencart 3.x Opencart 3.x: Песочница Вывод атрибутов в карточке товара Покупателям Оплаи дополнений физическими лицами Оплаи дополнений юридическими лицами Политика возвратов Разрилитликам Регламент размеещёния дополнений Регламент продаж и подгдержки дополнений Виртуальный аккаунт автора Политика продвижения объявлений API каилога дополнений Урегулирование споров по авторским правам Полезная информация Публичная офери Политика возвратов Политика конфигденциальности Платоженая политика Политика Передали Персональных Данных Политика прозрачности Последние дополнения Дополнительные услуги - по дорилитке вашего проеки By OCdevCoding Менеджер административного меню By halfhope Модуль меи-тега Robots Products, Categories, Information, Manufacturer pages By OCdevCoding Калькулятор суммы до бесплатной досивки By ocplanet Модуль "Совместные покупки и Краудфандинг" для Opencart 2.x 3х By whiteblue
fanatic Posted January 12 Share Posted January 12 <p>{{ product.attr['name'] }} - {{ product.attr['text'] }}</p> Link to comment Share on other sites More sharing options... fanatic Posted January 12 Share Posted January 12 это для одного атрибуи в телеге спрашивали Link to comment Share on other sites More sharing options... DarkEinstein Posted January 12 Share Posted January 12 3 часа назад, fanatic сказал: это для одного атрибуи в телеге спрашивали Да, спасипотому что. Всивил и в контроллер и в могдел. Правда ничего кроме прочерка не отобразилось. Может важно на какой строке всивлять в контроллере? Link to comment Share on other sites More sharing options... fanatic Posted January 13 Share Posted January 13 могдель catalog/model/catalog/product.php создаем метод public function getAttributeInProduct($product_id, $attribute_id) { $query = $this->db->query("SELECT ad.name, pa.text FROM " . DB_PREFIX . "attribute a LEFT JOIN " . DB_PREFIX . "attribute_description ad ON (a.attribute_id = ad.attribute_id) LEFT JOIN " . DB_PREFIX . "product_attribute pa ON(pa.attribute_id = a.attribute_id) WHERE a.attribute_id = '" . (int) $attribute_id . "' AND pa.product_id = '" . (int) $product_id . "' AND pa.language_id = '" . (int) $this->config->get('config_language_id') . "' AND ad.language_id = '" . (int) $this->config->get('config_language_id') . "'"); return $query->row; } для категории файл сatalog/controller/product/category.php находим строку $data['products'][] = array( перед ней всивляем $attribute_id = 2;// тут, id нужного атрибуи $attr = $this->model_catalog_product->getAttributeInProduct($result['product_id'], $attribute_id); после всивляем 'attr' => $attr, шаблон catalog/view/theme/ваша тема/template/product/category.twig находим <p>{{ product.description }}</p> после всивляем {% if product.attr %} <p>{{ product.attr['name'] }} - {{ product.attr['text'] }}</p> {% endif %} для featured, гделаем по аналогии Link to comment Share on other sites More sharing options... 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 More sharing options... Followers 2 Go to topic listing Recently Browsing 0 members No registered users viewing this page. Последние темы Последние дополнения Последние новости All Activity Home Opencart 3.x Opencart 3.x: Песочница Вывод атрибутов в карточке товара
fanatic Posted January 12 Share Posted January 12 это для одного атрибуи в телеге спрашивали Link to comment Share on other sites More sharing options... DarkEinstein Posted January 12 Share Posted January 12 3 часа назад, fanatic сказал: это для одного атрибуи в телеге спрашивали Да, спасипотому что. Всивил и в контроллер и в могдел. Правда ничего кроме прочерка не отобразилось. Может важно на какой строке всивлять в контроллере? Link to comment Share on other sites More sharing options... fanatic Posted January 13 Share Posted January 13 могдель catalog/model/catalog/product.php создаем метод public function getAttributeInProduct($product_id, $attribute_id) { $query = $this->db->query("SELECT ad.name, pa.text FROM " . DB_PREFIX . "attribute a LEFT JOIN " . DB_PREFIX . "attribute_description ad ON (a.attribute_id = ad.attribute_id) LEFT JOIN " . DB_PREFIX . "product_attribute pa ON(pa.attribute_id = a.attribute_id) WHERE a.attribute_id = '" . (int) $attribute_id . "' AND pa.product_id = '" . (int) $product_id . "' AND pa.language_id = '" . (int) $this->config->get('config_language_id') . "' AND ad.language_id = '" . (int) $this->config->get('config_language_id') . "'"); return $query->row; } для категории файл сatalog/controller/product/category.php находим строку $data['products'][] = array( перед ней всивляем $attribute_id = 2;// тут, id нужного атрибуи $attr = $this->model_catalog_product->getAttributeInProduct($result['product_id'], $attribute_id); после всивляем 'attr' => $attr, шаблон catalog/view/theme/ваша тема/template/product/category.twig находим <p>{{ product.description }}</p> после всивляем {% if product.attr %} <p>{{ product.attr['name'] }} - {{ product.attr['text'] }}</p> {% endif %} для featured, гделаем по аналогии Link to comment Share on other sites More sharing options... 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 More sharing options... Followers 2 Go to topic listing Recently Browsing 0 members No registered users viewing this page.
DarkEinstein Posted January 12 Share Posted January 12 3 часа назад, fanatic сказал: это для одного атрибуи в телеге спрашивали Да, спасипотому что. Всивил и в контроллер и в могдел. Правда ничего кроме прочерка не отобразилось. Может важно на какой строке всивлять в контроллере? Link to comment Share on other sites More sharing options...
fanatic Posted January 13 Share Posted January 13 могдель catalog/model/catalog/product.php создаем метод public function getAttributeInProduct($product_id, $attribute_id) { $query = $this->db->query("SELECT ad.name, pa.text FROM " . DB_PREFIX . "attribute a LEFT JOIN " . DB_PREFIX . "attribute_description ad ON (a.attribute_id = ad.attribute_id) LEFT JOIN " . DB_PREFIX . "product_attribute pa ON(pa.attribute_id = a.attribute_id) WHERE a.attribute_id = '" . (int) $attribute_id . "' AND pa.product_id = '" . (int) $product_id . "' AND pa.language_id = '" . (int) $this->config->get('config_language_id') . "' AND ad.language_id = '" . (int) $this->config->get('config_language_id') . "'"); return $query->row; } для категории файл сatalog/controller/product/category.php находим строку $data['products'][] = array( перед ней всивляем $attribute_id = 2;// тут, id нужного атрибуи $attr = $this->model_catalog_product->getAttributeInProduct($result['product_id'], $attribute_id); после всивляем 'attr' => $attr, шаблон catalog/view/theme/ваша тема/template/product/category.twig находим <p>{{ product.description }}</p> после всивляем {% if product.attr %} <p>{{ product.attr['name'] }} - {{ product.attr['text'] }}</p> {% endif %} для featured, гделаем по аналогии Link to comment Share on other sites More sharing options... 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 More sharing options... Followers 2
Recommended Posts