Ejemplo n.º 1
0
 /**
  * @param ImportCategory $category
  * @return int
  */
 protected function getCategoryProductsCount($category)
 {
     /** @var \simple_html_dom $html */
     $html = $this->getHtmlDocument($category->getUrl() . (strpos($category->getUrl(), 'List?') ? '&' : '?') . 'Page=0&PageSize=1');
     $matches = array();
     return preg_match('/(?<=Page=)\\d+/', $html->findOne('div.paging span.last a')->attr['href'], $matches) ? $matches[0] + 1 : null;
 }
Ejemplo n.º 2
0
 /**
  * @param ImportCategory $category
  * @throws \Exception
  * @return int
  */
 protected function getCategoryProductsCount($category)
 {
     list($address, $query) = explode('?', $category->getUrl());
     $html = $this->getPage($address, null, "{$query}&page=1&pageSize=40", array("Content-Type" => "application/x-www-form-urlencoded; charset=UTF-8"));
     $json = json_decode($html);
     if (isset($json->totalCount)) {
         return $json->totalCount;
     } else {
         throw new \Exception("No product count is defined");
     }
 }
Ejemplo n.º 3
0
 /**
  * @param ImportCategory $category
  * @return int
  */
 protected function getCategoryProductsCount($category)
 {
     $html = $this->getHtmlDocument($category->getUrl());
     $matches = [];
     if (preg_match('/\\d+/', $html->findOne('p.prdCount')->text(), $matches)) {
         return $matches[0];
     } else {
         return null;
     }
 }