2016-04-12 13 views
-2

私はprestashopのモジュールをやっています(私は昨日別の質問を投稿しました)。今私はPHPに問題があると思います。たびにそれは私のことを言っているif($same_puente === false OR $same_patilla === false)...解析エラー:構文エラー、予期しないT_STRINGその行で。予期しないT_STRINGがどこにありますか?

<?php 

if (!defined('_PS_VERSION_')) 
    exit; 

class glassOptics extends Module 
{ 
    /* @var boolean error */ 
    protected $_errors = false; 

    /* @var boolean puente */ 
    public $same_puente = false; 

    /* @var boolean patilla */ 
    public $same_patilla = false; 

    /* @var boolean altura cristal */ 
    public $same_altura_cristal = false; 

    /* @var boolean ancho cristal */ 
    public $same_ancho_cristal = false; 

    public function __construct() 
    { 
     $this->name = 'glassOptics'; 
     $this->tab = 'front_office_features'; 
     $this->version = '1.0'; 
     $this->author = 'Víctor Martín'; 
     $this->need_instance = 0; 

     parent::__construct(); 

     $this->displayName = $this->l('glassOptics'); 
     $this->description = $this->l('Módulo para Ópticas, de filtrado de gafas compatibles para cada cliente.'); 
    } 

    public function install() 
    { 
     if (!parent::install() OR 
      !$this->glopticasCustomerDB('add') OR 
      !$this->glopticasProductDB('add') OR 
      !$this->glopticasProductLangDB('modify') OR   
      !$this->registerHook('hookActionProductListOverride') OR    
      !$this->registerHook('DisplayAdminProductsExtra') OR    
      !$this->registerHook('ActionProductUpdate')) 
      return false; 
     return true; 
    } 

    public function uninstall() 
    { 
     if (!parent::uninstall() OR !$this->glopticasCustomerDB('remove') OR !$this->glopticasProductDB('remove')) 
      return false; 
     return true; 
    } 


    public function glopticasCustomerDB($method) 
    { 
     switch ($method) { 
      case 'add': 

       $decimal_zero = '0.000000'; 
       $decimal_zero = mysql_real_escape_string($decimal_zero); 

       $sql = 'CREATE TABLE IF EXISTS `'._DB_PREFIX_.'customer_optics_data` (
       `id_customer` int(10) UNSIGNED NOT NULL, 
       `dioptrias_izquierdo` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.', 
       `dioptrias_derecho` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.', 
       `puente` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.', 
       `patilla` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.', 
       `altura_cristal` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.', 
       `ancho_cristal` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.' 
       ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'; 

       break; 

      case 'remove': 
       $sql = 'DROP TABLE IF EXISTS `'._DB_PREFIX_ . 'customer_optics_data`'; 
       break; 
     } 

     if(!Db::getInstance()->Execute($sql)) 
      return false; 
     return true; 
    } 

    public function glopticasProductDB($method) 
    { 
     switch ($method) { 
      case 'add': 

       $decimal_zero = '0.000000'; 
       $decimal_zero = mysql_real_escape_string($decimal_zero); 

       $sql = 'CREATE TABLE IF EXISTS `'._DB_PREFIX_.'product_optics_data` (
       `id_product` int(10) UNSIGNED NOT NULL, 
       `dioptrias_izquierdo` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.', 
       `dioptrias_derecho` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.', 
       `puente` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.', 
       `patilla` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.', 
       `altura_cristal` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.', 
       `ancho_cristal` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.' 
       ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'; 

       break; 

      case 'remove': 
       $sql = 'DROP TABLE IF EXISTS `'._DB_PREFIX_ . 'product_optics_data`'; 
       break; 
     } 

     if(!Db::getInstance()->Execute($sql)) 
      return false; 
     return true; 
    } 


    public function glopticasProductLangDB($method) 
    { 
     switch ($method) { 
      case 'modify': 

       $decimal_zero = '0.000000'; 
       $decimal_zero = mysql_real_escape_string($decimal_zero); 

       $sql = 'ALTER TABLE ' . _DB_PREFIX_ . 'product_lang ' 
       .'ADD `dioptrias_izquierdo` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.',' 
       .'ADD `dioptrias_derecho` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.',' 
       .'ADD `puente` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.',' 
       .'ADD `patilla` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.',' 
       .'ADD `altura_cristal` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.',' 
       .'ADD `ancho_cristal` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.'' 
       .') ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'; 

       break; 

     } 

     if(!Db::getInstance()->Execute($sql)) 
      return false; 
     return true; 
    } 

