Нашел тему на форуме, где указано решение этой проблемы для версии 1.5. Попробывал применить для версии 2, но выходит ошибка Если делать все как написано в этой теме, то получается такой измененый код в category.php
//кусок кода, который вытащил из product.php
$data['options'] = array();
foreach ($this->model_catalog_product->getProductOptions($this->request->get['product_id']) as $option) {
$product_option_value_data = array();
foreach ($option['product_option_value'] as $option_value) {
if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) {
if ((($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) && (float)$option_value['price']) {
$price = $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax') ? 'P' : false));
} else {
$price = false;
}
$product_option_value_data[] = array(
'product_option_value_id' => $option_value['product_option_value_id'],
'option_value_id' => $option_value['option_value_id'],
'name' => $option_value['name'],
'image' => $this->model_tool_image->resize($option_value['image'], 50, 50),
'price' => $price,
'price_prefix' => $option_value['price_prefix']
);
}
}
$data['options'][] = array(
'product_option_id' => $option['product_option_id'],
'product_option_value' => $product_option_value_data,
'option_id' => $option['option_id'],
'name' => $option['name'],
'type' => $option['type'],
'value' => $option['value'],
'required' => $option['required']
);
}//конец куска кода
//Код из темы на форуме
$options = $this->model_catalog_product->getProductOptions($result['product_id']);
$data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
'attribute_groups' => $this->model_catalog_product->getProductAttributes($result['product_id']), // добавляем атрибуты
'price' => $price,
'options' => $options,
'special' => $special, //Код из темы на форуме
'tax' => $tax,
'rating' => $result['rating'],
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
);
}
И вот такие ошибки вылезают
Notice: Undefined index: product_id in /var/www/u0079664/public_html/burzhuy.org/vqmod/vqcache/vq2-catalog_controller_product_category.php on line 263
Notice: Undefined index: product_id in /var/www/u0079664/public_html/burzhuy.org/vqmod/vqcache/vq2-catalog_controller_product_category.php on line 263
Notice: Undefined index: product_id in /var/www/u0079664/public_html/burzhuy.org/vqmod/vqcache/vq2-catalog_controller_product_category.php on line 263
Notice: Undefined index: product_id in /var/www/u0079664/public_html/burzhuy.org/vqmod/vqcache/vq2-catalog_controller_product_category.php on line 263
Notice: Undefined index: product_id in /var/www/u0079664/public_html/burzhuy.org/vqmod/vqcache/vq2-catalog_controller_product_category.php on line 263
Notice: Undefined index: product_id in /var/www/u0079664/public_html/burzhuy.org/vqmod/vqcache/vq2-catalog_controller_product_category.php on line 263
Notice: Undefined index: product_id in /var/www/u0079664/public_html/burzhuy.org/vqmod/vqcache/vq2-catalog_controller_product_category.php on line 263
Если код из product.php запихнуть под массив
//Код из темы на форуме
$options = $this->model_catalog_product->getProductOptions($result['product_id']);
$data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
'attribute_groups' => $this->model_catalog_product->getProductAttributes($result['product_id']), // добавляем атрибуты
'price' => $price,
'options' => $options,
'special' => $special, //Код из темы на форуме
'tax' => $tax,
'rating' => $result['rating'],
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
);
}
//кусок кода, который вытащил из product.php
$data['options'] = array();
foreach ($this->model_catalog_product->getProductOptions($this->request->get['product_id']) as $option) {
$product_option_value_data = array();
foreach ($option['product_option_value'] as $option_value) {
if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) {
if ((($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) && (float)$option_value['price']) {
$price = $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax') ? 'P' : false));
} else {
$price = false;
}
$product_option_value_data[] = array(
'product_option_value_id' => $option_value['product_option_value_id'],
'option_value_id' => $option_value['option_value_id'],
'name' => $option_value['name'],
'image' => $this->model_tool_image->resize($option_value['image'], 50, 50),
'price' => $price,
'price_prefix' => $option_value['price_prefix']
);
}
}
$data['options'][] = array(
'product_option_id' => $option['product_option_id'],
'product_option_value' => $product_option_value_data,
'option_id' => $option['option_id'],
'name' => $option['name'],
'type' => $option['type'],
'value' => $option['value'],
'required' => $option['required']
);
}//конец куска кода
То получается только вот такая ошибка
Notice: Undefined index: product_id in /var/www/u0079664/public_html/burzhuy.org/vqmod/vqcache/vq2-catalog_controller_product_category.php on line 283
В category.tpl у меня такой код
<?php if ($options) { ?>
<hr>
<h3><?php echo $text_option; ?></h3>
<?php foreach ($options as $option) { ?>
<?php if ($option['type'] == 'radio') { ?>
<div class="form-group<?php echo ($option['required'] ? ' required' : ''); ?>">
<label class="control-label"><?php echo $option['name']; ?></label>
<div id="input-option<?php echo $option['product_option_id']; ?>">
<?php foreach ($option['product_option_value'] as $option_value) { ?>
<div class="radio">
<input type="radio" id="radio<?php echo $option_value['product_option_value_id']; ?>" value="<?php echo $option_value['product_option_value_id']; ?>" name="option[<?php echo $option['product_option_id']; ?>]" />
<label for="radio<?php echo $option_value['product_option_value_id']; ?>"><span></span>
<?php echo $option_value['name']; ?>
</label>
<?php if ($option_value['price']) { ?>
(<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
<?php } ?>
</div>
<?php } ?>
</div>
</div>
<?php } ?>
<?php } ?>
<?php } ?>
Как решить эту проблему?