Автор Тема: Please HELP! "Invalid argument supplied for foreach()"  (Прочитано 3335 раз)

05 Сентябрь 2016, 21:12:10
  • Новичок
  • *
  • Сообщений: 13
  • Репутация: +0/-0
  • Сообщество PrestaShop
    • Просмотр профиля
Сайт на денвере. Преста 1.5.6.1

При переходе в товар(карточка товара) выдает следующее предупреждение:

1. Warning: Invalid argument supplied for foreach() in Z:\home\prestanew\www\classes\Product.php on line 2563
              на 2563 строке:
foreach ($res as $row) {
                $array_tmp = array(
                    'price' => $row['price'],
                    'ecotax' => $row['ecotax'],
                    'attribute_price' => (isset($row['attribute_price']) ? $row['attribute_price'] : null)
                );
                self::$_pricesLevel2[$cache_id_2][(int) $row['id_product_attribute']] = $array_tmp;

                if (isset($row['default_on']) && $row['default_on'] == 1)
                    self::$_pricesLevel2[$cache_id_2][0] = $array_tmp;
            }

2.Warning: Invalid argument supplied for foreach() in Z:\home\prestanew\www\classes\Hook.php on line 131
       на 131 строке:
foreach ($result as $row)
$hook_ids[strtolower($row['name'])] = $row['id_hook'];
Cache::store($cache_id, $hook_ids);

3.Warning: Invalid argument supplied for foreach() in Z:\home\prestanew\www\classes\Hook.php on line 229

foreach ($results as $result)
{
if (!isset($list[$result['id_hook']]))
$list[$result['id_hook']] = array();

4.Warning: Invalid argument supplied for foreach() in Z:\home\prestanew\www\classes\tax\TaxRulesTaxManager.php on line 95


foreach ($rows as $row)
{
$tax = new Tax((int)$row['id_tax']);

$taxes[] = $tax;

// the applied behavior correspond to the most specific rules
if ($first_row)
{
$behavior = $row['behavior'];
$first_row = false;
}

if ($row['behavior'] == 0)
break;
}

5.Warning: Invalid argument supplied for foreach() in Z:\home\prestanew\www\classes\Tab.php on line 277

foreach ($result as $row)
self::$_getIdFromClassName[strtolower($row['class_name'])] = $row['id_tab'];
}

Не судите строго - с наскоку вникнуть не удалось.
Заранее благодарю за внимание.
06 Сентябрь 2016, 09:59:49
Ответ #1
  • Модератор
  • Ветеран
  • *****
  • Сообщений: 86688
  • Репутация: +25428/-0
  • Сообщество PrestaShop
    • Просмотр профиля
Включите показ ошибок в prestashop, нужно больше информации.
12 Сентябрь 2016, 23:29:44
Ответ #2
  • Новичок
  • *
  • Сообщений: 13
  • Репутация: +0/-0
  • Сообщество PrestaShop
    • Просмотр профиля
После включения режима отображения ошибок выдал следующее(волосы дыбом встали от своей дубовости в подобных вопросах):
Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.


SELECT pa.id_product_attribute
FROM ps_product_attribute pa
INNER JOIN ps_product_attribute_shop product_attribute_shop
ON (product_attribute_shop.id_product_attribute = pa.id_product_attribute AND product_attribute_shop.id_shop = 1)
WHERE product_attribute_shop.default_on = 1  AND pa.id_product = 29 LIMIT 1

