Jump to content
Sign in to follow this  
arca

[Решено] Ошибка - несуществующий индекс масива

Recommended Posts

Здравствуйте, ситуация:

добавил украинский язык, отключил русский, английский, на главной странице все хорошо, но в категориях ошибка:

Notice: Undefined index: 3 in Z:\home\master.com.ua\www\catalog\controller\module\reviews.php on line 12

я понимаю, что из-за махинаций с языками где-то масив выходит за рамки, я так понимаю, что должен бить какой-то конфиг из которого я вручную должен убрать эти не нужные языки.

 

Подскажите, пожалуйста, как исправить, а то с php никогда не работал.

 

Ну и конечено, из-за ошибки едет шаблон.

Шаблон - Tecart
OC - 1.5.6
 

Файл reviews.php:

class ControllerModuleReviews extends Controller {
protected function index($setting) {
$this->language->load('module/reviews');

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

$this->load->model('tool/image');

$this->load->model('module/reviews');

if (strlen($setting['header'][$this->config->get('config_language_id')]) > 0){
$this->data['header'] = $setting['header'][$this->config->get('config_language_id')];
} else {
$this->data['header'] = false;
}

$this->data['reviews'] = array();

if ($setting['limit'] > 0) {
$limit = $setting['limit'];
} else {
$limit = 4;
}

if ($setting['text_limit'] > 0) {
$text_limit = $setting['text_limit'];
} else {
$text_limit = 50;
}

if ($setting['type'] == 'latest') {
$results = $this->model_module_reviews->getLatestReviews($limit);
} else {
$results = $this->model_module_reviews->getRandomReviews($limit);
}

foreach ($results as $result) {
if ($this->config->get('config_review_status')) {
$rating = $result['rating'];
} else {
$rating = false;
}

$product_id = false;
$product = false;
$prod_thumb = false;
$prod_name = false;
$prod_model = false;
$prod_href = false;
$stickers = false;

if ($result['product_id']) {
$product = $this->model_catalog_product->getProduct($result['product_id']);
if ($product['image']) {
$prod_thumb = $this->model_tool_image->resize($product['image'], $setting['image_width'], $setting['image_height']);
}
$product_id = $product['product_id'];
$prod_name = $product['name'];
$prod_model = $product['model'];
$prod_href = $this->url->link('product/product', 'product_id=' . $product['product_id']);
$stickers = $this->getStickers($product['product_id']) ;
}

$this->data['reviews'][] = array(
'review_id' => $result['review_id'],
'rating' => $result['rating'],
'description' => mb_substr($result['text'], 0, $text_limit,'utf-8') . '..',
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'href' => $this->url->link('product/product', 'product_id=' . $product['product_id']),
'author' => $result['author'],
'product_id' => $product_id,
'prod_thumb' => $prod_thumb,
'prod_name' => $prod_name,
'sticker' => $stickers,
'prod_model' => $prod_model,
'prod_href' => $prod_href
);
}

$this->data['link_all_reviews'] = $this->url->link('product/reviews', 'page=1');
$this->data['text_all_reviews'] = $this->language->get('text_all_reviews');

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/reviews.tpl')) {
$this->template = $this->config->get('config_template') . '/template/module/reviews.tpl';
} else {
$this->template = 'default/template/module/reviews.tpl';
}

$this->render();
}

private function getStickers($product_id) {

$stickers = $this->model_catalog_product->getProductStickerbyProductId($product_id) ;

if (!$stickers) {
return;
}

$this->data['stickers'] = array();

foreach ($stickers as $sticker) {
$this->data['stickers'][] = array(
'position' => $sticker['position'],
'image' => HTTP_SERVER . 'image/' . $sticker['image']
);
}


if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/stickers.tpl')) {
$this->template = $this->config->get('config_template') . '/template/product/stickers.tpl';
} else {
$this->template = 'default/template/product/stickers.tpl';
}

return $this->render();

}
}
?>

Share this post


Link to post
Share on other sites

if (strlen($setting['header'][$this->config->get('config_language_id')]) > 0){
$this->data['header'] = $setting['header'][$this->config->get('config_language_id')];
} else {
$this->data['header'] = false;
}
>>

if (isset($setting['header'][$this->config->get('config_language_id')])) {
if (strlen($setting['header'][$this->config->get('config_language_id')]) > 0){
$this->data['header'] = $setting['header'][$this->config->get('config_language_id')];
} else {
$this->data['header'] = false;
}
}
?

Share this post


Link to post
Share on other sites

Спасибо, проблема убралась, но появилась другая:

 

Notice: Undefined variable: header in Z:\home\master.com.ua\www\catalog\view\theme\tecart\template\module\reviews.tpl on line 2
Файл reviews.tpl:

<div class="box">
  <?php if ($header) {?>
  <div class="box-heading"><?php echo $header; ?></div>
  <?php } ?>
  <div class="box-content">
    <div class="box-product">
      <?php foreach ($reviews as $review) { ?>
      <div style="margin:0px;width:100%;">
        <?php if ($review['product_id']) {?>
          <?php if ($review['prod_thumb']) { ?>
          <div class="image"><?php echo $review['sticker']; ?><a href="<?php echo $review['prod_href']; ?>"><img src="<?php echo $review['prod_thumb']; ?>" alt="<?php echo $review['prod_name']; ?>" title="<?php echo $review['prod_name']; ?>"/></a></div>
          <?php } ?>
          <div class="name"><a href="<?php echo $review['prod_href']; ?>"><?php echo $review['prod_name']; ?></a></div>
          <?php } ?>
        <div class="rating">
          <?php for ($i = 1; $i <= 5; $i++) { ?>
          <?php if ($review['rating'] < $i) { ?>
          <span class="fa fa-stack"><i class="fa fa-star-o fa-stack-2x"></i></span>
          <?php } else { ?>
          <span class="fa fa-stack"><i class="fa fa-star fa-stack-2x"></i><i class="fa fa-star-o fa-stack-2x"></i></span>
          <?php } ?>
          <?php } ?>
        </div>
      </div>
      <div style="margin:0px;width:100%;"><?php echo $review['description']?> <a href="<?php echo $review['href']?>">...»</a></div>
      <div style="margin-bottom:20px;margin-right:0px;font-style:italic;font-weight:bold;text-align:right;width:180px;"><?php echo $review['author']?></div>
      <?php } ?>
      <div style="margin:0 10px 10px 0;text-align:right;width:195px;"><a href="<?php echo $link_all_reviews; ?>" class="button"><span><?php echo $text_all_reviews;?></span></a></div>
    </div>
  </div>
</div>

Share this post


Link to post
Share on other sites

Решено, спасибо, тему закрывайте.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • 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.