    public function hookActionProductListOverride($params) 
    { 
     $customer_settings = glassOpticsHelperClass::getCustomerSettings($this->context->customer); 

     if (!is_null($customer_settings)) { 
      // Inform the hook was executed 
      $params['hookExecuted'] = true; 

      // Filter products here, you are now overriding the default 
      // functionality of CategoryController class. 
      // You can see blocklayered module for more details. 

      if ((isset($this->context->controller->display_column_left) && !$this->context->controller->display_column_left) 
      && (isset($this->context->controller->display_column_right) && !$this->context->controller->display_column_right)) 
      return false; 

      global $smarty; 
      if (!Configuration::getGlobalValue('PS_LAYERED_INDEXED')) 
       return; 

      $sql_cat = 'SELECT COUNT(*) FROM '._DB_PREFIX_.'layered_category WHERE id_category = '.(int)Tools::getValue('id_category', Tools::getValue('id_category_layered', Configuration::get('PS_HOME_CATEGORY'))).' 
       AND id_shop = '.(int) Context::getContext()->shop->id; 
      $categories_count = Db::getInstance()->getValue($sql_cat); 

      if ($categories_count == 0) 
       return; 

      // List of product to overrride categoryController 
      $params['catProducts'] = array(); 
      $selected_filters = $this->getSelectedFilters(); 
      $filter_block = $this->getFilterBlock($selected_filters); 
      $title = ''; 

      if (is_array($filter_block['title_values'])) 
       foreach ($filter_block['title_values'] as $key => $val) 
        $title .= ' > '.$key.' '.implode('/', $val); 

      $smarty->assign('categoryNameComplement', $title); 
      $this->getProducts($selected_filters, $params['catProducts'], $params['nbProducts'], $p, $n, $pages_nb, $start, $stop, $range); 
      // Need a nofollow on the pagination links? 
      $smarty->assign('no_follow', $filter_block['no_follow']); 

      filterProductsByConditions($customer_settings, $params['nbProducts']); 


     } 
    } 

    private static function filterProductsByConditions($customer_settings, $product_collection) { 
     if(!is_null($product_collection)){ 

      foreach ($product_collection as $product){ 
       $product_settings = glassOpticsHelperClass::getProductSettings($product); 

       if(!is_null($product_settings)){ 

        if(!is_null($product_settings->puente) AND !is_null($customer_settings->puente)){ 
         $same_puente = (($product_settings->puente == $customer_settings->puente) ? true : false); 
        }else{ 
         $same_puente = false; 
        } 

        if(!is_null($product_settings->patilla) AND !is_null($customer_settings->patilla)){ 
         $same_patilla = (($product_settings->patilla == $customer_settings->patilla) ? true : false); 
        }else{ 
         $same_patilla = false; 
        } 

        if(!is_null($product_settings->altura_cristal) AND !is_null($customer_settings->altura_cristal)){ 
         $same_altura_cristal = (($product_settings->altura_cristal == $customer_settings->altura_cristal) ? true : false); 
        }else{ 
         $same_altura_cristal = false; 
        } 

        if(!is_null($product_settings->ancho_cristal) AND !is_null($customer_settings->ancho_cristal)){ 
         $same_ancho_cristal = (($product_settings->ancho_cristal == $customer_settings->ancho_cristal) ? true : false); 
        }else{ 
         $same_ancho_cristal = false; 
        } 

        if($same_puente === false OR $same_patilla === false){ 
         unset($product_collection[$product]); 
        } 
       } 
      } 
      return $product_collection; 
     }else{ 
      return $product_collection; 
     } 
    } 
} 

私は間違っていますか?ありがとうございました。

+0

その行を削除すると何か変更されますか? –

答えて

2

あなたの$sql文の余分な閉じ括弧があります.') ENGINE='._MYSQL_ENGINE_.'

$sql = 'ALTER TABLE ' . _DB_PREFIX_ . 'product_lang ' 
.'ADD `dioptrias_izquierdo` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.',' 
.'ADD `dioptrias_derecho` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.',' 
.'ADD `puente` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.',' 
.'ADD `patilla` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.',' 
.'ADD `altura_cristal` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.',' 
.'ADD `ancho_cristal` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.'' 
.') ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'; 
1

あなたの問題はここにある:

foreach ($product_collection as $product){ 
    ... 
    unset($product_collection[$product]); 
} 

あなたは、配列のGET要素のための$keyを使用する必要があります。

foreach ($product_collection as $key => $product){ 
    ... 
    unset($product_collection[$key]); 
} 

$productは値ですeの配列要素ですが、キーは含みません。

関連する問題