На форуме 9558 тем, 76452 сообщений, 44664 участников
тема · 2 840 просмотров · 24 ответа

Opencart 3. Добавить новое поле в oc_ product_image

Общие вопросы
читают: 0 участников и 1 гость
порядок
1 июл 2019 20:57#21
euxos написал(а): ↑да, чтобы описания подгружались вместе с изображениями.

Chukcha написал(а): ↑под изображениями? или в атрибутах?
1 июл 2019 21:00#22
Chukcha написал(а): ↑можно паковать через json или serialize

да согласен, как-то не подумал. но мне все равно удобней в таблице.
1 июл 2019 21:04#23
euxos написал(а): ↑И для вывода на сайте

php
            $data['images'] = array();

$results = $this->model_catalog_product->getProductImages($this->request->get['product_id']);

// desc image start

$image_description = array();

$query_desc_image = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image_description WHERE image_product_id = '" . (int) $this->request->get['product_id'] . "' AND language_id = '" . (int) $this->config->get('config_language_id') . "'");
if($query_desc_image->rows){
foreach($query_desc_image->rows as $d_i){
$image_description[$d_i['image_id']] = $d_i['image_description'];
}
}

// desc image end

foreach ($results as $result) {
// desc image start

if(isset($image_description[$result['product_image_id']])){
$desc = $image_description[$result['product_image_id']];
}else{
$desc = false;
}

// desc image end

$data['images'][] = array(
// desc image start
'description' => $desc,
// desc image end
'popup' => $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_height')),
'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_additional_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_additional_height'))
);
}
1 июл 2019 21:33#24
fanatic написал(а): ↑но мне все равно удобней в таблице.

Каждому свое

У меня был проект, для которого такое делалось
Там было всего 100 товаров и по от 5-ти до 10-ти изображений

Все закончилось на 20ти товарах

Для 100 товаров - отдельная таблица не нагрузка
Для 10к - начинает эти миллисекунды начинают ощущаться.
1 июл 2019 22:34#25
fanatic написал(а): ↑
php
            $data['images'] = array();

$results = $this->model_catalog_product->getProductImages($this->request->get['product_id']);

// desc image start

$image_description = array();

$query_desc_image = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image_description WHERE image_product_id = '" . (int) $this->request->get['product_id'] . "' AND language_id = '" . (int) $this->config->get('config_language_id') . "'");
if($query_desc_image->rows){
foreach($query_desc_image->rows as $d_i){
$image_description[$d_i['image_id']] = $d_i['image_description'];
}
}

// desc image end

foreach ($results as $result) {
// desc image start

if(isset($image_description[$result['product_image_id']])){
$desc = $image_description[$result['product_image_id']];
}else{
$desc = false;
}

// desc image end

$data['images'][] = array(
// desc image start
'description' => $desc,
// desc image end
'popup' => $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_height')),
'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_additional_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_additional_height'))
);
}

Огромнейшее СПАСИБО! Вы необычайно помогли.
сообщения 21–25 из 25
Чтобы ответить, войдите или зарегистрируйтесь.

Похожие темы