тема · 2 840 просмотров · 24 ответа
Opencart 3. Добавить новое поле в oc_ product_image
Общие вопросы
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'))
);
}fanatic написал(а): ↑но мне все равно удобней в таблице.
Каждому свое
У меня был проект, для которого такое делалось
Там было всего 100 товаров и по от 5-ти до 10-ти изображений
Все закончилось на 20ти товарах
Для 100 товаров - отдельная таблица не нагрузка
Для 10к - начинает эти миллисекунды начинают ощущаться.
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'))
);
}
Огромнейшее СПАСИБО! Вы необычайно помогли.
Чтобы ответить, войдите или зарегистрируйтесь.