Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770
Форумы портала PHP.SU :: Версия для печати :: Подскажите, что делаю не так?
Форумы портала PHP.SU » » Вопросы новичков » Подскажите, что делаю не так?

Страниц (1): [1]
 

1. artemka170691 - 16 Марта, 2017 - 13:37:44 - перейти к сообщению
Всем добрый день! Подскажите, что делаю не так?
Нужна помощь с PHP Simple HTML DOM
Изображение берется, а описание нет(

PHP:
скопировать код в буфер обмена
  1. class Licenziya extends \Infr\Supplier {
  2.  
  3.     protected $_host = 'https://www.sima-land.ru';
  4.        
  5.     protected $_productMask = 'https://www.sima-land.ru/{PRODUCT_ID}';
  6.  
  7.     protected function _getPrice() {
  8.         $class = 'Plugins\Suppliers\Supplier\Licenziya';
  9.         if (class_exists($class)) {
  10.             $supplierItem = new $class;
  11.             $pricePath = $supplierItem->getPricePath();
  12.             if (file_exists($pricePath)) {
  13.                 return file_get_contents($pricePath);
  14.             } else {
  15.                 throw new \Exception('Прайс-лист для поставщика не загружен');
  16.             }
  17.         } else {
  18.             throw new \Exception('К плагину Suppliers не подключен нужный поставщик');
  19.         }
  20.     }
  21.  
  22.     public function getProduct(Supplier $supplier, Supplier\Product $product, array $params = array()) {
  23.         if ($product->url) {
  24.             $html = \Infr\Request::httpRequest($product->url);
  25.                        
  26.                         if ($html) {
  27.                                 $dom = \Infr\str_get_html($html);
  28.  
  29.                                 if ($dom) {
  30.                                         $pict = $dom->find('a.easyzoom_large-image', 0);
  31.                                         if ($pict) {
  32.                                                 $product->pictures = array((string) $pict->getAttribute('href'));
  33.                                                 $pict->clear();
  34.                                         }
  35.  
  36.                     $techpars = $dom->find('div#tab_3.b-properties-holder', 0);
  37.                     if ($techpars) {
  38.                         $desc = '<ul class="g-ul b-properties">';
  39.  
  40.                         foreach ($techpars as $techpar) {
  41.                             $trs = $techpar->find('li');
  42.                             if ($trs) {
  43.                                 foreach ($trs as $li) {
  44.                                     $desc .= (string) $li->innertext();
  45.                                     $li->clear();
  46.                                 }
  47.                             }
  48.                             $techpar->clear();
  49.                         }
  50.  
  51.                         $desc .= '</table>';
  52.  
  53.                         $product->description = $desc;
  54.                     }
  55.  
  56.                    
  57.  
  58.                                         unset($dom);
  59.                                 }
  60.                         }
  61.             unset($html);
  62.         }
  63.  
  64.         return $product;
  65.     }

 

Powered by ExBB FM 1.0 RC1