Beispiel #1
0
 /**
  * Generates the html error report summary after a data feed generation
  * @param \Wyomind\Simplegoogleshopping\Model\Feeds $row
  * @return string
  */
 public function generationStats($row)
 {
     $fileName = preg_replace('/^\\//', '', $row->getSimplegoogleshoppingPath() . ($row->getSimplegoogleshoppingPath() == "/" ? "" : "/") . $row->getSimplegoogleshoppingFilename());
     $this->_storeManager->setCurrentStore($row->getStoreId());
     $baseurl = $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB, false);
     $rootdir = $this->_list->getPath(\Magento\Framework\App\Filesystem\DirectoryList::ROOT);
     $url = $baseurl . $fileName;
     $url = preg_replace('/([^\\:])\\/\\//', '$1/', $url);
     if ($this->_io->fileExists($rootdir . "/" . $fileName)) {
         $report = unserialize($row->getSimplegoogleshoppingReport());
         $errors = 0;
         if (isset($report['required'])) {
             $errors += count($report['required']);
         }
         if (isset($report['toolong'])) {
             $errors += count($report['toolong']);
         }
         if (isset($report['toomany'])) {
             $errors += count($report['toomany']);
         }
         if (isset($report['invalid'])) {
             $errors += count($report['invalid']);
         }
         $warnings = 0;
         if (isset($report['recommended'])) {
             $warnings += count($report['recommended']);
         }
         $time = $report['stats'][1];
         $items = $report['stats'][0];
         $stats = $items . __(' product') . ($items > 1 ? "s" : "") . __(" exported in ") . $this->_coreHelper->getDuration($time);
         if ($report == null) {
             return '<a href="' . $url . '?r=' . time() . '" target="_blank">' . $url . '</a><br>' . "[ " . __('The data feed must be generated prior to any report.') . " ]";
         } elseif (!($errors + $warnings)) {
             return '<a href="' . $url . '?r=' . time() . '" target="_blank">' . $url . '</a><br>' . '[ ' . $stats . ", " . __('no error detected') . ' ]';
         } else {
             return '<a href="' . $url . '?r=' . time() . '" target="_blank">' . $url . '</a><br>' . '[ ' . $stats . ", " . $errors . " " . __('error') . ($errors > 1 ? "s" : null) . ', ' . $warnings . ' ' . __('warning') . ($warnings > 1 ? "s" : null) . ' ]';
         }
     } else {
         return $url . "<br> [ " . __('no report available') . " ]";
     }
 }