public function uninstall() { if (!$this->getUser()->hasPermission('modify', 'extension/import')) { $this->getSession()->data['notifications']['error'] = $this->language->get('error_permission'); } else { ImportSourceSiteDAO::getInstance()->removeSourceSite($this->parameters['importClass']); } $this->redirect($this->getUrl()->link('extension/import', 'token=' . $this->getSession()->data['token'], 'SSL')); }
/** * @return int */ public function getDefaultItemWeight() { if (!isset($this->defaultItemWeight)) { $this->defaultItemWeight = new Mutable(ImportSourceSiteDAO::getInstance()->getDefaultItemWeight($this->className)); } return $this->defaultItemWeight; }
/** * @return ImportSourceSite */ public function getSite() { if (is_null($this->sourceSite)) { //error_log(static::class); $this->sourceSite = ImportSourceSiteDAO::getInstance()->getSourceSite(static::class); //error_log(print_r($this->sourceSite, true)); } return $this->sourceSite; }
// error was suppressed with the @-operator if (0 === error_reporting()) { return false; } throw new ErrorException($errstr, 0, $errno, $errfile, $errline); } if ($sites = trim(file_get_contents("crawler.lck"))) { unlink("crawler.lck"); // fclose(STDIN); // fclose(STDOUT); // fclose(STDERR); // $STDIN = fopen('/dev/null', 'r'); // $STDOUT = fopen('import.log', 'wb'); // $STDERR = fopen('import.error.log', 'wb'); echo date('Y-m-d H:i:s') . " Starting\n"; $startTime = time(); try { foreach (explode(',', $sites) as $siteClassName) { $site = ImportSourceSiteDAO::getInstance()->getSourceSite($siteClassName); echo date('Y-m-d H:i:s') . " Crawling " . $site->getClassName() . "\n"; $className = 'automation\\SourceSite\\' . $site->getClassName(); /** @var \automation\ProductSource $className */ $products = $className::getInstance()->getProducts(); DatabaseManager::getInstance()->addProducts($products); DatabaseManager::getInstance()->cleanup($className::getInstance(), $startTime); } } catch (Exception $exc) { print_r($exc); die; } }
private function showList() { $filter = $this->parameters; $filter['start'] = intval(($this->parameters['page'] - 1) * $this->config->get('config_admin_limit')); $filter['limit'] = intval($this->config->get('config_admin_limit')); unset($filter['selectedItems']); foreach (ImportProductDAO::getInstance()->getImportedProducts($filter) as $product) { $productItem = $product; $productItem->actions = $this->getProductActions($product); $productItem->isSelected = in_array($product->getId(), $this->parameters['selectedItems']); $productItem->localProductUrl = $this->url->link('catalog/product/update', 'product_id=' . $product->getLocalProductId() . '&token=' . $this->parameters['token'], 'SSL'); $this->data['products'][] = $productItem; } foreach (ImportSourceSiteDAO::getInstance()->getSourceSites() as $sourceSite) { $this->data['sourceSites'][$sourceSite->getClassName()] = $sourceSite->getName(); } /// Check import running status if ($this->status()) { $this->data['textToggleImport'] = $this->language->get('STOP_IMPORT'); $this->data['importAction'] = 'stop'; } else { $this->data['textToggleImport'] = $this->language->get('START_IMPORT'); $this->data['importAction'] = 'start'; } $this->data['urlDeleteAll'] = $this->url->link('catalog/import/delete', $this->buildUrlParameterString($this->parameters) . '&what=all', 'SSL'); $this->data['urlDeleteSelected'] = $this->url->link('catalog/import/delete', $this->buildUrlParameterString($this->parameters) . '&what=selectedItems', 'SSL'); $this->data['urlDisableAll'] = $this->url->link('catalog/import/disable', $this->buildUrlParameterString($this->parameters) . '&what=all', 'SSL'); $this->data['urlDisableInactive'] = $this->url->link('catalog/import/disable', $this->buildUrlParameterString($this->parameters) . '&what=inactiveItems', 'SSL'); $this->data['urlDisableSelected'] = $this->url->link('catalog/import/disable', $this->buildUrlParameterString($this->parameters) . '&what=selectedItems', 'SSL'); $this->data['urlEnableSelected'] = $this->url->link('catalog/import/enable', $this->buildUrlParameterString($this->parameters) . '&what=selectedItems', 'SSL'); $this->data['urlSyncAll'] = $this->url->link('catalog/import/synchronize', $this->buildUrlParameterString($this->parameters) . '&what=all', 'SSL'); $this->data['urlSyncSelected'] = $this->url->link('catalog/import/synchronize', $this->buildUrlParameterString($this->parameters) . '&what=selectedItems', 'SSL'); $this->data['urlSyncSelectedNoImages'] = $this->url->link('catalog/import/synchronizeWithoutImages', $this->buildUrlParameterString($this->parameters) . '&what=selectedItems', 'SSL'); $page = $this->parameters['page']; unset($this->parameters['page']); $pagination = new Pagination($page, $this->config->get('config_admin_limit'), ImportProductDAO::getInstance()->getImportedProductsQuantity($filter), $this->language->get('text_pagination'), $this->url->link('catalog/import', $this->buildUrlParameterString($this->parameters) . '&page={page}', 'SSL')); $this->data['pagination'] = $pagination->render(); $this->data = array_merge($this->data, $this->parameters); $this->setBreadcrumbs(); $this->template = 'catalog/importProductsList.tpl.php'; $this->children = array('common/header', 'common/footer'); $this->getResponse()->setOutput($this->render()); }
/** * @param int $productId * @param string $siteClassName * @return int[] */ private function getMatchingCategories($productId, $siteClassName) { $productCategories = array(); $productSourceCategories = ImportProductDAO::getInstance()->getSourceCategories($productId); $sourceSiteCategoriesMapping = ImportSourceSiteDAO::getInstance()->getCategoriesMap($siteClassName); if (sizeof($sourceSiteCategoriesMapping)) { foreach ($productSourceCategories as $productSourceCategory) { foreach ($sourceSiteCategoriesMapping as $siteCategory) { if ($productSourceCategory == $siteCategory->getSourceSiteCategoryId()) { $productCategories = array_merge($productCategories, $siteCategory->getLocalCategoryIds()); break; } } } if (sizeof($productCategories)) { $tmp = array(); foreach ($productCategories as $productCategory) { if (!array_key_exists($productCategory, $tmp)) { $tmp[$productCategory] = null; } } $productCategories = array_keys($tmp); } sort($productCategories); } else { $productCategories = ImportSourceSiteDAO::getInstance()->getDefaultCategories($siteClassName); } return $productCategories; }