at line 613 in file classes/db/Db.php
607. WebserviceRequest::getInstance()->setError(500, '[SQL Error] '.$this->getMsgError().'. From '.(isset($dbg[3]['class']) ? $dbg[3]['class'] : '').'->'.$dbg[3]['function'].'() Query was : '.$sql, 97);
608. }
609. else if (_PS_DEBUG_SQL_ && $errno && !defined('PS_INSTALLATION_IN_PROGRESS'))
610. {
611. if ($sql)
612. throw new PrestaShopDatabaseException($this->getMsgError().'<br /><br /><pre>'.$sql.'</pre>');
613. throw new PrestaShopDatabaseException($this->getMsgError());
614. }
615. }
616.
617. /**

DbCore->displayError - [line 313 - classes/db/Db.php] - [1 Arguments]
307. if ($sql instanceof DbQuery)
308. $sql = $sql->build();
309.
310. $this->result = $this->_query($sql);
311. if (_PS_DEBUG_SQL_)
312. $this->displayError($sql);
313. return $this->result;
314. }
315.
316. /**
317. * Execute an INSERT query

DbCore->query - [line 526 - classes/db/Db.php] - [1 Arguments]
520. if ($use_cache && $this->is_cache_enabled && ($result = Cache::getInstance()->get(md5($sql))))
521. {
522. $this->last_cached = true;
523. return $result;
524. }
525. $this->result = $this->query($sql);
526. if (!$this->result)
527. return false;
528. $this->last_cached = false;
529. $result = $this->nextRow($this->result);
530. if (is_null($result))

DbCore->getRow - [line 550 - classes/db/Db.php] - [2 Arguments]
544. public function getValue($sql, $use_cache = true)
545. {
546. if ($sql instanceof DbQuery)
547. $sql = $sql->build();
548.
549. if (!$result = $this->getRow($sql, $use_cache))
550. return false;
551. return array_shift($result);
552. }
553.
554. /**

DbCore->getValue - [line 622 - classes/Product.php] - [1 Arguments]
616. ' . Shop::addSqlAssociation('product_attribute', 'pa') . '
617. ' . ($minimum_quantity > 0 ? Product::sqlStock('pa', 'pa') : '') .
618.                 ' WHERE product_attribute_shop.default_on = 1 '
619.                 . ($minimum_quantity > 0 ? ' AND IFNULL(stock.quantity, 0) >= ' . (int) $minimum_quantity : '') .
620.                 ' AND pa.id_product = ' . (int) $id_product;
621.         $result = Db::getInstance()->getValue($sql);
622.
623.         if (!$result) {
624.             $sql = 'SELECT pa.id_product_attribute
625. FROM ' . _DB_PREFIX_ . 'product_attribute pa
626. ' . Shop::addSqlAssociation('product_attribute', 'pa') . '

ProductCore::getDefaultAttribute - [line 2531 - classes/Product.php] - [1 Arguments]
2525.
2526.         if (!$use_customer_price)
2527.             $id_customer = 0;
2528.
2529.         if ($id_product_attribute === null)
2530.             $id_product_attribute = Product::getDefaultAttribute($id_product);
2531.
2532.         $cache_id = $id_product . '-' . $id_shop . '-' . $id_currency . '-' . $id_country . '-' . $id_state . '-' . $zipcode . '-' . $id_group .
2533.                 '-' . $quantity . '-' . $id_product_attribute . '-' . ($use_tax ? '1' : '0') . '-' . $decimals . '-' . ($only_reduc ? '1' : '0') .
2534.                 '-' . ($use_reduc ? '1' : '0') . '-' . $with_ecotax . '-' . $id_customer . '-' . (int) $use_group_reduction . '-' . (int) $id_cart . '-' . (int) $real_quantity;
2535.

ProductCore::priceCalculation - [line 2491 - classes/Product.php] - [20 Arguments]
2485.         if (is_null($id_customer) && Validate::isLoadedObject($context->customer))
2486.             $id_customer = $context->customer->id;
2487.
2488.         return Product::priceCalculation(
2489.                         $context->shop->id, $id_product, $id_product_attribute, $id_country, $id_state, $zipcode, $id_currency, $id_group, $cart_quantity, $usetax, $decimals, $only_reduc, $usereduc, $with_ecotax, $specific_price_output, $use_group_reduction, $id_customer, $use_customer_price, $id_cart, $quantity
2490.         );
2491.     }
2492.
2493.     /**
2494.      * Price calculation / Get product price
2495.      *

ProductCore::getPriceStatic - [line 1461 - classes/Tools.php] - [4 Arguments]
1455. }
1456.
1457. public static function orderbyPrice(&$array, $order_way)
1458. {
1459. foreach ($array as &$row)
1460. $row['price_tmp'] = Product::getPriceStatic($row['id_product'], true, ((isset($row['id_product_attribute']) && !empty($row['id_product_attribute'])) ? (int)$row['id_product_attribute'] : null), 2);
1461. if (strtolower($order_way) == 'desc')
1462. uasort($array, 'cmpPriceDesc');
1463. else
1464. uasort($array, 'cmpPriceAsc');
1465. foreach ($array as &$row)

ToolsCore::orderbyPrice - [line 1089 - classes/Product.php] - [2 Arguments]
1083.                                AND p.price BETWEEN "' . $price_start . '" AND "' . $price_end . '";             
1084. ORDER BY ' . (isset($order_by_prefix) ? pSQL($order_by_prefix) . '.' : '') . '`' . pSQL($order_by) . '` ' . pSQL($order_way) .
1085.                 ($limit > 0 ? ' LIMIT ' . (int) $start . ',' . (int) $limit : '');
1086.         $rq = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
1087.         if ($order_by == 'price')
1088.             Tools::orderbyPrice($rq, $order_way);
1089.
1090.         foreach ($rq as &$row)
1091.             $row = Product::getTaxesInformations($row);
1092.
1093.         return ($rq);

ProductCore::getProductsByPrice - [line 285 - classes/controller/FrontController.php] - [7 Arguments]
279.
280.             $productId = Tools::getValue('id_product');
281.             $product = new Product($productId, false, Configuration::get('PS_LANG_DEFAULT'), 'null');
282.
283.
284.             $products = Product::getProductsByPrice((int) Context::getContext()->language->id, 0, 10, 'price', 'ASC', $product->price, ((int) $product->price + 100));
285.             $this->context->smarty->assign(array('products_by_price' => $products));
286.
287.             //$productArr = $product->getProducts(int) Context::getContext()->language->id, 10, 5, 'price', );
288. //            $sql = new DbQuery();
289. //            $sql->select('*');

FrontControllerCore->init - [line 84 - controllers/front/ProductController.php] - [0 Argument]
78. * Initialize product controller
79. * @see FrontController::init()
80. */
81. public function init()
82. {
83. parent::init();
84.
85. if ($id_product = (int)Tools::getValue('id_product'))
86. $this->product = new Product($id_product, true, $this->context->language->id, $this->context->shop->id);
87.
88. if (!Validate::isLoadedObject($this->product))

ProductControllerCore->init - [line 150 - classes/controller/Controller.php] - [0 Argument]
144. /**
145. * Start controller process (this method shouldn't be overriden !)
146. */
147. public function run()
148. {
149. $this->init();
150. if ($this->checkAccess())
151. {
152. // setMedia MUST be called before postProcess
153. if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className)))
154. $this->setMedia();

ControllerCore->run - [line 348 - classes/Dispatcher.php] - [0 Argument]
342. // Execute hook dispatcher
343. if (isset($params_hook_action_dispatcher))
344. Hook::exec('actionDispatcher', $params_hook_action_dispatcher);
345.
346. // Running controller
347. $controller->run();
348. }
349. catch (PrestaShopException $e)
350. {
351. $e->displayMessage();
352. }

DispatcherCore->dispatch - [line 28 - index.php] - [0 Argument]
22. *  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
23. *  International Registered Trademark & Property of PrestaShop SA
24. */
25.
26. require(dirname(__FILE__).'/config/config.inc.php');
27. Dispatcher::getInstance()->dispatch();
28.
13 Сентябрь 2016, 13:33:59
Ответ #3
  • Новичок
  • *
  • Сообщений: 13
  • Репутация: +0/-0
  • Сообщество PrestaShop
    • Просмотр профиля
Неужели никто не сталкивался и не знает решение - сайт-то работал до этого, модули никакие не устанавливал...
Подскажите, пожалуйста,....кто знает :'(
13 Сентябрь 2016, 14:44:13
Ответ #4
  • Ветеран
  • *****
  • Сообщений: 1807
  • Репутация: +49/-1
  • Сообщество PrestaShop
    • Просмотр профиля
Модули, которые в таб на странице товара, удалите. В каком то из них проблема.