/** * Parses csv file * * @param string $file * @return Mage_Core_Model_Resource_Abstract */ public function parseCsv($file) { $info = pathinfo($file); $io = new Varien_Io_File(); $io->open(array('path' => $info['dirname'])); $io->streamOpen($info['basename'], 'r'); $headers = $io->streamReadCsv(); if ($headers === false) { $io->streamClose(); Mage::throwException(Mage::helper('pyro_licenses')->__('You must specify valid headers in the first row')); } if (false === ($columns = $this->_prepareColumns($headers))) { $io->streamClose(); Mage::throwException(Mage::helper('pyro_licenses')->__("Invalid header: 'License' is missed")); } $this->_write->beginTransaction(); try { $rowNumber = 1; $importData = array(); while (false !== ($csvLine = $io->streamReadCsv())) { $rowNumber++; // check for empty lines $emptyLine = array_unique($csvLine); if (count($emptyLine) == 1 && $emptyLine[0] == "") { continue; } $row = $this->_getImportRow($csvLine, $columns, $rowNumber); if ($row !== false) { $importData[] = $row; } if (count($importData) == 5000) { $this->_saveImportData($importData); $importData = array(); } } $this->_saveImportData($importData); $io->streamClose(); } catch (Mage_Core_Exception $e) { $this->_write->rollback(); $io->streamClose(); Mage::throwException($e->getMessage()); } catch (Exception $e) { $this->_write->rollback(); $io->streamClose(); Mage::logException($e); Mage::throwException(Mage::helper('adminhtml')->__($e->getMessage())); } $this->_write->commit(); if ($this->_importErrors) { $error = sprintf('ImportSubscribers: "%1$s"', implode('", "', $this->_importErrors)); Mage::log($error, 3, '', true); } return $this; }
public function getPatchefiles() { /* Mage::getBaseDir('etc') . DS . 'applied.patches.list'; */ $path = BP . DS . "app" . DS . "etc" . DS; $filename = 'applied.patches.list'; $filepath = $path . $filename; if (!file_exists($filepath)) { return "No Patch file found."; } if (!is_readable($filepath)) { return "Patch file is not readable."; } $flocal = new Varien_Io_File(); $flocal->open(array('path' => dirname($filepath))); $flocal->streamOpen($filepath, 'r'); $patch_install_version = array(); $patch_uninstall_version = array(); $patch_version = array(); while (false !== ($patchFileLines = $flocal->streamReadCsv())) { if (strpos($patchFileLines[0], 'SUPEE') !== false) { $patch_name = explode('|', $patchFileLines[0]); $patch_install_version[] = str_replace("SUPEE-", '', $patch_name[1]); } if (strpos($patchFileLines[0], 'REVERTED') !== false) { $patch_name = explode('|', $patchFileLines[0]); $patch_uninstall_version[] = str_replace("SUPEE-", '', $patch_name[1]); } } $patch_install_version = array_unique($patch_install_version); $patch_uninstall_version = array_unique($patch_uninstall_version); $patch_version = array_diff($patch_install_version, $patch_uninstall_version); return implode(",", $patch_version); }
/** * Load the import data from the csv files * * @return array */ public function loadData() { $ioHandler = new Varien_Io_File(); $ioHandler->open(array('path' => $this->getImportDir())); $debitFiles = $ioHandler->ls(Varien_Io_File::GREP_FILES); $import = array(); foreach ($debitFiles as $debitFile) { if ($debitFile['filetype'] != 'csv') { continue; } $country = str_replace('.csv', '', $debitFile['text']); $country = strtoupper($country); $import[$country] = array(); $i = 1; $ioHandler->streamOpen($debitFile['text'], 'r'); while (($line = $ioHandler->streamReadCsv()) !== false) { if ($i == 1) { $i++; continue; } // Check if routing number already exists $swiftCode = trim($line[2]); if (array_key_exists($swiftCode, $import[$country]) || empty($swiftCode)) { continue; } // Add bank to array $import[$country][$swiftCode] = array('routing_number' => trim($line[0]), 'swift_code' => $swiftCode, 'bank_name' => trim($line[1])); } $ioHandler->streamClose(); } return $import; }
/** * @$forceCreation true overwrites existing entities with the new values */ public function import($forceCreation = false) { if (is_null($this->_entity)) { throw Mage::exception('Please specify a valid entity.'); } if (!file_exists($this->_importFile)) { throw Mage::exception('Please specify a valid csv file.'); } if (is_null($this->_storeId)) { throw Mage::exception('Please specify a valid store.'); } $io = new Varien_Io_File(); $io->streamOpen($this->_importFile, 'r'); $io->streamLock(true); $firstLine = true; while (false !== ($line = $io->streamReadCsv())) { if ($firstLine) { $firstLine = false; $this->_headerColumns = $line; continue; } $data = array(); foreach ($this->_headerColumns as $key => $val) { $data[$val] = $line[$key]; } $this->_importEntity($data, $forceCreation); } }
public function uploadAndImport(Varien_Object $object) { $hlr = Mage::helper("amacart"); if (empty($_FILES['groups']['tmp_name']['import']['fields']['blacklist']['value'])) { return $this; } $csvFile = $_FILES['groups']['tmp_name']['import']['fields']['blacklist']['value']; $io = new Varien_Io_File(); $info = pathinfo($csvFile); $io->open(array('path' => $info['dirname'])); $io->streamOpen($info['basename'], 'r'); $emails = array(); while (($csvLine = $io->streamReadCsv()) !== FALSE) { foreach ($csvLine as $email) { if (!Zend_Validate::is($email, 'NotEmpty')) { } else { if (!Zend_Validate::is($email, 'EmailAddress')) { $this->_warnings[] = $email . " " . $hlr->__("not valid email"); } else { $emails[] = array("email" => $email, 'created_at' => date("Y-m-d H:i:s", time())); } } if (count($emails) == 100) { $this->saveImportData($emails); $emails = array(); } } } $this->saveImportData($emails); foreach (array_slice($this->_warnings, 0, 10) as $warning) { Mage::getSingleton('adminhtml/session')->addWarning($warning); } Mage::getSingleton('core/session')->addSuccess($hlr->__("Import completed")); }
public function importAction() { try { $productId = $this->getRequest()->getParam('id'); $fileName = $this->getRequest()->getParam('Filename'); $path = Mage::getBaseDir('var') . DS . 'import' . DS; $uploader = new Mage_Core_Model_File_Uploader('file'); $uploader->setAllowedExtensions(array('csv')); $uploader->setAllowRenameFiles(false); $uploader->setFilesDispersion(false); $result = $uploader->save($path, $fileName); $io = new Varien_Io_File(); $io->open(array('path' => $path)); $io->streamOpen($path . $fileName, 'r'); $io->streamLock(true); while ($data = $io->streamReadCsv(';', '"')) { if ($data[0]) { $model = Mage::getModel('giftcards/pregenerated')->load($data[0], 'card_code'); if ($model->getId()) { continue; } $model->setCardCode($data[0]); $model->setCardStatus(1); $model->setProductId($productId); $model->save(); } else { continue; } } } catch (Exception $e) { $result = array('error' => $e->getMessage(), 'errorcode' => $e->getCode()); } $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); }
public function saveImportAction() { $request = $this->getRequest(); $importConfig = new Varien_Object(); $path = ''; $delimiter = $request->getParam('delimiter', false); $enclosure = $request->getParam('enclosure', false); $importConfig->setFilePath($path)->setDelimiter($delimiter)->setEnclosure($enclosure); try { $file = $_FILES['file']['name']; $path = Mage::getBaseDir('var') . DS . 'import' . DS; $uploader = new Varien_File_Uploader('file'); $uploader->setAllowRenameFiles(false); $uploader->setFilesDispersion(false); $uploader->save($path, $file); $io = new Varien_Io_File(); $io->open(array('path' => $path)); $io->streamOpen($path . $file, 'r'); $io->streamLock(true); $map = $io->streamReadCsv($delimiter, $enclosure); $prodModel = Mage::getSingleton('catalog/product'); $db = Mage::getSingleton('core/resource')->getConnection('core_write'); $db->query('set foreign_key_checks = 0'); while ($data = $io->streamReadCsv($delimiter, $enclosure)) { $prod = $prodModel->loadByAttribute('sku', $data[2]); if (!$prod || !$prod->getId()) { continue; } $prices = Mage::getModel('customerprices/prices'); $prices->loadByCustomer($prod->getId(), $data[0], $data[3]); $prices->setProductId($prod->getId()); $prices->setCustomerId($data[0]); $prices->setCustomerEmail($data[1]); $prices->setQty($data[3]); $prices->setPrice($data[4]); $prices->setSpecialPrice($data[5]); $prices->save(); } Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('customerprices')->__('Prices where succesfully imported ')); } catch (Mage_Core_Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); } catch (Exception $e) { //Mage::getSingleton('adminhtml/session')->addError(Mage::helper('customergroupsprice')->__($e->getMessage().'An error occurred while importing prices.')); Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); } $this->getResponse()->setRedirect($this->getUrl("*/*/import")); }
public function _afterSave() { if (empty(@$_FILES['groups']['tmp_name']['svea_general']['fields']['import_customer_addresses']['value'])) { return $this; } else { try { $csvFile = $_FILES['groups']['tmp_name']['svea_general']['fields']['import_customer_addresses']['value']; $io = new Varien_Io_File(); $info = pathinfo($csvFile); $io->open(array('path' => $info['dirname'])); $io->streamOpen($info['basename'], 'r'); // delete all current rows $resource = Mage::getSingleton('core/resource'); $connection = $resource->getConnection('core_write'); $connection->query("DELETE FROM {$resource->getTableName('svea_webpay/customer_address')}"); // read header $header = array(); foreach ($io->streamReadCsv(';') as $k => $v) { $header[$k] = $this->_fileHeaderMapping[$this->_convertCsvString($v)]; } // Import rows while ($row = $io->streamReadCsv(';')) { $row = array_combine($header, $row); foreach ($row as $k => $v) { $row[$k] = $this->_convertCsvString($v); } if ($row['status'] !== 'Active') { continue; } // Split name into first and last name foreach ($this->_splitName($row['name']) as $k => $v) { $row[$k] = $v; } unset($row['name']); $model = Mage::getModel('svea_webpay/customer_address'); $model->setOrgnr($row['nationalIdNumber']); $model->setCountryCode($row['countryCode']); $model->setAddress($row); $model->save(); } $io->streamClose(); } catch (Exception $e) { Mage::logException($e); throw new Mage_Exception(Mage::helper('svea_webpay')->__("Failed to import customer addresses.")); } } }
public function cronImportAction() { $request = $this->getRequest(); $path = $request->getParam('path', false); $delimiter = $request->getParam('delimiter', ';'); $enclosure = $request->getParam('enclosure', '"'); try { $io = new Varien_Io_File(); $io->streamOpen(Mage::getBaseDir() . $path, 'r'); $io->streamLock(true); $map = $io->streamReadCsv($delimiter, $enclosure); $prodModel = Mage::getSingleton('catalog/product'); $db = Mage::getSingleton('core/resource')->getConnection('core_write'); $db->query('set foreign_key_checks = 0'); $db->query("delete from {$db->getTableName('customerprices_prices')}"); $errors = array(); while ($data = $io->streamReadCsv($delimiter, $enclosure)) { $prod = $prodModel->loadByAttribute('sku', $data[1]); if (!$prod || !$prod->getId()) { continue; } $customer = Mage::getModel('customer/customer')->setWebsiteId(1)->loadByEmail($data[0]); if (!$customer->getId()) { Mage::log('Customer not exist - ' . $data[0], null, 'Customerprices_import.log'); $errors[] = $data[0]; continue; } $prices = Mage::getModel('customerprices/prices'); $prices->setProductId($prod->getId()); $prices->setCustomerEmail($data[0]); $prices->setCustomerId($customer->getId()); $prices->setQty($data[2]); $prices->setPrice($data[3]); $prices->setSpecialPrice($data[4]); $prices->save(); } echo 'FINISHED' . "\n"; if (count($errors)) { echo "Check Customerprices_import.log for errors"; } } catch (Mage_Core_Exception $e) { echo $e->getMessage(); } catch (Exception $e) { echo $e->getMessage(); } }
public function saveAction() { $request = $this->getRequest(); $path = ''; $delimiter = $request->getParam('delimiter', false); $enclosure = $request->getParam('enclosure', false); try { $file = $_FILES['file']['name']; $path = Mage::getBaseDir('var') . DS . 'import' . DS; $uploader = new Varien_File_Uploader('file'); $uploader->setAllowRenameFiles(false); $uploader->setFilesDispersion(false); $uploader->save($path, $file); $io = new Varien_Io_File(); $io->open(array('path' => $path)); $io->streamOpen($path . $file, 'r'); $io->streamLock(true); $map = $io->streamReadCsv($delimiter, $enclosure); while ($data = $io->streamReadCsv($delimiter, $enclosure)) { if ($data[0]) { $model = Mage::getModel('giftcards/giftcards'); $model->setCardAmount($data[1]); $model->setCardCode($data[0]); $model->setCardStatus(1); $model->save(); } else { continue; } } Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('giftcards')->__('Gift Cards where succesfully imported ')); } catch (Mage_Core_Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError(Mage::helper('giftcards')->__($e->getMessage() . 'An error occurred while importing Gift Cards.')); } $this->getResponse()->setRedirect($this->getUrl("*/*/index")); }
/** * Returns the bankname by given blz * * @param string $blz BLZ * @return null|string Bank Name */ public function getBankByBlz($blz) { $data = $this->_loadBlzCache(); if (!$data) { // open blz file handle $file = new Varien_Io_File(); $file->open(array('path' => Mage::getModuleDir('etc', 'Itabs_Debit'))); $file->streamOpen('bankleitzahlen.csv', 'r'); // read csv stream while (($line = $file->streamReadCsv(';')) !== false) { $data[$line[0]] = $line[1]; } $this->_saveBlzCache(serialize($data)); } else { $data = unserialize($data); } return empty($data[$blz]) ? null : $data[$blz]; }
/** * Upload store csv file and import data from it * * @throws Mage_Core_Exception * @param Varien_Object $object * @return Bluehorse_Storelocator_Model_Storelocator */ public function uploadAndImport($object) { $this->_behavior = $object->getRequest()->getPost('behavior'); $importFile = $_FILES['import_file']; if (empty($importFile['tmp_name'])) { return; } $csvFile = $importFile['tmp_name']; $this->_importErrors = array(); $this->_importedRows = 0; $io = new Varien_Io_File(); $info = pathinfo($csvFile); $io->open(array('path' => $info['dirname'])); $io->streamOpen($info['basename'], 'r'); // check and skip headers $headers = $io->streamReadCsv(); if ($headers === false || count($headers) < 19) { $io->streamClose(); Mage::throwException(Mage::helper('bluehorse_storelocator')->__('Invalid Stores File Format')); } $adapter = $this->_getWriteAdapter(); $adapter->beginTransaction(); try { $rowNumber = 1; $importData = array(); while (false !== ($csvLine = $io->streamReadCsv())) { $rowNumber++; if (empty($csvLine)) { continue; } $row = $this->_getImportRow($csvLine, $rowNumber); if ($row !== false) { $importData[] = $row; } if (count($importData) == 5000) { $this->_saveImportData($importData); $importData = array(); } } if ($this->_importErrors) { $error = Mage::helper('bluehorse_storelocator')->__('File has not been imported. See the following list of errors: <br>%s', implode(" <br>", $this->_importErrors)); Mage::throwException($error); } if (empty($this->_importErrors)) { $this->_saveImportData($importData); } $io->streamClose(); } catch (Mage_Core_Exception $e) { $adapter->rollback(); $io->streamClose(); Mage::throwException($e->getMessage()); } catch (Exception $e) { $adapter->rollback(); $io->streamClose(); Mage::logException($e); Mage::throwException(Mage::helper('bluehorse_storelocator')->__('An error occurred while import stores csv.')); } $adapter->commit(); //add success message Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('bluehorse_storelocator')->__($this->_importedRows . ' - Rows imported successfully.')); return $this; }
public function loadfileAction() { $tmp_file = $this->getRequest()->getParam('file'); if ($this->getRequest()->getParam('file_system_type') === "1") { $content = $this->downloadFile(); if (is_array($content)) { $rtn['status'] = 'error'; $rtn['body'] = $content[0]; die(json_encode($rtn)); } else { $tmp_file = $content; } } $io = new Varien_Io_File(); $realPath = $io->getCleanPath(Mage::getBaseDir() . '/' . $tmp_file); if ($tmp_file == '') { $rtn['status'] = 'error'; $rtn['body'] = Mage::helper('massstockupdate')->__('File path can\'t be empty.'); } elseif (stripos($tmp_file, 'csv') < 1 && stripos($tmp_file, 'xml') < 1) { $rtn['status'] = 'error'; $rtn['body'] = Mage::helper('massstockupdate')->__('Wrong file type. "%s" must be a csv or xml file.', $realPath); } elseif (!$io->fileExists($realPath, false)) { $rtn['status'] = 'error'; $rtn['body'] = Mage::helper('massstockupdate')->__('Wrong file path. "%s" is not a file.', $realPath); } elseif (!is_readable($realPath)) { $rtn['status'] = 'error'; $rtn['body'] = Mage::helper('massstockupdate')->__('Please make sure that "%s" is readable by web-server.', $realPath); } else { $rtn['status'] = 'valid'; if ($this->getRequest()->getParam('file_type') == 1) { // xml $csv_file = $this->transformXmlToCsv($realPath, $this->getRequest()->getParam('xpath'), 1000); if (is_array($csv_file)) { $rtn['status'] = 'error'; $rtn['body'] = $csv_file[0]; die(json_encode($rtn)); } $realPath = $io->getCleanPath(Mage::getBaseDir() . '/' . $csv_file); } if ($this->getRequest()->getParam('file_type') === "1") { $fileSeparator = ";"; $fileEnclosure = "none"; } else { $fileSeparator = $this->getRequest()->getParam('separator'); $fileEnclosure = $this->getRequest()->getParam('enclosure'); } $io->streamOpen($realPath, 'r'); $rtn = array(); $i = 0; if (Mage::helper('core')->isModuleEnabled('Wyomind_Advancedinventory')) { $places = Mage::getModel('pointofsale/pointofsale')->getPlaces(); foreach ($places as $p) { $rtn["places"][$i]['label'] = $p->getName(); $rtn["places"][$i]['value'] = $p->getPlaceId(); $rtn["places"][$i]['id'] = $p->getPlaceId(); $rtn["places"][$i]['style'] = "store " . $p->getPlaceId(); $i++; } $rtn["places"][$i]['label'] = "Manage Local Stock"; $rtn["places"][$i]['value'] = "manage_local_stock"; $rtn["places"][$i]['id'] = 'manage_local_stock'; $rtn["places"][$i]['style'] = "manage_local_stock"; $i++; } if ($this->getRequest()->getParam('autoSetInStock') == "0") { $rtn["places"][$i]['label'] = "Stock status"; $rtn["places"][$i]['value'] = "is_in_stock"; $rtn["places"][$i]['id'] = 'is_in_stock'; $rtn["places"][$i]['style'] = "is_in_stock"; $i++; } /* if ($this->getRequest()->getParam('autoSetManageStock') == "0") { $rtn["places"][$i]['label'] = "Manage stock"; $rtn["places"][$i]['value'] = "manage_stock"; $rtn["places"][$i]['id'] = 'manage_stock'; $rtn["places"][$i]['style'] = "manage_stock"; $i++; } */ // if total stock are not sync with local stocks or if total stock are sync with local stocks but sync is done by user if ($this->getRequest()->getParam('autoSetTotal') == "0") { $rtn["places"][$i]['label'] = "Total Stock"; $rtn["places"][$i]['value'] = "total"; $rtn["places"][$i]['id'] = 'total'; $rtn["places"][$i]['style'] = "total"; $i++; } else { $rtn["places"][$i]['label'] = "used"; $rtn["places"][$i]['value'] = "used"; $rtn["places"][$i]['id'] = 'used'; $rtn["places"][$i]['style'] = "used"; $i++; } $resource = Mage::getSingleton('core/resource'); $read = $resource->getConnection('core_read'); $tableEet = $resource->getTableName('eav_entity_type'); $select = $read->select()->from($tableEet)->where('entity_type_code=\'catalog_product\''); $data = $read->fetchAll($select); $typeId = $data[0]['entity_type_id']; function cmp($a, $b) { return $a['attribute_code'] < $b['attribute_code'] ? -1 : 1; } /* Liste des attributs disponible dans la bdd */ $attributesList = Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter($typeId)->addSetInfo()->getData(); usort($attributesList, "cmp"); foreach ($attributesList as $attribute) { if (!empty($attribute['frontend_label'])) { $rtn["places"][$i]['label'] = $attribute['attribute_code']; $rtn["places"][$i]['value'] = $attribute['attribute_code']; $rtn["places"][$i]['id'] = "attribute-" . $attribute['attribute_code'] . "-" . $attribute['attribute_id'] . "-" . $attribute['backend_type']; $rtn["places"][$i]['style'] = "attribute"; $i++; } } $rtn["places"][$i]['label'] = "not used"; $rtn["places"][$i]['value'] = "not-used"; $rtn["places"][$i]['id'] = 'not-used'; $rtn["places"][$i]['style'] = "not-used"; $i++; $sku_offset = $this->getRequest()->getParam('skuOffset'); $offset = $sku_offset - 1; $l = 0; if ($fileEnclosure != "none") { while (false !== ($csvLine = $io->streamReadCsv($fileSeparator, $fileEnclosure)) && $l < 1000) { $skus = array_splice($csvLine, $offset, 1); array_unshift($csvLine, $skus[0]); if (strlen($csvLine[0]) > 50) { $csvLine[0] = '<span title="' . $csvLine[0] . '">' . substr($csvLine[0], 0, 50) . '...' . '</span>'; } $rtn['body'][$l] = $csvLine; $rtn['body'][$l][] = 0; $l++; } } else { while (false !== ($csvLine = $io->streamReadCsv($fileSeparator)) && $l < 1000) { $skus = array_splice($csvLine, $offset, 1); array_unshift($csvLine, $skus[0]); if (strlen($csvLine[0]) > 50) { $csvLine[0] = '<span title="' . $csvLine[0] . '">' . substr($csvLine[0], 0, 50) . '...' . '</span>'; } $rtn['body'][$l] = $csvLine; $rtn['body'][$l][] = 0; $l++; } } $io->streamClose(); if ($this->getRequest()->getParam('useCustomRules')) { $rules = $this->getRequest()->getParam('customRules'); foreach ($rtn['body'] as $i => $line) { eval(str_replace('$C[', '$line[', $rules)); $rtn['body'][$i] = $line; } } } die(json_encode($rtn)); }
public function importvalidateAction() { $this->_validateCustomerLogin(); $session = $this->_getSession(); $this->_initLayoutMessages('marketplace/session'); $data = $this->getRequest()->getPost(); $time = time(); if ($data) { try { $marketplaceHelper = Mage::helper('marketplace'); $customer = Mage::getSingleton('customer/session')->getCustomer(); $productState = $customer->getSellerProductState(); $productStatus = $customer->getSellerProductStatus(); $newProductStatus = $productStatus ? $productStatus : $marketplaceHelper->getNewProductStatus(); $newProductState = $productState ? $productState : $marketplaceHelper->getNewProductState(); $newProductStateValue = Mage::getModel('eav/config')->getAttribute('catalog_product', 'marketplace_state')->getSource()->getOptionText($newProductState); $this->loadLayout(); /** @var $import Mage_ImportExport_Model_Import */ $import = Mage::getModel('importexport/import'); $source = $import->setData($data)->uploadSource(); // Modify CSV file $io = new Varien_Io_File(); $io->streamOpen($source, 'r'); $io->streamLock(true); $newCsvData = array(); $i = 0; while ($data = $io->streamReadCsv()) { if ($i == 0) { $data[] = '_attribute_set'; $data[] = '_type'; $data[] = '_product_websites'; $data[] = 'tax_class_id'; $data[] = 'visibility'; $data[] = 'seller_id'; $data[] = 'marketplace_state'; $data[] = 'status'; $data[] = 'media_gallery'; $newCsvData[] = $data; } else { $data[] = 'Default'; $data[] = Mage_Catalog_Model_Product_Type::DEFAULT_TYPE; $data[] = 'base'; $data[] = 0; $data[] = $marketplaceHelper->getNewProductVisibility(); $data[] = $customer->getCompanyName(); $data[] = $newProductStateValue; $data[] = $newProductStatus; $data[] = ' '; if ($this->validateSellerCSV($data)) { $newCsvData[] = $data; } } $i++; } $io->close(); unlink($source); $checkPath = Mage::getBaseDir() . DS . 'media' . DS . 'marketplace/' . $customer->getId(); if (!file_exists($checkPath)) { mkdir($checkPath, 0777); } $newSource = $checkPath . DS . 'productimport.csv'; $io = new Varien_File_Csv(); $io->saveData($newSource, $newCsvData); $validationResult = $import->validateSource($newSource); if (!$import->getProcessedRowsCount()) { $session->addError($this->__('File does not contain data or duplicate sku. Please upload another one')); } else { if (!$validationResult) { if ($import->getProcessedRowsCount() == $import->getInvalidRowsCount()) { $session->addNotice($this->__('File is totally invalid. Please fix errors and re-upload file')); } elseif ($import->getErrorsCount() >= $import->getErrorsLimit()) { $session->addNotice($this->__('Errors limit (%d) reached. Please fix errors and re-upload file', $import->getErrorsLimit())); } else { if ($import->isImportAllowed()) { $session->addNotice($this->__('Please fix errors and re-upload file or simply press "Import" button to skip rows with errors'), true); } else { $session->addNotice($this->__('File is partially valid, but import is not possible'), false); } } // errors info foreach ($import->getErrors() as $errorCode => $rows) { $error = $errorCode . ' ' . $this->__('in rows:') . ' ' . implode(', ', $rows); $session->addError($error); } } else { if ($import->isImportAllowed()) { $import->importSource(); //Process Images $status = $this->_uploadZipImages($time); if ($status !== false) { if ($status[0] == 'success') { $returnVal = Mage::getModel('marketplace/image')->process($newCsvData, $customer->getId(), $time); if ($returnVal === true) { $customDir = Mage::getBaseDir() . DS . 'media' . DS . 'marketplace' . DS . $customer->getId() . DS . $time; self::delTree($customDir); } $session->addSuccess($this->__($status[1]), true); } else { $session->addError($this->__($status[1])); } } $import->invalidateIndex(); $session->addSuccess($this->__('Import successfully done.'), true); $this->_redirect('*/*/import'); } else { $session->addError($this->__('File is valid, but import is not possible'), false); } } $session->addNotice($import->getNotices()); $session->addNotice($this->__('Checked rows: %d, checked entities: %d, invalid rows: %d, total errors: %d', $import->getProcessedRowsCount(), $import->getProcessedEntitiesCount(), $import->getInvalidRowsCount(), $import->getErrorsCount())); } } catch (Exception $e) { $session->addNotice($this->__('Please fix errors and re-upload file'))->addError($e->getMessage()); } } elseif ($this->getRequest()->isPost() && empty($_FILES)) { $session->addError($this->__('File was not uploaded')); } else { $session->addError($this->__('Data is invalid or file is not uploaded')); } $this->_redirect('*/*/import'); }
public function generateXml() { $x147 = "str_replace"; $x148 = "utf8_encode"; $x149 = "preg_match_all"; $x14a = "preg_match"; $x14b = "is_null"; $x14c = "number_format"; $x14d = "is_numeric"; $x14e = "preg_split"; $x14f = "utf8_decode"; $x150 = "is_string"; $x151 = "json_decode"; $x152 = "is_array"; $x153 = "array_push"; $x154 = "print_r"; $x155 = "version_compare"; $x156 = "in_array"; $x157 = "array_pop"; $x158 = "str_pad"; $x159 = "array_shift"; $x15a = "array_reverse"; $x15b = "array_values"; $x15c = "preg_replace"; $x15d = "strip_tags"; $x15e = "html_entity_decode"; $x15f = "mb_strtolower"; $x160 = "mb_strtoupper"; Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> --------------- START PROCESS FOR " . strtoupper($this->x165(false)) . "-----------------", null, $this->x165('.log')); ini_set('memory_limit', Mage::getStoreConfig("simplegoogleshopping/system/memory_limit") . 'M'); $this->_debug = isset($_GET['debug']) ? true : false; include Mage::getBaseDir() . "/lib/Wyomind/Google/Requirements.php"; $x3a = new Varien_Io_File(); $x4f = new Varien_Io_File(); $x52 = Mage::getBaseDir() . DS . 'var' . DS . 'tmp' . DS; $x53 = $x52 . "sgs_" . $this->getSimplegoogleshoppingId() . ".flag"; $x3a->setAllowCreateFolders(true); if (!$this->_display) { $x3a->open(array('path' => $this->getPath())); if ($x3a->fileExists($this->x165()) && !$x3a->isWriteable($this->x165())) { Mage::throwException(Mage::helper('simplegoogleshopping')->__('File "\\x25\\x73" cannot be saved. Please, make sure the directory "\\x25\\x73" is writeable by web server.', $this->x165(), $this->getPath())); } $x3a->streamOpen($this->x165()); $x4f->open(array('path' => $x52)); if ($x4f->fileExists($x53, false)) { $x4f->streamOpen($x53, 'r'); $x4d = $x4f->streamReadCsv(";"); $x54 = $x4f->streamStat(); if ($x4d[0] == "PROCESSING") { $x55 = $x54["mtime"]; $x56 = $x4d[3]; if (!(Mage::getSingleton('core/date')->gmtTimestamp() > $x55 + $x56 * 10 || Mage::getSingleton('core/date')->gmtTimestamp() > $x55 + $x56 * 2)) { Mage::throwException(Mage::helper('simplegoogleshopping')->__('File "\\x25\\x73" is already processing. Please wait the end of the process.', $this->x165(), $this->getPath())); } } } else { $x4f->streamOpen($x53); } } $x57 = array("ac" => "activation_code", "ak" => "activation_key", "bu" => "base_url", "md" => "md5", "th" => "this", "dm" => "_demo", "ext" => "sgs", "ver" => "9.0.1"); $x150(Mage::app()->getRequest()->getParam("store_id")) ? $x58 = Mage::app()->getRequest()->getParam("store_id") : ($x58 = $this->getStoreId()); $x59 = Mage::getSingleton('core/date')->gmtDate('Y-m-d'); $x5a = Mage::getDesign()->getSkinUrl(); $x5b = Mage::getStoreConfig("catalog/placeholder/image_placeholder", $x58); $x5c = Mage::getStoreConfig("currency/options/base", $x58); $x5d = Mage::getStoreConfig("cataloginventory/item_options/manage_stock", $x58); $x5e = Mage::getStoreConfig("cataloginventory/item_options/backorders", $x58); $x5f = Mage::app()->getStore($x58)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, false); $x60 = Mage::getModel('core/store')->load($x58)->getBaseUrl(); $x61 = Mage::app()->getStore($x58)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA, false); $x62 = Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX, $x58); $x63 = Mage::app()->getStore($x58)->getRootCategoryId(); $x64 = Mage::app()->getStore()->getStoreId(); $x65 = array("activation_key" => Mage::getStoreConfig("simplegoogleshopping/license/activation_key"), "activation_code" => Mage::getStoreConfig("simplegoogleshopping/license/activation_code"), "base_url" => Mage::getStoreConfig("web/secure/base_url")); $x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_xmlitempattern")) ? $x66 = Mage::app()->getRequest()->getParam("simplegoogleshopping_xmlitempattern") : ($x66 = $this->getSimplegoogleshoppingXmlitempattern()); $x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_title")) ? $x67 = Mage::app()->getRequest()->getParam("simplegoogleshopping_title") : ($x67 = $this->getSimplegoogleshoppingTitle()); $x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_description")) ? $x68 = Mage::app()->getRequest()->getParam("simplegoogleshopping_description") : ($x68 = $this->getSimplegoogleshoppingDescription()); $x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_categories")) ? $x69 = $x151(Mage::app()->getRequest()->getParam("simplegoogleshopping_categories")) : ($x69 = $x151($this->getSimplegoogleshoppingCategories())); $x150(Mage::app()->getRequest()->getParam("category_filter")) ? $x6a = Mage::app()->getRequest()->getParam("category_filter") : ($x6a = $this->getSimplegoogleshoppingCategoryFilter()); $x150(Mage::app()->getRequest()->getParam("category_type")) ? $x6b = Mage::app()->getRequest()->getParam("category_type") : ($x6b = $this->getSimplegoogleshoppingCategoryType()); $x6c = array(); $x6d = array(); if ($x152($x69)) { foreach ($x69 as $x6e) { if ($x6e->checked) { $x6c[] = $x6e->line; } } foreach ($x69 as $x6e) { if ($x6e->mapping != "") { $x6d[$x6e->line] = $x6e->mapping; } } } if (count($x6c) < 1) { $x6c[] = '*'; } $x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_type_ids")) ? $x6f = explode(',', Mage::app()->getRequest()->getParam("simplegoogleshopping_type_ids")) : ($x6f = explode(',', $this->getSimplegoogleshoppingTypeIds())); $x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_visibility")) ? $x70 = explode(',', Mage::app()->getRequest()->getParam("simplegoogleshopping_visibility")) : ($x70 = explode(',', $this->getSimplegoogleshoppingVisibility())); $x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_attributes")) ? $x71 = $x151(Mage::app()->getRequest()->getParam("simplegoogleshopping_attributes")) : ($x71 = $x151($this->getSimplegoogleshoppingAttributes())); $x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_attribute_sets")) ? $x72 = explode(',', Mage::app()->getRequest()->getParam("simplegoogleshopping_attribute_sets")) : ($x72 = explode(',', $this->getSimplegoogleshoppingAttributeSets())); if ($x65[$x57['ac']] != $x57["md"]($x57["md"]($x65[$x57['ak']]) . $x57["md"]($x65[$x57['bu']]) . $x57["md"]($x57["ext"]) . $x57["md"]($x57["ver"]))) { ${$x57}["ext"] = "valid"; ${$x57}["th"]->{$x57}["dm"] = true; } else { ${$x57}["th"]->{$x57}["dm"] = false; ${$x57}["ext"] = "valid"; } $x73 = ''; $x74 = ''; header("Content-Type: text/html; charset=utf-8"); $x73 = '<?xml version="1.0" encoding="utf-8" ?>' . "\n"; $x73 .= '<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">' . "\n"; $x73 .= '<channel>' . "\n"; $x73 .= '<title>' . $x67 . "</title>\n"; $x73 .= '<link>' . substr($x5f, 0, -1) . "</link>\n"; $x73 .= '<description>' . $x68 . "</description>\n"; if (!isset(${$x57}["ext"]) || ${$x57}["th"]->{$x57}["dm"]) { ${$x57}["th"]->{$x57}["dm"] = true; return ${$x57}["th"]; } if ($this->_display) { $x74 = $this->x169($x73); } else { $x3a->streamWrite($this->x169($x73)); $this->x16a($x4f, $x53, "PROCESSINGØ;100;˜"); Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " . $this->x165() . " created and opened", null, $this->x165('.log')); } $x35 = '/{([a-zA-Z_0-9:]+)(\\sparent|\\sgrouped|\\sconfigurable|\\sbundle)?([^}|]*)(\\s?\\|\\s?)?(([a-zA-Z_0-9:]+)(\\sparent|\\sgrouped|\\sconfigurable|\\sbundle)?([^}|]*))?(\\s?\\|\\s?)?(([a-zA-Z_0-9:]+)(\\sparent|\\sgrouped|\\sconfigurable|\\sbundle)?([^}|]*))?(\\s?\\|\\s?)?(([a-zA-Z_0-9:]+)(\\sparent|\\sgrouped|\\sconfigurable|\\sbundle)?([^}|]*))?}/'; $x149($x35, $x66, $x36); foreach ($x36[6] as $x37 => $x75) { if ($x75 != "") { $x36[0][] = $x36[0][$x37]; $x36[1][] = $x75; $x36[2][] = $x36[7][$x37]; $x36[3][] = $x36[8][$x37]; $x36[4][] = $x36[9][$x37]; } } foreach ($x36[11] as $x37 => $x75) { if ($x75 != "") { $x36[0][] = $x36[0][$x37]; $x36[1][] = $x75; $x36[2][] = $x36[7][$x37]; $x36[3][] = $x36[8][$x37]; $x36[4][] = $x36[9][$x37]; } } foreach ($x36[16] as $x37 => $x75) { if ($x75 != "") { $x36[0][] = $x36[0][$x37]; $x36[1][] = $x75; $x36[2][] = $x36[7][$x37]; $x36[3][] = $x36[8][$x37]; $x36[4][] = $x36[9][$x37]; } } $x36[0][] = "{categories,[1],[1],[1]}"; $x36[1][] = "categories"; $x36[2][] = ""; $x36[3][] = ",[1],[1],[1]"; $x76 = array(); $x77 = array(); foreach ($x36[1] as $x37 => $x75) { $x76[$x37]['methodName'] = "get" . $x147(' ', '', ucwords(trim($x75)) . '()'); $x76[$x37]['pattern'] = "{" . trim($x75) . "}"; $x76[$x37]['fullpattern'] = $x36[0][$x37]; $x76[$x37]['name'] = trim($x75); $x76[$x37]['reference'] = trim($x36[2][$x37]); if (empty($x76[$x37]['reference'])) { $x76[$x37]['reference'] = 'self'; } switch ($x76[$x37]['name']) { case 'url': $x153($x77, 'url_key'); break; case 'uri': $x153($x77, 'url_key'); break; case 'G:ID': $x153($x77, 'sku'); break; case 'G:TITLE': $x153($x77, 'name'); break; case 'G:DESCRIPTION': $x153($x77, 'short_description'); $x153($x77, 'description'); break; case 'G:IMAGE_LINK': $x153($x77, 'image'); $x153($x77, 'small_image'); $x153($x77, 'thumbnail'); break; case 'SC:IMAGES': $x153($x77, 'image'); $x153($x77, 'small_image'); $x153($x77, 'thumbnail'); break; case 'SC:DESCRIPTION': $x153($x77, 'description'); $x153($x77, 'short_description'); $x153($x77, 'manufacturer'); $x153($x77, 'name'); $x153($x77, 'sku'); break; case 'SC:EAN': $x153($x77, 'ean'); break; case 'SC:URL': $x153($x77, 'url_key'); $x153($x77, 'url'); break; default: $x153($x77, $x76[$x37]['name']); } $x76[$x37]["value"] = '$product->get' . $x76[$x37]['name'] . "()"; $x76[$x37]["getText"] = 'getAttributeText(\'' . trim($x75) . '\')'; $x78 = '/\\[([^\\]]+)\\]/'; $x149($x78, $x36[3][$x37], $x79); $x76[$x37]["options"] = $x79[1]; } if ($this->_debug) { echo "----------------------------------------------<br>\r ------------ DEBUG MODE ----------------<br>\r\n ----------------------------------------------<br><br>"; echo "<br><br>------------ ATTRIBUTES ----------------<br>"; $x154($x76); } Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Product template analyzed", null, $this->x165('.log')); $x7a = Mage::getModel('catalog/category')->getCollection()->setStoreId($x58)->addAttributeToSelect('name', 'store_id')->addAttributeToSelect('is_active')->addAttributeToSelect('include_in_menu'); $x7b = array(); foreach ($x7a as $x7c) { $x7b[$x7c->getId()]['name'] = $x7c->getName(); $x7b[$x7c->getId()]['path'] = $x7c->getPath(); $x7b[$x7c->getId()]['level'] = $x7c->getLevel(); if ($x155(Mage::getVersion(), '1.6.0', '<') || Mage::getStoreConfig("simplegoogleshopping/system/include_in_menu")) { $x7b[$x7c->getId()]['include_in_menu'] = true; } else { $x7b[$x7c->getId()]['include_in_menu'] = $x7c->getIncludeInMenu(); } } if ($this->_debug) { echo "<br><br>------------ CATEGORIES ----------------<br>"; $x154($x7b); } Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Categories collected", null, $this->x165('.log')); $x7d = Mage::getSingleton('core/resource'); $x7e = $x7d->getConnection('core_read'); $x7f = $x7d->getTableName('eav_entity_type'); $x80 = $x7e->select()->from($x7f)->where('entity_type_code=\'catalog_product\''); $x81 = $x7e->fetchAll($x80); $x82 = $x81[0]['entity_type_id']; $x7d = Mage::getSingleton('core/resource'); $x7e = $x7d->getConnection('core_read'); $x83 = $x7d->getTableName('directory_currency_rate'); $x80 = $x7e->select()->from($x83)->where('currency_from=\'' . $x5c . '\''); $x40 = $x7e->fetchAll($x80); $x84 = array(); foreach ($x40 as $x3f) { $x84[$x3f['currency_to']] = $x3f['rate']; } $this->_currencies = $x84; if ($this->_debug) { echo "<br><br>------------ CURRENCIES ----------------<br>"; $x154($x84); } Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Currencies rate collected", null, $this->x165('.log')); $x85 = Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter($x82)->addSetInfo()->getData(); $x86 = array(); $x87 = array(); foreach ($x85 as $x37 => $x75) { if ($x156($x75['attribute_code'], $x77)) { $x153($x86, $x75['attribute_code']); $x87[$x75['attribute_code']] = $x75['frontend_input']; } } if (!$x156('special_price', $x86)) { $x86[] = 'special_price'; } if (!$x156('special_from_date', $x86)) { $x86[] = 'special_from_date'; } if (!$x156('special_to_date', $x86)) { $x86[] = 'special_to_date'; } if (!$x156('price_type', $x86)) { $x86[] = 'price_type'; } if (!$x156('price', $x86)) { $x86[] = 'price'; } $x86[] = 'tax_class_id'; foreach ($x71 as $x88) { if (!$x156($x88->code, $x86) && $x88->checked) { if (!$x156($x88->code, array("is_in_stock", "qty", "entity_id", "created_at", "updated_at"))) { $x86[] = $x88->code; } } } if ($this->_debug) { echo "<br><br>------------ ATTRIBUTES ----------------<br>"; $x154($x86); } Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> List of required attributes collected", null, $this->x165('.log')); $x7d = Mage::getSingleton('core/resource'); $x7e = $x7d->getConnection('core_read'); $x89 = $x7d->getTableName('eav_attribute_option_value'); $x80 = $x7e->select(); $x80->from($x89); $x80->where("store_id=" . $x58 . ' OR store_id=0'); $x80->order(array('option_id', 'store_id')); $x8a = $x7e->fetchAll($x80); foreach ($x8a as $x8b) { $x8c[$x8b['option_id']][$x8b['store_id']] = $x8b['value']; } if ($this->_debug) { echo "<br><br>------------ ATTRIBUTES LABEL ----------------<br>"; $x154($x8c); } Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> List of attribute labels collected", null, $this->x165('.log')); $x8d = $x7d->getTableName('tax_class'); $x8e = $x7d->getTableName('tax_calculation'); $x8f = $x7d->getTableName('tax_calculation_rate'); $x90 = $x7d->getTableName('directory_country_region'); $x91 = $x7d->getTableName('customer_group'); $x80 = $x7e->select(); $x80->from($x8d)->order(array('class_id', 'tax_calculation_rate_id')); $x80->joinleft(array('tc' => $x8e), 'tc.product_tax_class_id = ' . $x8d . '.class_id', 'tc.tax_calculation_rate_id'); $x80->joinleft(array('tcr' => $x8f), 'tcr.tax_calculation_rate_id = tc.tax_calculation_rate_id', array('tcr.rate', 'tax_country_id', 'tax_region_id')); $x80->joinleft(array('dcr' => $x90), 'dcr.region_id=tcr.tax_region_id', 'code'); $x80->joinInner(array('cg' => $x91), 'cg.tax_class_id=tc.customer_tax_class_id AND cg.customer_group_code="NOT LOGGED IN"'); $x92 = $x7e->fetchAll($x80); $x44 = array(); $x3c = ''; foreach ($x92 as $x93) { if ($x3c != $x93['class_id']) { $x94 = 0; } else { $x94++; } $x3c = $x93['class_id']; $x44[$x93['class_id']][$x94]['rate'] = $x93['rate']; $x44[$x93['class_id']][$x94]['code'] = $x93['code']; $x44[$x93['class_id']][$x94]['country'] = $x93['tax_country_id']; } $this->_rates = $x44; if ($this->_debug) { echo "<br><br>------------ TAX CLASS ----------------<br>"; $x154($x44); } Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Tax rate collected", null, $this->x165('.log')); $x95 = $x7d->getTableName('review'); $x96 = $x7d->getTableName('review_store'); $x97 = $x7d->getTableName('rating_option_vote'); $x98 = $x7e->select()->distinct('review_id'); $x98->from(array("r" => $x95), array("COUNT(DISTINCT r.review_id) AS count", 'entity_pk_value')); $x98->joinleft(array('rs' => $x96), 'rs.review_id=r.review_id', 'rs.store_id'); $x98->joinleft(array('rov' => $x97), 'rov.review_id=r.review_id', 'AVG(rov.percent) AS score'); $x98->where("status_id=1 and entity_id=1"); $x98->group(array('r.entity_pk_value', 'rs.store_id')); $x99 = $x7e->select(); $x99->from(array("r" => $x95), array("COUNT(DISTINCT r.review_id) AS count", 'entity_pk_value', "(SELECT 0) AS store_id")); $x99->joinleft(array('rs' => $x96), 'rs.review_id=r.review_id', array()); $x99->joinleft(array('rov' => $x97), 'rov.review_id=r.review_id', 'AVG(rov.percent) AS score'); $x99->where("status_id=1 and entity_id=1"); $x99->group(array('r.entity_pk_value')); $x80 = $x7e->select()->union(array($x98, $x99)); $x80->order(array('entity_pk_value', 'store_id')); $x9a = $x7e->fetchAll($x80); $x9b = array(); foreach ($x9a as $x9c) { $x9b[$x9c['entity_pk_value']][$x9c['store_id']]["count"] = $x9c["count"]; $x9b[$x9c['entity_pk_value']][$x9c['store_id']]['score'] = $x9c['score']; } Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Reviews collected", null, $this->x165('.log')); $x7d = Mage::getSingleton('core/resource'); $x7e = $x7d->getConnection('core_read'); $x9d = $x7d->getTableName('catalog_product_entity_media_gallery'); $x9e = $x7d->getTableName('catalog_product_entity_media_gallery_value'); $x80 = $x7e->select(array("DISTINCT value")); $x80->from($x9d); $x80->joinleft(array('cpemgv' => $x9e), 'cpemgv.value_id = ' . $x9d . '.value_id', array('cpemgv.position', 'cpemgv.disabled')); $x80->where("value<>TRIM('') AND (store_id=" . $x58 . ' OR store_id=0)'); $x80->order(array('position', 'value_id')); $x80->group(array('value_id')); $x9f = $x7e->fetchAll($x80); foreach ($x9f as $xa0) { if ($xa0['disabled'] != 1 && $xa0['value'] != '') { if (!$x156($xa0['value'], $xa1[$xa0['entity_id']]['src'])) { $xa1[$xa0['entity_id']]['src'][] = $xa0['value']; $xa1[$xa0['entity_id']]['disabled'][] = $xa0['disabled']; } } } if ($this->_debug) { echo "<br><br>------------ IMAGES ----------------<br>"; $x154($xa1); } Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Images collected", null, $this->x165('.log')); Mage::app()->setCurrentStore($x58); $xa2 = $x7d->getTableName("cataloginventory_stock_item"); $xa3 = $x7d->getTableName("core_url_rewrite"); $x83 = $x7d->getTableName('catalog_category_product'); $xa4 = $x7d->getTableName('catalog_category_product_index'); $xa5 = $x7d->getTableName('catalog_product_index_price'); $xa6 = $x7d->getTableName('catalog_product_super_link'); $xa7 = $x7d->getTableName('catalog_product_link'); $xa8 = $x7d->getTableName('catalog_product_bundle_selection'); $x155(Mage::getVersion(), '1.6.0', '<') ? $x79 = "options=''" : ($x79 = "ISNULL(options)"); switch (Mage::getStoreConfig("simplegoogleshopping/system/urlrewrite")) { case 1: $xa9 = "AND url.target_path NOT LIKE '%category%'"; $xaa = 'MAX'; break; default: $xa9 = "AND url.target_path LIKE '%category%'"; $xaa = 'GROUP_CONCAT'; break; break; } $xab = Mage::getModel('simplegoogleshopping/product_collection')->getCollection()->addStoreFilter($x58); $xab->addAttributeToFilter('status', 1); $xab->addAttributeToFilter('type_id', array("in" => "configurable")); $xab->addAttributeToFilter('visibility', array("nin" => 1)); $xab->addAttributeToSelect($x86, true); $xab->getSelect()->joinLeft($xa6 . ' AS cpsl', 'cpsl.parent_id=e.entity_id ', array('child_ids' => 'GROUP_CONCAT( DISTINCT cpsl.product_id)')); $xab->getSelect()->joinLeft($xa2 . ' AS stock', 'stock.product_id=e.entity_id', array('qty' => 'qty', 'is_in_stock' => 'is_in_stock', 'manage_stock' => 'manage_stock', 'use_config_manage_stock' => 'use_config_manage_stock', 'backorders' => 'backorders', 'use_config_backorders' => 'use_config_backorders')); $xab->getSelect()->joinLeft($xa3 . ' AS url', 'url.product_id=e.entity_id ' . $xa9 . ' AND is_system=1 AND ' . $x79 . ' AND url.store_id=' . $x58, array('request_path' => $xaa . '(DISTINCT request_path)')); $xab->getSelect()->joinLeft($x83 . ' AS categories', 'categories.product_id=e.entity_id'); $xab->getSelect()->joinLeft($xa4 . ' AS categories_index', 'categories_index.category_id=categories.category_id AND categories_index.product_id=categories.product_id AND categories_index.store_id=' . $x58, array('categories_ids' => 'GROUP_CONCAT( DISTINCT categories_index.category_id)')); $xab->getSelect()->group(array('cpsl.parent_id')); $xac = array(); foreach ($xab as $xad) { foreach (explode(",", $xad->getChildIds()) as $xae) { $xac[$xae] = $xad; $xaf[$xae]['categories_ids'] = $xad->getCategories_ids(); $xaf[$xae]['parent_id'] = $xad->getId(); $xaf[$xae]['parent_sku'] = $xad->getSku(); $xaf[$xae]['parent_request_path'] = $xad->getRequestPath(); } } $this->configurable = $xac; if ($this->_debug) { echo "<br><br>------------ CONFIGURABLES ----------------<br>"; echo $xab->getSelect() . '<br><br>'; $x154($xaf); } Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Relations with configurable products detected", null, $this->x165('.log')); $xab = Mage::getModel('simplegoogleshopping/product_collection')->getCollection()->addStoreFilter($x58); $xab->addAttributeToFilter('status', 1); $xab->addAttributeToFilter('type_id', array("in" => "configurable")); $xab->addAttributeToFilter('visibility', array("nin" => 1)); $xab->getSelect()->joinLeft($xa6 . ' AS cpsl', 'cpsl.parent_id=e.entity_id '); $xab->getSelect()->joinLeft($xa2 . ' AS stock', 'stock.product_id=cpsl.product_id', array('qty' => 'SUM(stock.qty)')); $xab->getSelect()->group(array('cpsl.parent_id')); $xb0 = array(); foreach ($xab as $xb1) { $xb0[$xb1->getId()] = $xb1->getQty(); } $this->configurableQty = $xb0; if ($this->_debug) { echo "<br><br>------------ CONFIGURABLES QTY ----------------<br>"; echo $xab->getSelect() . '<br><br>'; $x154($xb0); } Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Qty for configurable products calculated", null, $this->x165('.log')); $xa6 = $x7d->getTableName("catalog_product_super_link"); $xb2 = $x7d->getTableName("catalog_product_super_attribute"); $xb3 = $x7d->getTableName("catalog_product_entity_int"); $xb4 = $x7d->getTableName("catalog_product_super_attribute_pricing"); $xb5 = $x7e->select(); $xb5->from(array("cpsl" => $xa6), array("parent_id", "product_id")); $xb5->joinleft(array("cpsa" => $xb2), "cpsa.product_id = cpsl.parent_id", array("attribute_id")); $xb5->joinleft(array("cpei" => $xb3), "cpei.entity_id = cpsl.product_id AND cpei.attribute_id = cpsa.attribute_id", array("value" => "value")); $xb5->joinleft(array("cpsap" => $xb4), "cpsap.product_super_attribute_id = cpsa.product_super_attribute_id AND cpei.value = cpsap.value_index", array("pricing_value" => "pricing_value", "is_percent" => "is_percent")); $xb5->order(array("cpsl.parent_id", "cpsl.product_id")); $xb5->group(array("cpsl.parent_id", "cpsl.product_id", "cpsa.attribute_id")); $xb6 = $x7e->fetchAll($xb5); $xb7 = array(); foreach ($xb6 as $xb1) { $xb7[$xb1["parent_id"]][$xb1["product_id"]][$xb1['attribute_id']]['attribute_id'] = $xb1["attribute_id"]; $xb7[$xb1["parent_id"]][$xb1["product_id"]][$xb1['attribute_id']]['value'] = $xb1["value"]; $xb7[$xb1["parent_id"]][$xb1["product_id"]][$xb1['attribute_id']]['pricing_value'] = $xb1["pricing_value"]; $xb7[$xb1["parent_id"]][$xb1["product_id"]][$xb1['attribute_id']]['is_percent'] = $xb1["is_percent"]; } if ($this->_log) { Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Configurable prices collected", null, $this->x165('.log')); } $this->configurablePrices = $xb7; if ($this->_debug) { echo "<br><br>------------ CONFIGURABLES PRICES ----------------<br>"; echo $xb5 . '<br><br>'; $x154($xb7); } $xab = Mage::getModel('simplegoogleshopping/product_collection')->getCollection()->addStoreFilter($x58); $xab->addAttributeToFilter('status', 1); $xab->addAttributeToFilter('type_id', array("in" => "grouped")); $xab->addAttributeToFilter('visibility', array("nin" => 1)); $xab->addAttributeToSelect($x86, true); $xab->getSelect()->joinLeft($xa7 . ' AS cpl', 'cpl.product_id=e.entity_id AND cpl.link_type_id=3', array('child_ids' => 'GROUP_CONCAT( DISTINCT cpl.linked_product_id)')); $xab->getSelect()->joinLeft($xa2 . ' AS stock', 'stock.product_id=e.entity_id', array('qty' => 'qty', 'is_in_stock' => 'is_in_stock', 'manage_stock' => 'manage_stock', 'use_config_manage_stock' => 'use_config_manage_stock', 'backorders' => 'backorders', 'use_config_backorders' => 'use_config_backorders')); $xab->getSelect()->joinLeft($xa3 . ' AS url', 'url.product_id=e.entity_id ' . $xa9 . ' AND is_system=1 AND ' . $x79 . ' AND url.store_id=' . $x58, array('request_path' => $xaa . '(DISTINCT request_path)')); $xab->getSelect()->joinLeft($x83 . ' AS categories', 'categories.product_id=e.entity_id'); $xab->getSelect()->joinLeft($xa4 . ' AS categories_index', 'categories_index.category_id=categories.category_id AND categories_index.product_id=categories.product_id AND categories_index.store_id=' . $x58, array('categories_ids' => 'GROUP_CONCAT( DISTINCT categories_index.category_id)')); $xab->getSelect()->group(array('cpl.product_id')); $xb8 = array(); foreach ($xab as $xad) { foreach (explode(",", $xad->getChildIds()) as $xae) { $xb8[$xae] = $xad; $xb9[$xae]['categories_ids'] = $xad->getCategories_ids(); $xb9[$xae]['parent_id'] = $xad->getId(); $xb9[$xae]['parent_sku'] = $xad->getSku(); $xb9[$xae]['parent_request_path'] = $xad->getRequestPath(); } } $this->grouped = $xb8; if ($this->_debug) { echo "<br><br>------------ GROUPED ----------------<br>"; echo $xab->getSelect() . '<br><br>'; $x154($xb9); } Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Relations with grouped products detected", null, $this->x165('.log')); $xab = Mage::getModel('simplegoogleshopping/product_collection')->getCollection()->addStoreFilter($x58); $xab->addAttributeToFilter('status', 1); $xab->addAttributeToFilter('type_id', array("in" => "bundle")); $xab->addAttributeToFilter('visibility', array("nin" => 1)); $xab->addAttributeToSelect($x86, true); $xab->getSelect()->joinLeft($xa8 . ' AS cpbs', 'cpbs.parent_product_id=e.entity_id', array('child_ids' => 'GROUP_CONCAT( DISTINCT cpbs.product_id)')); $xab->getSelect()->joinLeft($xa2 . ' AS stock', 'stock.product_id=e.entity_id', array('qty' => 'qty', 'is_in_stock' => 'is_in_stock', 'manage_stock' => 'manage_stock', 'use_config_manage_stock' => 'use_config_manage_stock', 'backorders' => 'backorders', 'use_config_backorders' => 'use_config_backorders')); $xab->getSelect()->joinLeft($xa3 . ' AS url', 'url.product_id=e.entity_id ' . $xa9 . ' AND is_system=1 AND ' . $x79 . ' AND url.store_id=' . $x58, array('request_path' => $xaa . '(DISTINCT request_path)')); $xab->getSelect()->joinLeft($x83 . ' AS categories', 'categories.product_id=e.entity_id'); $xab->getSelect()->joinLeft($xa4 . ' AS categories_index', 'categories_index.category_id=categories.category_id AND categories_index.product_id=categories.product_id AND categories_index.store_id=' . $x58, array('categories_ids' => 'GROUP_CONCAT( DISTINCT categories_index.category_id)')); $xab->getSelect()->group(array('e.entity_id')); $xba = array(); foreach ($xab as $xad) { foreach (explode(",", $xad->getChildIds()) as $xae) { $xba[$xae] = $xad; $xbb[$xae]['parent_id'] = $xad->getId(); $xbb[$xae]['parent_sku'] = $xad->getSku(); $xbb[$xae]['parent_request_path'] = $xad->getRequestPath(); $xbb[$xae]['categories_ids'] = $xad->getCategories_ids(); } } $this->bundle = $xba; if ($this->_debug) { echo "<br><br>------------ BUNDLE ----------------<br>"; echo $xab->getSelect() . '<br><br>'; $x154($xbb); } Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Relations with bundle products detected", null, $this->x165('.log')); $xbc = $x7d->getTableName("catalog_product_option"); $xbd = $x7d->getTableName("catalog_product_option_title"); $xbe = $x7d->getTableName("catalog_product_option_type_value"); $xbf = $x7d->getTableName("catalog_product_option_type_title"); $xc0 = $x7d->getTableName("catalog_product_option_type_price"); $xc1 = $x7e->select(); $xc1->from(array("cpo" => $xbc), array("product_id")); $xc1->joinleft(array("cpot" => $xbd), "cpot.option_id=cpo.option_id AND cpot.store_id=0", array("option" => "title", "option_id", "store_id")); $xc1->joinleft(array("cpotv" => $xbe), "cpotv.option_id = cpo.option_id", array("sku", "id" => "option_type_id")); $xc1->joinleft(array("cpott" => $xbf), "cpott.option_type_id=cpotv.option_type_id AND cpott.store_id=cpot.store_id", "title AS value"); $xc1->joinleft(array("cpotp" => $xc0), "cpotp.option_type_id=cpotv.option_type_id AND cpotp.store_id=cpot.store_id", array("price", "price_type")); $x80 = $xc1->order(array("product_id", "cpotv.sort_order ASC")); $x9a = $x7e->fetchAll($x80); $xc2 = array(); $xc3 = 0; foreach ($x9a as $xc4) { $xc2[$xc4["product_id"]][$xc4["option"]]["options"][] = array("value" => $xc4["value"], "sku" => $xc4["sku"], "price" => $xc4["price"], "price_type" => $xc4["price_type"]); $xc3++; } $this->customOptions = $xc2; if ($this->_debug) { echo "<br><br>------------ CUSTOM OPTIONS ----------------<br>"; echo $xc1 . '<br><br>'; $x154($xc2); } Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Custom options collected", null, $this->x165('.log')); if (Mage::helper("core")->isModuleEnabled("Wyomind_Googlemerchantpromotions")) { $xc5 = Mage::getResourceModel('salesrule/rule_collection')->setOrder('sort_order', 'ASC')->addFieldToFilter("transferable_to_google_merchant", 1)->load(); Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Promotions rules collected", null, $this->x165('.log')); } $xc6 = Mage::getModel('simplegoogleshopping/product_collection')->getCollection()->addStoreFilter($x58); if (Mage::getStoreConfig("simplegoogleshopping/system/disabled")) { $xc6->addFieldToFilter("status", array('gteq' => 1)); } else { $xc6->addFieldToFilter("status", 1); } $xc6->addAttributeToFilter("type_id", array("in" => $x6f)); $xc6->addAttributeToFilter("visibility", array("in" => $x70)); if ($x72[0] != '*') { $xc6->addAttributeToFilter("attribute_set_id", array("in" => $x72)); } $xc6->addAttributeToSelect($x86, true); $xc7 = array("eq" => "= '%s'", "neq" => "!= '%s'", "gteq" => ">= '%s'", "lteq" => "<= '%s'", "gt" => "> '%s'", "lt" => "< '%s'", "like" => "like '%s'", "nlike" => "not like '%s'", "null" => "is null", "notnull" => "is not null", "in" => "in (%s)", "nin" => "not in(%s)"); $xc8 = ''; $x32 = 0; $xc9 = array(); foreach ($x71 as $x88) { if ($x88->checked) { if ($x88->condition == 'in' || $x88->condition == 'nin') { if ($x88->code == 'qty' || $x88->code == 'is_in_stock') { $xca = explode(',', $x88->value); $x88->value = "'" . implode($xca, "','") . "'"; } else { $x88->value = explode(',', $x88->value); } } switch ($x88->code) { case 'qty': if ($x32 > 0) { $xc8 .= ' ' . $x88->statement . ' '; } $xc8 .= " qty " . sprintf($xc7[$x88->condition], $x88->value); $x32++; break; case 'is_in_stock': if ($x32 > 0) { $xc8 .= ' ' . $x88->statement . ' '; } $xc8 .= " (IF("; $xc8 .= "(use_config_manage_stock=1 AND {$x5d}=0)"; $xc8 .= " OR "; $xc8 .= '(use_config_manage_stock=0 AND manage_stock=0)'; $xc8 .= " OR "; $xc8 .= "(use_config_manage_stock=1 AND {$x5d}=1 AND is_in_stock=1 )"; $xc8 .= " OR "; $xc8 .= "(use_config_manage_stock=0 AND manage_stock=1 AND is_in_stock=1 )"; $xc8 .= ",'1','0')" . sprintf($xc7[$x88->condition], $x88->value) . ")"; $x32++; break; default: if ($x88->statement == "AND") { if (count($xc9)) { $xc6->addFieldToFilter($xc9); } $xc9 = array(); } if ($x88->condition == "in") { $xcb = true; $xcc = array(); foreach ($x88->value as $xcd) { if (!$x14d($xcd)) { $xcb = true; } } if ($xcb) { foreach ($x88->value as $xcd) { $xcc[] = array(array("finset" => $xcd)); } $xc9[] = array("attribute" => $x88->code, $xcc); } else { $xc9[] = array("attribute" => $x88->code, $x88->condition => $x88->value); } } else { $xc9[] = array("attribute" => $x88->code, $x88->condition => $x88->value); } break; } } } if (count($xc9)) { $xc6->addFieldToFilter($xc9); } $xc6->getSelect()->joinLeft($xa2 . ' AS stock', 'stock.product_id=e.entity_id', array('qty' => 'qty', 'is_in_stock' => 'is_in_stock', 'manage_stock' => 'manage_stock', 'use_config_manage_stock' => 'use_config_manage_stock', 'backorders' => 'backorders', 'use_config_backorders' => 'use_config_backorders')); $xc6->getSelect()->joinLeft($xa3 . ' AS url', 'url.product_id=e.entity_id ' . $xa9 . ' AND is_system=1 AND ' . $x79 . ' AND url.store_id=' . $x58, array('request_path' => $xaa . '(DISTINCT request_path)')); if ($x6c[0] != '*') { $xcd = 0; $xce = null; foreach ($x6c as $x6e) { if ($xcd > 0) { $xce .= ','; } $xce .= $x157(explode('/', $x6e)); $xcd++; } $x6a ? $xcf = "IN" : ($xcf = "NOT IN"); $xc6->getSelect()->joinLeft($xa6 . ' AS cpsl', 'cpsl.product_id=e.entity_id ', array('parent_id' => 'parent_id')); switch ($x6b) { case 0: $xd0 = "categories.product_id=e.entity_id"; break; case 1: $xd0 = "categories.product_id=e.entity_id OR categories.product_id=cpsl.parent_id"; break; case 2: $xd0 = "categories.product_id=cpsl.parent_id "; break; } if ($x155(Mage::getVersion(), '1.12.0', '<=')) { $xce = "AND categories_index.category_id " . $xcf . " (" . $xce . ")"; $xc6->getSelect()->joinLeft($x83 . ' AS categories', $xd0, array()); $xc6->getSelect()->joinInner($xa4 . ' AS categories_index', '((categories_index.category_id=categories.category_id AND categories_index.product_id=categories.product_id)) AND categories_index.store_id=' . $x58 . ' ' . $xce, array('categories_ids' => 'GROUP_CONCAT( DISTINCT categories_index.category_id)')); } else { $xce = "AND categories.category_id " . $xcf . " (" . $xce . ")"; $xc6->getSelect()->joinInner($x83 . ' AS categories', $xd0 . ' ' . $xce, array('categories_ids' => 'GROUP_CONCAT( DISTINCT categories.category_id)')); } } else { $xc6->getSelect()->joinLeft($x83 . ' AS categories', 'categories.product_id=e.entity_id'); $xc6->getSelect()->joinLeft($xa4 . ' AS categories_index', '((categories_index.category_id=categories.category_id AND categories_index.product_id=categories.product_id) ) AND categories_index.store_id=' . $x58, array('categories_ids' => 'GROUP_CONCAT(DISTINCT categories_index.category_id)')); } if ($x155(Mage::getVersion(), '1.4.0', '>=')) { $xc6->getSelect()->joinLeft($xa5 . ' AS price_index', 'price_index.entity_id=e.entity_id AND customer_group_id=0 AND price_index.website_id=' . Mage::getModel('core/store')->load($x58)->getWebsiteId(), array('min_price' => 'min_price', 'max_price' => 'max_price', 'tier_price' => 'tier_price', 'final_price' => 'final_price')); } if (!empty($xc8)) { $xc6->getSelect()->where($xc8); } $xc6->getSelect()->group("e.entity_type_id"); if ($this->_log) { Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Main sql request: \n" . $xc6->getSelect(), null, $this->x165('.log')); } if ($this->_debug) { echo "<br><br>------------ MAIN SQL REQUEST ----------------<br>"; echo $xc6->getSelect(); } $xd1 = 0; $xd2 = clone $xc6; $xd2->getSelect()->columns("COUNT(DISTINCT e.entity_id) As total"); $this->_counter = $xd2->getFirstItem()->getTotal(); $xd3 = ceil($this->_counter / $this->_sqlSize); $x73 = ''; $xd4 = 1; Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Total items calculated ({$this->_counter} in {$xd3} queries )", null, $this->x165('.log')); $xc6->getSelect()->group(array('e.entity_id'))->order('e.entity_id'); $xd5 = time(true); $xd6 = 0; while ($xd1 < $xd3) { $xab = clone $xc6; if ($this->_debug) { echo "<br><br>------------ SQL ----------------<br>"; print $xab->getSelect(); } $xab->getSelect()->limit($this->_sqlSize, $this->_sqlSize * $xd1); $xd1++; if ($this->_sqlSize * $xd1 > $this->_counter) { $xd7 = $this->_counter; } else { $xd7 = $this->_sqlSize * $xd1; } if ($this->_log) { Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Fetching products from " . ($this->_sqlSize * ($xd1 - 1) + 1) . " to " . $xd7, null, $this->x165('.log')); } $xc3 = 1; foreach ($xab as $product) { if ($this->_debug) { echo "<br><br>------------ PRODUCT [ SKU -> " . $product->getSku() . " | ID -> " . $product->getId() . "]---------------<br>"; echo "categories : " . $product->getCategoriesIds() . ", Root id: " . $x63 . "<br>"; foreach (explode(',', $product->getCategoriesIds()) as $x37 => $x7c) { echo $x7c . "=>" . $x7b[$x7c]["path"] . "<br>"; } } $x48 = $x66; foreach ($x76 as $x37 => $xd8) { $x4a = ""; switch ($xd8['pattern']) { case '{G:ID}': $xd9 = $this->checkReference($xd8['reference'], $product); $xd8['options'][0] != "id" ? $xda = $xd9->getSku() : ($xda = $xd9->getId()); $x4a = "<g:id><![CDATA[" . $xda . "]]></g:id>"; break; case '{G:TITLE}': $xd9 = $this->checkReference($xd8['reference'], $product); $x39 = $xd9->getName(); if (strlen($x39) > 900) { $x39 = substr($x39, 0, 150, -3); $xdb = strrpos($x39, " "); $x39 = substr($x39, 0, $xdb) . "..."; } $x4a = "<title><![CDATA[" . $x39 . "]]></title>"; break; case '{G:DESCRIPTION}': $xd9 = $this->checkReference($xd8['reference'], $product); $xd8['options'][0] != "short" ? $xdc = $xd9->getDescription() : ($xdc = $xd9->getShortDescription()); $x4a = "<description><![CDATA[" . $xdc . "]]></description>"; break; case '{G:PROMOTION_ID}': $x4a = ""; $xdd = clone $xc5; foreach ($xdd as $xde) { if ($xde->getIsActive()) { $xdf = unserialize($xde->getConditions_serialized()); $xdf = $xdf["conditions"]; $xe0 = $xde->getConditions(); $xe1 = $xe0->getAggregator() === 'all'; $xe2 = (bool) $xe0->getValue(); $xe3 = $xe1 ? true : false; $xe3 = !count($xe0->getConditions()) ? true : $xe3; $xe4 = 0; foreach ($xe0->getConditions() as $xe5) { $xe6 = array("salesrule/rule_condition_product_subselect", "salesrule/rule_condition_address"); if (!$x156($xe5->getType(), $xe6)) { $xe7 = $xe5->validate($product); if ($xe1 && $xe7 !== $xe2) { $xe3 = false; } elseif (!$xe1 && $xe7 === $xe2) { $xe3 = true; break; } } else { if ($xe5->getAttribute() == "base_subtotal") { } } $xe4++; } $xe8 = unserialize($xde->getActions_serialized()); $xe8 = $xe8["conditions"]; $xe9 = $xde->getActions(); $xe1 = $xe9->getAggregator() === 'all'; $xe2 = (bool) $xe9->getValue(); $xea = $xe1 ? true : false; $xea = !count($xe9->getConditions()) ? true : $xea; $xe4 = 0; foreach ($xe9->getConditions() as $x57) { $xe7 = $x57->validate($product); if ($xe1 && $xe7 !== $xe2) { $xea = false; } elseif (!$xe1 && $xe7 === $xe2) { $xea = true; break; } $xe4++; } if ($xea && $xe3) { $x4a = "<g:promotion_id><![CDATA[" . $xde->getData('rule_id') . "]]></g:promotion_id>"; break; } } } break; case "{load_options}": $x9a = 1; $xeb = array(); foreach ($xd8['options'] as $x37 => $xec) { if (isset($xc2[$product->getId()][$xec])) { $x9a = $x9a * count($xc2[$product->getId()][$xec]["options"]); $xeb[$x37] = 0; } } $x35 = array(); for ($x94 = 1; $x94 <= $x9a; $x94++) { $xed = $x48; foreach ($xd8['options'] as $x37 => $xec) { if (isset($xc2[$product->getId()][$xec])) { $xed = $x147("{" . $xec . "_label}", $xc2[$product->getId()][$xec]["options"][$xeb[$x37]]['value'], $xed); $xed = $x147("{" . $xec . "_sku}", $xc2[$product->getId()][$xec]["options"][$xeb[$x37]]['sku'], $xed); $xed = $x147("{" . $xec . "_price}", $xc2[$product->getId()][$xec]["options"][$xeb[$x37]]['price'], $xed); $xed = $x147("{" . $xec . "_type}", $xc2[$product->getId()][$xec]["options"][$xeb[$x37]]['price_type'], $xed); $xed = $x147("{" . $xec . "_id}", $xc2[$product->getId()][$xec]["options"][$xeb[$x37]]['id'], $xed); if ($x37 > 0 || count($xc2[$product->getId()]) == 1 || count($xd8['options']) < 2) { $xeb[$x37]++; } if ($xeb[$x37] >= count($xc2[$product->getId()][$xec]["options"])) { $xeb[$x37] = 0; $xeb[$x37 - 1]++; } } } $x35[] = $xed; } if (count($x35) > 0) { $x48 = implode("</item>\n<item>", $x35); } break; case "{use_options}": foreach ($xd8['options'] as $x37 => $xec) { if (isset($xc2[$product->getId()][$xec])) { $xee = array(); $xef = array(); $xf0 = array(); $xf1 = array(); foreach ($xc2[$product->getId()][$xec]["options"] as $x4c) { $xee[] = $x4c['value']; $xef[] = $x4c['sku']; $xf0[] = $x4c['price']; $xf1[] = $x4c['id']; } $x48 = $x147("{" . $xec . "_label}", implode(',', $xee), $x48); $x48 = $x147("{" . $xec . "_sku}", implode(',', $xef), $x48); $x48 = $x147("{" . $xec . "_price}", implode(',', $xf0), $x48); $x48 = $x147("{" . $xec . "_id}", implode(',', $xf1), $x48); } } break; case '{inc}': $x4a = $xd4; break; case '{min_price}': $xd9 = $this->checkReference($xd8['reference'], $product); $x3e = $xd9->getMinPrice(); !isset($xd8['options'][1]) ? $x43 = false : ($x43 = $xd8['options'][1]); if ($xd9->getTypeId() == "configurable") { if (isset($this->configurablePrices[$xd9->getId()][$product->getId()])) { $xf2 = 0; foreach ($this->configurablePrices[$xd9->getId()][$product->getId()] as $xf3) { if ($xf3["is_percent"]) { $xf2 += $xf3["pricing_value"] / 100 * $x3e; } else { $xf2 += $xf3["pricing_value"]; } } $x3e += $xf2; } } $x4a = $this->x167($x3e, $x62, $xd9->getTaxClassId(), $x43); !isset($xd8['options'][0]) ? $x3f = $x5c : ($x3f = $xd8['options'][0]); $x4a = $this->x166($x4a, $x3f); $x4a = $x14c($x4a, 2, '.', ''); break; case '{max_price}': $xd9 = $this->checkReference($xd8['reference'], $product); $x3e = $xd9->getMaxPrice(); !isset($xd8['options'][1]) ? $x43 = false : ($x43 = $xd8['options'][1]); if ($xd9->getTypeId() == "configurable") { if (isset($this->configurablePrices[$xd9->getId()][$product->getId()])) { $xf2 = 0; foreach ($this->configurablePrices[$xd9->getId()][$product->getId()] as $xf3) { if ($xf3["is_percent"]) { $xf2 += $xf3["pricing_value"] / 100 * $x3e; } else { $xf2 += $xf3["pricing_value"]; } } $x3e += $xf2; } } $x4a = $this->x167($x3e, $x62, $xd9->getTaxClassId(), $x43); !isset($xd8['options'][0]) ? $x3f = $x5c : ($x3f = $xd8['options'][0]); $x4a = $this->x166($x4a, $x3f); $x4a = $x14c($x4a, 2, '.', ''); break; case '{normal_price}': $xd9 = $this->checkReference($xd8['reference'], $product); if ($xd9->type_id == 'bundle') { $x3e = $xd9->price; } else { $x3e = $xd9->getPrice(); } if ($xd9->getTypeId() == "configurable") { if (isset($this->configurablePrices[$xd9->getId()][$product->getId()])) { $xf2 = 0; foreach ($this->configurablePrices[$xd9->getId()][$product->getId()] as $xf3) { if ($xf3["is_percent"]) { $xf2 += $xf3["pricing_value"] / 100 * $x3e; } else { $xf2 += $xf3["pricing_value"]; } } $x3e += $xf2; } } !isset($xd8['options'][1]) ? $x43 = false : ($x43 = $xd8['options'][1]); $x4a = $this->x167($x3e, $x62, $xd9->getTaxClassId(), $x43); !isset($xd8['options'][0]) ? $x3f = $x5c : ($x3f = $xd8['options'][0]); $x4a = $this->x166($x4a, $x3f); $x4a = $x14c($x4a, 2, '.', ''); break; case '{price}': $xd9 = $this->checkReference($xd8['reference'], $product); if ($xd9->getSpecialFromDate() && !$xd9->getSpecialToDate()) { if ($xd9->getSpecialFromDate() <= date("Y-m-d H:i:s")) { if ($xd9->type_id == "bundle") { if (($xd9->price_type || !$xd9->price_type && $xd9->special_price < $xd9->price) && $xd9->special_price > 0) { if ($xd9->price_type) { $x3e = $x14c($xd9->price * $xd9->special_price / 100, 2, ".", ""); } else { $x3e = $xd9->special_price; } } else { $x3e = $xd9->price; } } else { $xd9->getSpecial_price() && $xd9->getSpecial_price() < $xd9->getPrice() ? $x3e = $xd9->getSpecialPrice() : ($x3e = $xd9->getPrice()); } } else { if ($xd9->type_id == "bundle") { $x3e = $xd9->price; } else { $x3e = $xd9->getPrice(); } } } elseif ($xd9->getSpecialFromDate() && $xd9->getSpecialToDate()) { if ($xd9->getSpecialFromDate() <= date("Y-m-d H:i:s") && date("Y-m-d H:i:s") < $xd9->getSpecialToDate()) { if ($xd9->type_id == "bundle") { if (($xd9->price_type || !$xd9->price_type && $xd9->special_price < $xd9->price) && $xd9->special_price > 0) { if ($xd9->price_type) { $x3e = $x14c($xd9->price * $xd9->special_price / 100, 2, ".", ""); } else { $x3e = $xd9->special_price; } } else { $x3e = $xd9->price; } } else { $xd9->getSpecial_price() && $xd9->getSpecial_price() < $xd9->getPrice() ? $x3e = $xd9->getSpecialPrice() : ($x3e = $xd9->getPrice()); } } else { if ($xd9->type_id == "bundle") { $x3e = $xd9->price; } else { $x3e = $xd9->getPrice(); } } } else { if ($xd9->type_id == "bundle") { if (($xd9->price_type || !$xd9->price_type && $xd9->special_price < $xd9->price) && $xd9->special_price > 0) { if ($xd9->price_type) { $x3e = $x14c($xd9->price * $xd9->special_price / 100, 2, ".", ""); } else { $x3e = $xd9->special_price; } } else { $x3e = $xd9->price; } } else { $xd9->getSpecial_price() && $xd9->getSpecial_price() < $xd9->getPrice() ? $x3e = $xd9->getSpecialPrice() : ($x3e = $xd9->getPrice()); } } if ($xd9->getTypeId() == "configurable") { if (isset($this->configurablePrices[$xd9->getId()][$product->getId()])) { $xf2 = 0; foreach ($this->configurablePrices[$xd9->getId()][$product->getId()] as $xf3) { if ($xf3["is_percent"]) { $xf2 += $xf3["pricing_value"] / 100 * $x3e; } else { $xf2 += $xf3["pricing_value"]; } } $x3e += $xf2; } } !isset($xd8['options'][1]) ? $x43 = false : ($x43 = $xd8['options'][1]); $x4a = $this->x167($x3e, $x62, $xd9->getTaxClassId(), $x43); !isset($xd8["options"][0]) ? $x3f = $x5c : ($x3f = $xd8["options"][0]); $x4a = $this->x166($x4a, $x3f); $x4a = $x14c($x4a, 2, ".", ""); break; case "{is_special_price}": $xd9 = $this->checkReference($xd8['reference'], $product); !isset($xd8["options"][0]) ? $xe2 = 1 : ($xe2 = $xd8["options"][0]); !isset($xd8["options"][1]) ? $xf4 = 0 : ($xf4 = $xd8["options"][1]); if ($xd9->getSpecialFromDate() && !$xd9->getSpecialToDate()) { if ($xd9->getSpecialFromDate() <= date("Y-m-d H:i:s")) { if ($xd9->type_id == "bundle") { ($xd9->price_type || !$xd9->price_type && $xd9->special_price < $xd9->price) && $xd9->special_price > 0 ? $x4a = $xe2 : ($x4a = $xf4); } else { $xd9->getSpecial_price() && $xd9->getSpecial_price() < $xd9->getPrice() ? $x4a = $xe2 : ($x4a = $xf4); } } else { if ($xd9->type_id == "bundle") { $x4a = $xf4; } else { $x4a = $xf4; } } } elseif ($xd9->getSpecialFromDate() && $xd9->getSpecialToDate()) { if ($xd9->getSpecialFromDate() <= date("Y-m-d H:i:s") && date("Y-m-d H:i:s") < $xd9->getSpecialToDate()) { if ($xd9->type_id == "bundle") { ($xd9->price_type || !$xd9->price_type && $xd9->special_price < $xd9->price) && $xd9->special_price > 0 ? $x4a = $xe2 : ($x4a = $xf4); } else { $xd9->getSpecial_price() && $xd9->getSpecial_price() < $xd9->getPrice() ? $x4a = $xe2 : ($x4a = $xf4); } } else { if ($xd9->type_id == "bundle") { $x4a = $xf4; } else { $x4a = $xf4; } } } else { if ($xd9->type_id == "bundle") { ($xd9->price_type || !$xd9->price_type && $xd9->special_price < $xd9->price) && $xd9->special_price > 0 ? $x4a = $xe2 : ($x4a = $xf4); } else { $xd9->getSpecial_price() && $xd9->getSpecial_price() < $xd9->getPrice() ? $x4a = $xe2 : ($x4a = $xf4); } } break; case "{special_price}": $xd9 = $this->checkReference($xd8['reference'], $product); $x3e = null; if ($xd9->getSpecialFromDate() && !$xd9->getSpecialToDate()) { if ($xd9->getSpecialFromDate() <= date("Y-m-d H:i:s")) { if ($xd9->type_id == 'bundle') { if ($xd9->price_type) { $x3e = $x14c($xd9->price * $xd9->special_price / 100, 2, ".", ""); } else { $x3e = $xd9->special_price; } } else { $x3e = $xd9->getSpecial_price(); } } } elseif ($xd9->getSpecialFromDate() && $xd9->getSpecialToDate()) { if ($xd9->getSpecialFromDate() <= date("Y-m-d H:i:s") && date("Y-m-d H:i:s") < $xd9->getSpecialToDate()) { if ($xd9->type_id == 'bundle') { if ($xd9->price_type) { $x3e = $x14c($xd9->price * $xd9->special_price / 100, 2, ".", ""); } else { $x3e = $xd9->special_price; } } else { $x3e = $xd9->getSpecial_price(); } } } else { if ($xd9->type_id == 'bundle') { if ($xd9->price_type) { $x3e = $x14c($xd9->price * $xd9->special_price / 100, 2, ".", ""); } else { $x3e = $xd9->special_price; } } else { $x3e = $xd9->getSpecial_price(); } } !isset($xd8['options'][1]) ? $x43 = false : ($x43 = $xd8['options'][1]); if ($x3e > 0) { if ($xd9->getTypeId() == "configurable") { if (isset($this->configurablePrices[$xd9->getId()][$product->getId()])) { $xf2 = 0; foreach ($this->configurablePrices[$xd9->getId()][$product->getId()] as $xf3) { if ($xf3["is_percent"]) { $xf2 += $xf3["pricing_value"] / 100 * $x3e; } else { $xf2 += $xf3["pricing_value"]; } } $x3e += $xf2; } } $x4a = $this->x167($x3e, $x62, $xd9->getTaxClassId(), $x43); !isset($xd8['options'][0]) ? $x3f = $x5c : ($x3f = $xd8['options'][0]); $x4a = $this->x166($x4a, $x3f); $x4a = $x14c($x4a, 2, '.', ''); } else { $x4a = ""; } break; case '{price_rules}': $xd9 = $this->checkReference($xd8['reference'], $product); $x58 = $this->getStoreId(); $xf5 = Mage::getResourceModel('catalogrule/rule'); $xf6 = Mage::app()->getLocale()->storeTimeStamp($x58); $xf7 = Mage::app()->getStore($x58); $xf8 = $xf7->getWebsiteId(); $xf9 = Mage::getSingleton('customer/session')->getCustomerGroupId(); $xfa = $xf5->getRulePrice($xf6, $xf8, $xf9, $xd9->getId()); if ($xfa !== false) { $xfb = sprintf('%.2f', round($xfa, 2)); } else { $xfb = $xd9->getPrice(); } if ($xd9->getSpecialFromDate() && !$xd9->getSpecialToDate()) { if ($xd9->getSpecialFromDate() <= date("Y-m-d H:i:s")) { if ($xd9->type_id == "bundle") { if (($xd9->price_type || !$xd9->price_type && $xd9->special_price < $xd9->price) && $xd9->special_price > 0) { if ($xd9->price_type) { $x3e = $x14c($xd9->price * $xd9->special_price / 100, 2, ".", ""); } else { $x3e = $xd9->special_price; } } else { $x3e = $xd9->price; } } else { $xd9->getSpecial_price() && $xd9->getSpecial_price() < $xd9->getPrice() ? $x3e = $xd9->getSpecialPrice() : ($x3e = $xfb); } } else { if ($xd9->type_id == "bundle") { $x3e = $xd9->price; } else { $x3e = $xfb; } } } elseif ($xd9->getSpecialFromDate() && $xd9->getSpecialToDate()) { if ($xd9->getSpecialFromDate() <= date("Y-m-d H:i:s") && date("Y-m-d H:i:s") < $xd9->getSpecialToDate()) { if ($xd9->type_id == "bundle") { if (($xd9->price_type || !$xd9->price_type && $xd9->special_price < $xd9->price) && $xd9->special_price > 0) { if ($xd9->price_type) { $x3e = $x14c($xd9->price * $xd9->special_price / 100, 2, ".", ""); } else { $x3e = $xd9->special_price; } } else { $x3e = $xd9->price; } } else { $xd9->getSpecial_price() && $xd9->getSpecial_price() < $xd9->getPrice() ? $x3e = $xd9->getSpecialPrice() : ($x3e = $xfb); } } else { if ($xd9->type_id == "bundle") { $x3e = $xd9->price; } else { $x3e = $xfb; } } } else { if ($xd9->type_id == "bundle") { if (($xd9->price_type || !$xd9->price_type && $xd9->special_price < $xd9->price) && $xd9->special_price > 0) { if ($xd9->price_type) { $x3e = $x14c($xd9->price * $xd9->special_price / 100, 2, ".", ""); } else { $x3e = $xd9->special_price; } } else { $x3e = $xd9->price; } } else { $xd9->getSpecial_price() && $xd9->getSpecial_price() < $xd9->getPrice() ? $x3e = $xd9->getSpecialPrice() : ($x3e = $xfb); } } if ($xfb !== FALSE) { if ($xfb < $x3e) { $x4a = $xfb; } else { $x4a = $x3e; } } else { $x4a = $x3e; } if ($xd9->getTypeId() == "configurable") { if (isset($this->configurablePrices[$xd9->getId()][$product->getId()])) { $xf2 = 0; foreach ($this->configurablePrices[$xd9->getId()][$product->getId()] as $xf3) { if ($xf3["is_percent"]) { $xf2 += $xf3["pricing_value"] / 100 * $x3e; } else { $xf2 += $xf3["pricing_value"]; } } $x3e += $xf2; } } !isset($xd8['options'][1]) ? $x43 = false : ($x43 = $xd8['options'][1]); $x4a = $this->x167($x3e, $x62, $xd9->getTaxClassId(), $x43); !isset($xd8["options"][0]) ? $x3f = $x5c : ($x3f = $xd8["options"][0]); $x4a = $this->x166($x4a, $x3f); $x4a = $x14c($x4a, 2, ".", ""); break; case '{G:PRICE}': $xd9 = $this->checkReference($xd8['reference'], $product); if ($xd9->type_id == 'bundle') { $x3e = $xd9->price; } else { $x3e = $xd9->getPrice(); } if ($xd9->getTypeId() == "configurable") { if (isset($this->configurablePrices[$xd9->getId()][$product->getId()])) { $xf2 = 0; foreach ($this->configurablePrices[$xd9->getId()][$product->getId()] as $xf3) { if ($xf3["is_percent"]) { $xf2 += $xf3["pricing_value"] / 100 * $x3e; } else { $xf2 += $xf3["pricing_value"]; } } $x3e += $xf2; } } !isset($xd8['options'][1]) ? $x43 = false : ($x43 = $xd8['options'][1]); $x4a = $this->x167($x3e, $x62, $xd9->getTaxClassId(), $x43); !isset($xd8['options'][0]) ? $x3f = $x5c : ($x3f = $xd8['options'][0]); $x4a = $this->x166($x4a, $x3f); $x4a = $x14c($x4a, 2, '.', ''); $x4a = "<g:price><![CDATA[" . $x4a . " " . $x3f . "]]></g:price>"; break; case "{G:SALE_PRICE}": $xd9 = $this->checkReference($xd8['reference'], $product); $x58 = $this->getStoreId(); $xf5 = Mage::getResourceModel('catalogrule/rule'); $xf6 = Mage::app()->getLocale()->storeTimeStamp($x58); $xf7 = Mage::app()->getStore($x58); $xf8 = $xf7->getWebsiteId(); $xf9 = Mage::getSingleton('customer/session')->getCustomerGroupId(); $xfa = $xf5->getRulePrice($xf6, $xf8, $xf9, $xd9->getId()); if ($xfa !== false) { $xfb = sprintf('%.2f', round($xfa, 2)); } $xfc = Mage::getSingleton('core/date')->getGmtOffset("hours"); if ($xfc > 0) { $xfd = "+"; $xfe = $x158(abs(floor($xfc)), 2, 0, STR_PAD_LEFT) . '' . $x158((abs($xfc) - floor(abs($xfc))) * 60, 2, 0, STR_PAD_LEFT); } else { $xfd = "-"; $xfe = $x158(abs(floor($xfc)), 2, 0, STR_PAD_LEFT) . '' . $x158((abs($xfc) - floor(abs($xfc))) * 60, 2, 0, STR_PAD_LEFT); } $xff = substr($x147(' ', 'T', $xd9->getSpecialFromDate()), 0, -3); $x100 = substr($x147(' ', 'T', $xd9->getSpecialToDate()), 0, -3); if ($xd9->type_id == 'bundle' && $xd9->special_price) { if ($xd9->price_type) { $x3e = $x14c($xd9->price * $xd9->special_price / 100, 2, ".", ""); } else { $x3e = $xd9->special_price; } } else { $x3e = $xd9->getSpecial_price(); } !isset($xd8['options'][1]) ? $x43 = false : ($x43 = $xd8['options'][1]); if ($xfb < $x3e && $xfa !== false) { $x3e = $xfb; } if ($x3e > 0) { if ($xd9->getTypeId() == "configurable") { if (isset($this->configurablePrices[$xd9->getId()][$product->getId()])) { $xf2 = 0; foreach ($this->configurablePrices[$xd9->getId()][$product->getId()] as $xf3) { if ($xf3["is_percent"]) { $xf2 += $xf3["pricing_value"] / 100 * $x3e; } else { $xf2 += $xf3["pricing_value"]; } } $x3e += $xf2; } } $x3e = $this->x167($x3e, $x62, $xd9->getTaxClassId(), $x43); !isset($xd8['options'][0]) ? $x3f = $x5c : ($x3f = $xd8['options'][0]); $x3e = $this->x166($x3e, $x3f); $x3e = $x14c($x3e, 2, '.', ''); } if ($x3e > 0) { $x4a = "<g:sale_price><![CDATA[" . $x3e . " " . $x3f . "]]></g:sale_price>\n"; } if ($x3e > 0 && $x100) { $x4a .= "<g:sale_price_effective_date><![CDATA[" . $xff . $xfd . $xfe . "/" . $x100 . $xfd . $xfe . "]]></g:sale_price_effective_date>\n"; } break; case "{image}": $xd9 = $this->checkReference($xd8['reference'], $product); $x101 = $xd9->getImage(); if (!isset($xd8['options'][0]) || $xd8['options'][0] == 0) { if ($xd9->getImage() && $xd9->getImage() != 'no_selection') { $x102 = 'catalog/product/' . $xd9->getImage(); $x4a = $x61 . $x147('//', '/', $x102); } else { $x4a = $x61 . '/catalog/product/placeholder/' . $x5b; } } elseif (isset($xa1[$xd9->getId()]['src'][$xd8['options'][0] - 1]) && $xd8['options'][0] > 0) { if ($xa1[$xd9->getId()]['src'][$xd8['options'][0] - 1] != $x101) { $x102 = 'catalog/product/' . $xa1[$xd9->getId()]['src'][$xd8['options'][0] - 1]; $x4a = $x61 . $x147('//', '/', $x102); } } break; case "{G:IMAGE_LINK}": $xd9 = $this->checkReference($xd8['reference'], $product); $x101 = $xd9->getImage(); $x103 = array($xd9->getSmall_image(), $xd9->getThumbnail()); $x104 = ''; $xeb = 0; if ($xd9->getImage() && $xd9->getImage() != 'no_selection') { $x102 = 'catalog/product/' . $xd9->getImage(); $x4a = $x61 . $x147('//', '/', $x102); $x104 .= "<g:image_link><![CDATA[" . $x4a . "]]></g:image_link>\n"; $xeb++; } $xe4 = 0; while (isset($xa1[$xd9->getId()]['src'][$xe4]) && $xeb < 10) { if ($xa1[$xd9->getId()]['src'][$xe4] != $x101) { if ($x156($xa1[$xd9->getId()]['src'][$xe4], $x103) || $xa1[$xd9->getId()]['disabled'][$xe4] != 1) { $x102 = 'catalog/product/' . $xa1[$xd9->getId()]['src'][$xe4]; $x4a = $x61 . $x147('//', '/', $x102); $x104 .= "<g:additional_image_link><![CDATA[" . $x4a . "]]></g:additional_image_link>\n"; $xeb++; } } $xe4++; } $x4a = $x104; break; case "{G:LINK}": $xd9 = $this->checkReference($xd8['reference'], $product); if ($xd9->getRequest_path()) { if (Mage::getStoreConfig("simplegoogleshopping/system/urlrewrite") == 2) { $x105 = explode(",", $xd9->getRequest_path()); usort($x105, array('Wyomind_Simplegoogleshopping_Model_Simplegoogleshopping', 'x161')); $x4a = $x60 . $x157($x105); } elseif (Mage::getStoreConfig("simplegoogleshopping/system/urlrewrite") == 3) { $x105 = explode(",", $xd9->getRequest_path()); usort($x105, array('Wyomind_Simplegoogleshopping_Model_Simplegoogleshopping', 'x161')); $x4a = $x60 . $x159($x105); } else { $x4a = $x60 . $xd9->getRequest_path(); } } else { $x4a = $xd9->getProductUrl(); } $x4a = "<link><![CDATA[" . $x4a . "]]></link>"; break; case "{url}": $xd9 = $this->checkReference($xd8['reference'], $product); if ($xd9->getRequest_path()) { if (Mage::getStoreConfig("simplegoogleshopping/system/urlrewrite") == 2) { $x105 = explode(",", $xd9->getRequest_path()); usort($x105, array('Wyomind_Simplegoogleshopping_Model_Simplegoogleshopping', 'x161')); $x4a = $x60 . $x157($x105); } elseif (Mage::getStoreConfig("simplegoogleshopping/system/urlrewrite") == 3) { $x105 = explode(",", $xd9->getRequest_path()); usort($x105, array('Wyomind_Simplegoogleshopping_Model_Simplegoogleshopping', 'x161')); $x4a = $x60 . $x159($x105); } else { $x4a = $x60 . $xd9->getRequest_path(); } } else { $x4a = $xd9->getProductUrl(); } break; case "{host}": $x4a = $x60; break; case "{uri}": $xd9 = $this->checkReference($xd8['reference'], $product); if ($xd9->getRequest_path()) { if (Mage::getStoreConfig("simplegoogleshopping/system/urlrewrite") == 2) { $x105 = explode(",", $xd9->getRequest_path()); usort($x105, array('Wyomind_Simplegoogleshopping_Model_Simplegoogleshopping', 'x161')); $x4a = $x157($x105); } elseif (Mage::getStoreConfig("simplegoogleshopping/system/urlrewrite") == 3) { $x105 = explode(",", $xd9->getRequest_path()); usort($x105, array('Wyomind_Simplegoogleshopping_Model_Simplegoogleshopping', 'x161')); $x4a = $x159($x105); } else { $x4a = $xd9->getRequest_path(); } } else { $x4a = $x147($x60, '', $xd9->getProductUrl()); } break; case '{G:AVAILABILITY}': $xd9 = $this->checkReference($xd8['reference'], $product); !isset($xd8['options'][0]) ? $x106 = 'in stock' : ($x106 = $xd8['options'][0]); !isset($xd8['options'][1]) ? $x107 = "out of stock" : ($x107 = $xd8['options'][1]); !isset($xd8['options'][2]) ? $x108 = "preorder" : ($x108 = $xd8['options'][2]); if ($xd9->getManageStock() && !$xd9->getUseConfigManageStock() && !$x5d || $xd9->getUseConfigManageStock() && $x5d || $xd9->getManageStock() && !$xd9->getUseConfigManageStock()) { if ($xd9->getIsInStock() > 0) { if ($product->type_id == "configurable") { $x109 = $xb0[$product->getId()]; } else { $x109 = $xd9->getQty(); } if ($x109 > 0) { $x4a = $x106; } else { if ($xd9->getBackorders() || $xd9->getUseConfigBackorders() && $x5e) { $x4a = $x108; } else { $x4a = $x107; } } } else { $x4a = $x107; } } else { $x4a = $x106; } $x4a = "<g:availability><![CDATA[" . $x4a . "]]></g:availability>"; break; case '{is_in_stock}': $xd9 = $this->checkReference($xd8['reference'], $product); !isset($xd8['options'][0]) ? $x106 = 'in stock' : ($x106 = $xd8['options'][0]); !isset($xd8['options'][1]) ? $x107 = "out of stock" : ($x107 = $xd8['options'][1]); !isset($xd8['options'][2]) ? $x108 = "preorder" : ($x108 = $xd8['options'][2]); if ($xd9->getManageStock() && !$xd9->getUseConfigManageStock() && !$x5d || $xd9->getUseConfigManageStock() && $x5d || $xd9->getManageStock() && !$xd9->getUseConfigManageStock()) { if ($xd9->getIsInStock() > 0) { if ($product->type_id == "configurable") { $x109 = $xb0[$product->getId()]; } else { $x109 = $xd9->getQty(); } if ($x109 > 0) { $x4a = $x106; } else { if ($xd9->getBackorders() || $xd9->getUseConfigBackorders() && $x5e) { $x4a = $x108; } else { $x4a = $x107; } } } else { $x4a = $x107; } } else { $x4a = $x106; } break; case '{stock_status}': $xd9 = $this->checkReference($xd8['reference'], $product); $xd9->getIs_in_stock() > 0 ? $x4a = 'in stock' : ($x4a = 'out of stock'); break; case '{qty}': $xd9 = $this->checkReference($xd8['reference'], $product); !isset($xd8['options'][0]) ? $x10a = 0 : ($x10a = $xd8['options'][0]); if ($product->type_id == "configurable") { $x4a = $xb0[$product->getId()]; $x4a = $x14c($x4a, $x10a, '.', ''); } else { if ($xd8['reference'] == "configurable") { $x4a = $x14c($xb0[$xd9->getId()], $x10a, '.', ''); } else { $x4a = $x14c($xd9->getQty(), $x10a, '.', ''); } } break; case "{categories_v1}": $xd9 = $this->checkReference($xd8['reference'], $product); !isset($xd8['options'][0]) || !$xd8['options'][0] || $xd8['options'][0] == 'INF' ? $x10b = INF : ($x10b = $xd8['options'][0]); !isset($xd8['options'][1]) ? $x10c = 1 : ($x10c = $xd8['options'][1]); !isset($xd8['options'][2]) || !$xd8['options'][2] || $xd8['options'][2] == 'INF' ? $x10d = INF : ($x10d = $xd8['options'][2]); $x10e = 0; $x4a = ''; $x10f = ''; foreach (explode(',', $xd9->getCategoriesIds()) as $x37 => $x7c) { $x6a ? $x110 = $x156($x7b[$x7c]["path"], $x6c) : ($x110 = !$x156($x7b[$x7c]["path"], $x6c)); if (isset($x7b[$x7c]) && $x10e < $x10b && ($x110 || $x6c[0] == "*")) { $x111 = 0; $x112 = explode('/', $x7b[$x7c]["path"]); if ($x156($x63, $x112)) { $x113 = ""; if ($x10e > 0) { $x10f = ","; } foreach ($x112 as $x114) { if (isset($x7b[$x114])) { if ($x7b[$x114]['level'] > $x10c && $x111 < $x10d) { if ($x111 > 0) { $x113 .= '>'; } $x113 .= $x7b[$x114]['name']; $x111++; } } } $x115 = ""; if (!empty($x113)) { $x4a .= $x10f . $x113 . $x115; $x10e++; } } } } break; case "{categories}": $x116 = null; $x10b = INF; $x10c = 1; $x117 = INF; $x118 = ', '; $x119 = " > "; if (count($xd8['options']) == 1) { !isset($xd8['options'][0]) ? $x116 = "last" : ($x116 = $xd8['options'][0]); $x10b = 1; } elseif (count($xd8['options']) == 2) { !isset($xd8['options'][0]) ? $x118 = ', ' : ($x118 = $xd8['options'][0]); !isset($xd8['options'][1]) ? $x119 = " > " : ($x119 = $xd8['options'][1]); } elseif (count($xd8['options']) > 2) { !isset($xd8['options'][0]) || !$xd8['options'][0] || $xd8['options'][0] == 'INF' ? $x10b = INF : ($x10b = $xd8['options'][0]); !isset($xd8['options'][1]) ? $x10c = 1 : ($x10c = $xd8['options'][1]); !isset($xd8['options'][2]) || !$xd8['options'][2] || $xd8['options'][2] == 'INF' ? $x117 = INF : ($x117 = $xd8['options'][2]); !isset($xd8['options'][3]) ? $x118 = ', ' : ($x118 = $xd8['options'][3]); !isset($xd8['options'][4]) ? $x119 = " > " : ($x119 = $xd8['options'][4]); } $xd9 = $this->checkReference($xd8['reference'], $product); $x102 = 0; $x11a = array(); foreach (explode(',', $xd9->getCategoriesIds()) as $x37 => $x7c) { $x6a ? $x110 = $x156(@$x7b[$x7c]["path"], $x6c) : ($x110 = !$x156(@$x7b[$x7c]["path"], $x6c)); if (isset($x7b[$x7c]) && ($x110 || $x6c[0] == "*")) { $x102++; $x11a[$x102] = array(); $x112 = explode('/', $x7b[$x7c]["path"]); if ($x156($x63, $x112)) { foreach ($x112 as $x114) { if (isset($x7b[$x114]) && $x7b[$x114]['name'] != null) { $x11a[$x102][] = $x7b[$x114]['name']; } } } } } $x11b = array(); usort($x11a, array('Wyomind_Simplegoogleshopping_Model_Simplegoogleshopping', 'x161Array')); if ($x116 == "last") { $x11a = $x15a($x11a); } $xd9->setCategoriesArray($x11a); $x11c = 0; foreach ($x11a as $x37 => $x111) { if ($x11c < $x10b) { foreach ($x111 as $x11d => $x11e) { if ($x11d >= $x10c && $x11d <= $x117) { if (!isset($x11b[$x11c])) { $x11b[$x11c] = array(); } $x11b[$x11c][] .= $x11e; } } if (count($x11b[$x11c])) { $x11c++; } } } $x4a = null; foreach ($x15b($x11b) as $x37 => $x11f) { if ($x37 > 0) { $x4a .= $x118; } $x4a .= implode($x119, $x11f); } break; case "{G:PRODUCT_TYPE_v1}": $xd9 = $this->checkReference($xd8['reference'], $product); !isset($xd8['options'][0]) || !$xd8['options'][0] || $xd8['options'][0] == 'INF' ? $x10b = INF : ($x10b = $xd8['options'][0]); !isset($xd8['options'][1]) ? $x10c = 1 : ($x10c = $xd8['options'][1]); !isset($xd8['options'][2]) || !$xd8['options'][2] || $xd8['options'][2] == 'INF' ? $x10d = INF : ($x10d = $xd8['options'][2]); $x10e = 0; $x4a = ''; foreach (explode(',', $xd9->getCategoriesIds()) as $x37 => $x7c) { $x6a ? $x110 = $x156($x7b[$x7c]["path"], $x6c) : ($x110 = !$x156($x7b[$x7c]["path"], $x6c)); if (@$x7b[$x7c]["include_in_menu"] && isset($x7b[$x7c]) && $x10e < $x10b && ($x110 || $x6c[0] == "*")) { $x111 = 0; $x112 = explode('/', $x7b[$x7c]["path"]); if ($x156($x63, $x112)) { $x113 = ''; $x10f = '<g:product_type><![CDATA['; foreach ($x112 as $x114) { if (isset($x7b[$x114])) { if ($x7b[$x114]['level'] > $x10c && $x111 < $x10d) { if ($x111 > 0) { $x113 .= ' > '; } $x113 .= $x7b[$x114]['name']; $x111++; } } } $x115 = "]]></g:product_type>\n"; if (!empty($x113)) { $x4a .= $x10f . $x113 . $x115; $x10e++; } } } } break; case "{G:PRODUCT_TYPE}": $x118 = "]]></g:product_type>\n<g:product_type><![CDATA["; $x119 = " > "; !isset($xd8['options'][0]) || !$xd8['options'][0] || $xd8['options'][0] == 'INF' ? $x10b = INF : ($x10b = $xd8['options'][0]); !isset($xd8['options'][1]) ? $x10c = 1 : ($x10c = $xd8['options'][1]); !isset($xd8['options'][2]) || !$xd8['options'][2] || $xd8['options'][2] == 'INF' ? $x117 = INF : ($x117 = $xd8['options'][2]); $xd9 = $this->checkReference($xd8['reference'], $product); $x102 = 0; $x11a = array(); foreach (explode(',', $xd9->getCategoriesIds()) as $x37 => $x7c) { $x6a ? $x110 = $x156(@$x7b[$x7c]["path"], $x6c) : ($x110 = !$x156(@$x7b[$x7c]["path"], $x6c)); if (isset($x7b[$x7c]) && ($x110 || $x6c[0] == "*")) { $x102++; $x11a[$x102] = array(); $x112 = explode('/', $x7b[$x7c]["path"]); if ($x156($x63, $x112)) { foreach ($x112 as $x114) { if (isset($x7b[$x114]) && $x7b[$x114]['name'] != null) { $x11a[$x102][] = $x7b[$x114]['name']; } } } } } $x11b = array(); usort($x11a, array('Wyomind_Simplegoogleshopping_Model_Simplegoogleshopping', 'x161Array')); foreach ($x11a as $x37 => $x111) { if ($x37 < $x10b) { foreach ($x111 as $x11d => $x11e) { if ($x11d > $x10c && $x11d <= $x117) { if (!isset($x11b[$x37])) { $x11b[$x37] = array(); } $x11b[$x37][] .= $x11e; } } } } $x4a = null; foreach ($x15b($x11b) as $x37 => $x11f) { if ($x37 > 0) { $x4a .= $x118; } $x4a .= implode($x119, $x11f); } if ($x11b) { $x4a = "<g:product_type><![CDATA[" . $x4a . "]]></g:product_type>\n"; } break; case "{G:GOOGLE_PRODUCT_CATEGORY}": $x120 = array(); !isset($xd8['options'][0]) ? $x116 = "longest" : ($x116 = $xd8['options'][0]); $xd9 = $this->checkReference($xd8['reference'], $product); foreach (explode(',', $xd9->getCategoriesIds()) as $x37 => $x7c) { if (isset($x7b[$x7c]["path"]) && isset($x6d[$x7b[$x7c]["path"]])) { $x120[] = $x6d[$x7b[$x7c]["path"]]; } } usort($x120, array('Wyomind_Simplegoogleshopping_Model_Simplegoogleshopping', 'x161')); if ($x116 == "shortest") { $x120 = $x15a($x120); } $x121 = $x159($x120); if ($x121 != "") { $x4a = "<g:google_product_category><![CDATA[" . $x121 . "]]></g:google_product_category>\n"; } break; case "{category_mapping}": isset($xd8["options"][0]) ? $x122 = $xd8["options"][0] : ($x122 = 0); $x4a = ""; $xd9 = $this->checkReference($xd8['reference'], $product); $x123 = 0; foreach (explode(',', $xd9->getCategoriesIds()) as $x37 => $x7c) { if (isset($x6d[$x7b[$x7c]["path"]])) { if ($x123 == $x122) { $x4a .= $x6d[$x7b[$x7c]["path"]]; break; } $x123++; } } break; case "{review_count}": $xd9 = $this->checkReference($xd8['reference'], $product); $x4a = ""; isset($xd8["options"][0]) && $xd8["options"][0] == "*" ? $x124 = 0 : ($x124 = $x58); if (isset($x9b[$xd9->getId()][$x124]["count"])) { $x125 = $x9b[$xd9->getId()][$x124]["count"]; if (isset($x125)) { $x4a .= $x125; } } break; case "{review_average}": $xd9 = $this->checkReference($xd8['reference'], $product); $x4a = ""; isset($xd8["options"][0]) && $xd8["options"][0] == "*" ? $x124 = 0 : ($x124 = $x58); !isset($xd8["options"][1]) || !$xd8["options"][1] ? $x126 = 5 : ($x126 = $xd8["options"][1]); if (isset($x9b[$xd9->getId()][$x124]["score"])) { $x127 = $x14c($x9b[$xd9->getId()][$x124]["score"] * $x126 / 100, 2, ".", ""); if (isset($x127)) { $x4a .= $x127; } } break; case "{G:PRODUCT_REVIEW}": $xd9 = $this->checkReference($xd8['reference'], $product); isset($xd8["options"][0]) && $xd8["options"][0] == "*" ? $x124 = 0 : ($x124 = $x58); !isset($xd8["options"][1]) || !$xd8["options"][1] ? $x126 = 5 : ($x126 = $xd8["options"][1]); $x4a = ""; if (isset($x9b[$xd9->getId()][$x124]["count"])) { $x125 = $x9b[$xd9->getId()][$x124]["count"]; $x127 = $x14c($x9b[$xd9->getId()][$x124]["score"] * $x126 / 100, 2, ".", ""); } if (isset($x127) && $x127 > 0) { $x4a .= "<g:product_review_average><![CDATA[" . $x127 . "]]></g:product_review_average>\n"; } if (isset($x125) && $x125 > 0) { $x4a .= "<g:product_review_count><![CDATA[" . $x125 . "]]></g:product_review_count>\n"; } unset($x127); unset($x125); break; case "{G:ITEM_GROUP_ID}": if (isset($this->configurable[$product->getId()])) { $xd9 = $this->checkReference('configurable', $product); $x4a = "<g:item_group_id><![CDATA[" . $xd9->getSku() . "]]></g:item_group_id>"; } break; case "{SC:EAN}": $x14d($xd8['options'][0]) && $xd8['options'][0] > 0 ? $x128 = $xd8['options'][0] : ($x128 = 0); $xd9 = $this->checkReference($xd8['reference'], $product); $x4a = explode(',', $xd9->getEan()); $x4a = "<g:ean><![CDATA[" . $x4a[$x128] . "]]></g:ean>"; break; case "{SC:IMAGES}": $xd9 = $this->checkReference($xd8['reference'], $product); $x101 = $xd9->getSmall_image(); $x103 = array($xd9->getImage(), $xd9->getThumbnail()); $x104 = ''; $xeb = 0; if ($xd9->getSmall_image() && $xd9->getSmall_image() != 'no_selection') { $x102 = $xd9->getSmall_image(); $x4a = $x102; $x104 .= "<g:image_link><![CDATA[" . $x4a . "]]></g:image_link>\n"; $xeb++; } $xe4 = 0; while (isset($xa1[$xd9->getId()]['src'][$xe4]) && $xeb < 10) { if ($xa1[$xd9->getId()]['src'][$xe4] != $x101) { if ($x156($xa1[$xd9->getId()]['src'][$xe4], $x103) || $xa1[$xd9->getId()]['disabled'][$xe4] != 1) { $x102 = $xa1[$xd9->getId()]['src'][$xe4]; $x4a = $x102; $x104 .= "<g:additional_image_link><![CDATA[" . $x4a . "]]></g:additional_image_link>\n"; $xeb++; } } $xe4++; } $x4a = $x104; break; case "{SC:DESCRIPTION}": $xd9 = $this->checkReference($xd8['reference'], $product); $x51 = $xd9->getDescription() . $xd9->getShortDescription(); $x129 = "|<iframe(.*)</iframe>|U"; $x14a($x129, $x51, $x12a); if ($x12a) { $x51 = $xd9->getAttributeText('manufacturer') . " " . $xd9->getName() . " - Part number: " . $xd9->getSku() . " - Category : {categories,[1],[1],[1]}"; } else { if ($x156("strip_tags", $xd8['options'])) { $x51 = $x15c('!\\<br /\\>!isU', " ", $x51); $x51 = $x15c('!\\<br/\\>!isU', " ", $x51); $x51 = $x15c('!\\<br>!isU', " ", $x51); $x51 = $x15d($x51); } if ($x156("html_entity_decode", $xd8['options'])) { $x51 = $x15e($x51, ENT_QUOTES, 'UTF-8'); } if ($x156("htmlentities", $xd8['options'])) { $x51 = htmlspecialchars($x51); } if (strlen($x51) > 900) { $x51 = substr($x51, 0, 900 - 3); $xdb = strrpos($x51, " "); $x51 = substr($x51, 0, $xdb) . '...'; } } if ($x51 == null) { $x51 = $xd9->getAttributeText('manufacturer') . " " . $xd9->getName() . " - Part number: " . $xd9->getSku() . " - Category : {categories,[1],[1],[1]}"; } $x51 = $x15c('/' . '[\\x00-\\x1F\\x7F]' . '|[\\x00-\\x7F][\\x80-\\xBF]+' . '|([\\xC0\\xC1]|[\\xF0-\\xFF])[\\x80-\\xBF]*' . '|[\\xC2-\\xDF]((?![\\x80-\\xBF])|[\\x80-\\xBF]{2,})' . '|[\\xE0-\\xEF](([\\x80-\\xBF](?![\\x80-\\xBF]))|' . '(?![\\x80-\\xBF]{2})|[\\x80-\\xBF]{3,})' . '/S', ' ', $x51); $x51 = $x147('â„¢', '', $x51); $x4a = "<description><![CDATA[" . $x51 . "]]></description>"; break; case "{SC:URL}": isset($xd8['options'][0]) ? $x12b = $xd8['options'][0] : ($x12b = ""); isset($xd8['options'][1]) ? $x12c = $xd8['options'][1] : ($x12c = ""); $xd9 = $this->checkReference($xd8['reference'], $product); if ($xd9->getRequest_path()) { $x4a = "<link><![CDATA[" . $x60 . $x12c . $xd9->getRequest_path() . $x12b . "]]></link>"; } else { $x4a = "<link><![CDATA[" . $xd9->getProductUrl() . "]]></link>"; } break; case "{SC:CONDITION}": $xd9 = $this->checkReference($xd8['reference'], $product); stristr($xd9->getName(), "refurbished") ? $xc7 = 'refurbished' : ($xc7 = 'new'); $x4a = "<g:condition><![CDATA[" . $xc7 . "]]></g:condition>"; break; case "{sc:condition}": $xd9 = $this->checkReference($xd8['reference'], $product); stristr($xd9->getName(), "refurbished") ? $xc7 = 'refurbished' : ($xc7 = 'new'); $x4a = $xc7; break; default: $xd9 = $this->checkReference($xd8['reference'], $product); if ($x156($xd8['name'], $x86)) { if ($x156($x87[$xd8['name']], array('select', 'multiselect'))) { eval('$x12e =($xd9->' . $xd8['methodName'] . ");"); $x12d = explode(',', $x12e); if (count($x12d) > 1) { $x4a = array(); foreach ($x12d as $xcd) { if (isset($x8c[$xcd][$x58])) { $x4a[] = $x8c[$xcd][$x58]; } else { if (isset($x8c[$xcd][0])) { $x4a[] = $x8c[$xcd][0]; } } } } else { if (isset($x8c[$x12d[0]][$x58])) { $x4a = $x8c[$x12d[0]][$x58]; } else { if (isset($x8c[$x12d[0]][0])) { $x4a = $x8c[$x12d[0]][0]; } } } } else { eval('$x4a =($xd9->' . $xd8['methodName'] . ");"); } } if ($x156(@$x84[$xd8['name']], $x84)) { $x4a = $x84[$xd8['name']]; } $x4a = $x15c('/' . '[\\x00-\\x1F\\x7F]' . '|[\\x00-\\x7F][\\x80-\\xBF]+' . '|([\\xC0\\xC1]|[\\xF0-\\xFF])[\\x80-\\xBF]*' . '|[\\xC2-\\xDF]((?![\\x80-\\xBF])|[\\x80-\\xBF]{2,})' . '|[\\xE0-\\xEF](([\\x80-\\xBF](?![\\x80-\\xBF]))|' . '(?![\\x80-\\xBF]{2})|[\\x80-\\xBF]{3,})' . '/S', ' ', $x4a); $x4a = $x147('â„¢', '', $x4a); $x12f = 0; if (count($xd8['options']) > 0) { while (isset($xd8['options'][$x12f])) { switch ($xd8['options'][$x12f]) { case "substr": if (isset($xd8['options'][$x12f + 1]) && strlen($x4a) > $xd8['options'][$x12f + 1]) { $x4a = substr($x4a, 0, $xd8['options'][$x12f + 1] - 3); $xdb = strrpos($x4a, " "); $x4a = substr($x4a, 0, $xdb) . $xd8['options'][$x12f + 2]; } $x12f++; $x12f++; break; case "htmlentities": $x4a = htmlspecialchars($x4a); break; case "strip_tags": $x130 = " "; $x4a = $x15c('!\\<br /\\>!isU', $x130, $x4a); $x4a = $x15c('!\\<br/\\>!isU', $x130, $x4a); $x4a = $x15c('!\\<br>!isU', $x130, $x4a); $x4a = $x15d($x4a); break; case "implode": $x4a = $x152($x4a) ? implode($xd8['options'][$x12f + 1], $x4a) : $x4a; $x12f++; break; case "float": $x4a = $x14c($x4a, $xd8['options'][$x12f + 1], '.', ''); $x12f++; break; case "html_entity_decode": $x4a = $x15e($x4a, ENT_QUOTES, 'UTF-8'); break; case "inline": $x4a = $x15c('/(\\r\\n|\\n|\\r|\\r\\n|\\t)/s', '', $x4a); break; case "strtolower": $x4a = $x15f($x4a, "UTF8"); break; case "strtoupper": $x4a = $x160($x4a, "UTF8"); break; case "cleaner": $x4a = $x15c('/' . '[\\x00-\\x1F\\x7F]' . '|[\\x00-\\x7F][\\x80-\\xBF]+' . '|([\\xC0\\xC1]|[\\xF0-\\xFF])[\\x80-\\xBF]*' . '|[\\xC2-\\xDF]((?![\\x80-\\xBF])|[\\x80-\\xBF]{2,})' . '|[\\xE0-\\xEF](([\\x80-\\xBF](?![\\x80-\\xBF]))|' . '(?![\\x80-\\xBF]{2})|[\\x80-\\xBF]{3,})' . '/S', ' ', $x4a); $x4a = $x147('â„¢', '', $x4a); break; default: if (stristr($xd8['options'][$x12f], "%s")) { $xec = $x147("%s", '$x4a', $xd8['options'][$x12f]); eval('$x4a=' . $xec . '; '); } else { eval('$x4a=' . $xd8['options'][$x12f] . '($x4a); '); } break; } $x12f++; } } break; } $x4a = $x147(array("<", ">", '"', '\\'), array("__LOWERTHAN__", "__HIGHERTHAN__", "__QUOTES__", "__BACKSLASH__"), $x4a); if ($x152($x4a)) { $x4a = implode(",", $x4a); } if ($x4a != "") { $x48 = $x147($xd8['fullpattern'], $x4a, $x48); } } foreach ($x76 as $x131) { $x48 = $x147($x131['fullpattern'], "", $x48); } $x48 = $this->x163($x48, $product); $x48 = $this->x169($x48); $x48 = $this->x168($x48); $x48 = $x147(array("__LOWERTHAN__", "__HIGHERTHAN__", "__QUOTES__", "__BACKSLASH__"), array("<", ">", '"', '\\'), $x48); if (!empty($x48)) { $x73 .= "<item>"; $x73 .= "\n" . $x48 . "\n"; $x73 .= "</item>" . "\n"; $xc3++; $this->_inc = $xd4; $xd4++; } $x132 = array(); try { $xd9 = new SimpleXMLElement("<item>" . $x147(array("<g:", "</g:"), array("<g_", "</g_"), $x48) . "</item>"); } catch (Exception $x133) { $this->x16a($x4f, $x53, "FAILLED;0"); Mage::throwException($x133->getMessage() . " " . Mage::helper('simplegoogleshopping')->__("Please check the template syntax.")); } $x134 = array(); foreach ($requirements as $x135) { if ($x152($x135['depends'])) { $x136 = false; foreach ($x135['depends'] as $x137 => $xc7) { foreach ($xc7 as $x138 => $x4a) { $x139 = $this->x16b($requirements, $x137); switch ($x138) { case "eq": if ($xd9->{$x139}['tag'] == $x4a) { $x136 = true; } else { $x136 = false; } break; case "neq": if ($xd9->{$x139}['tag'] != $x4a) { $x136 = true; } else { $x136 = false; } break; case "like": if (stristr($xd9->{$x139}['tag'], $x4a)) { $x136 = true; } else { $x136 = false; } break; } } } } else { $x136 = true; } if ($x136 == true && !$x156($x135['label'], $x134)) { $x134[] = $x135['label']; if ($x135['required'] && empty($xd9->{$x135}['tag'])) { $this->x16c($x135['label'], 'required', $xd9->{"g_id"}); } elseif ($x135['recommended'] && empty($xd9->{$x135}['tag'])) { $this->x16c($x135['label'], 'recommended', $xd9->{"g_id"}, null); } elseif ((int) $x135['occurrence'] < count($xd9->{$x135}['tag'])) { $this->x16c($x135['label'], 'toomany', $xd9->{"id"}); } else { if (isset($x135['length']) && strlen($xd9->{$x135}['tag']) > $x135['length']) { $this->x16c($x135['label'], 'toolong', $xd9->{"g_id"}, $x135['length']); } if (isset($x135['type']) && $x135['type'] == "RegExp" && !empty($xd9->{$x135}['tag']) && !$x14a("/^" . $x135['regexp'] . "\$/i", $xd9->{$x135}['tag'])) { $this->x16c($x135['label'], 'invalid', $xd9->{"g_id"}, $x135['say']); } elseif (isset($x135['type']) && ($x135['type'] == "GoogleProductCategory" || $x135['type'] == "Text")) { } elseif (isset($x135['type']) && !empty($xd9->{$x135}['tag']) && $x135['type'] != "RegExp") { switch ($x135['type']) { case "Boolean": $x13a = "/^true|false\$/i"; break; case "Alphanumeric": $x13a = "/^[\\wc73\\-]+\$/"; break; break; case "Url": $x13a = "/^http(s)?:\\/\\/.+\$/"; break; case "Price": $x13a = '/^([0-9]+\\.[0-9]{2})\\s?[A-Z]{3}$/'; break; } if (!$x14a($x13a, $xd9->{$x135}['tag'], $x13b)) { $this->x16c($x135['label'], 'invalid', $xd9->{"g_id"}, $x135['type']); } elseif ($x135['type'] == "Price" && (double) $x13b[1] < 0.01) { $this->x16c($x135['label'], 'invalid', $xd9->{"g_id"}, $x135['type']); } } } } } if ($this->_display) { $x74 .= $x73; $x73 = ''; } else { if ($xc3 % Mage::getStoreConfig("simplegoogleshopping/system/buffer") == 0) { $x3a->streamWrite($x73); unset($x73); $x73 = ''; Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" . $xd4 . "/" . $this->_counter . " items added", null, $this->x165('.log')); $x13c = time(true); $x13d = (int) $x13c - (int) $xd5; $this->_time += $x13d; $this->x16a($x4f, $x53, "PROCESSING; {$xd4}; " . $this->_counter . ";" . $x13d); $xd5 = time(true); } } if ($this->_limit && $xd4 > $this->_limit) { break 2; } } } $x73 .= '</channel>' . "\n"; $x73 .= '</rss>'; if (!$this->_display) { $x3a->streamWrite($x73); $this->x16a($x4f, $x53, "SUCCEED;ˆ0;ˆ0; 0"); } Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " . ($xd4 - 1) . "/" . $this->_counter . " items added", null, $this->x165('.log')); unset($xab); $x74 .= $x73; if ($this->_display && !$this->_debug) { return $x74; } elseif ($this->_debug) { echo "<br><br>------------ XML OUTPUT ----------------<br>"; $x51 = "<pre>" . htmlentities($x74) . "</pre>"; return $x51; } else { $x3a->streamClose(); $x3a->mv($this->x165(), $this->x165(false)); $x3a->rm($this->x165()); $this->setSimplegoogleshopping_time(Mage::getSingleton('core/date')->gmtDate('Y-m-d H:i:s')); $this->_errorReport['stats'] = array($xd4 - 1, $this->_time); $this->setSimplegoogleshopping_report(serialize($this->_errorReport)); $this->save(); Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Temp file closed and moved to " . $this->x165(false), null, $this->x165('.log')); } Mage::app()->setCurrentStore(0); return $this; }
public function saveAction() { $request = $this->getRequest(); $params = $request->getParams(); $path = ''; $delimiter = $request->getParam('delimiter', false); $enclosure = $request->getParam('enclosure', false); try { if (@empty($_FILES['file']['name'])) { Mage::getSingleton('adminhtml/session')->addError(Mage::helper('giftcards')->__('An error occurred while importing Gift Cards.')); $this->getResponse()->setRedirect($this->getUrl('giftcards/adminhtml_giftcards/index')); return; } $file = $_FILES['file']['name']; if (empty($file)) { Mage::getSingleton('adminhtml/session')->addError(Mage::helper('giftcards')->__('An error occurred while importing Gift Cards.')); $this->getResponse()->setRedirect($this->getUrl('giftcards/adminhtml_giftcards/index')); return; } $path = Mage::getBaseDir('var') . DS . 'import' . DS; $uploader = new Varien_File_Uploader('file'); $uploader->setAllowRenameFiles(false); $uploader->setFilesDispersion(false); $uploader->save($path, $file); $io = new Varien_Io_File(); $io->open(array('path' => $path)); $io->streamOpen($path . $file, 'r'); $io->streamLock(true); $map = $io->streamReadCsv($delimiter, $enclosure); while ($data = $io->streamReadCsv($delimiter, $enclosure)) { $giftCardCode = trim($data[self::GIFT_CARD_CODE_COLUMN]); $amount = trim($data[self::GIFT_CARD_AMOUNT_COLUMN]); $balance = trim($data[self::GIFT_CARD_BALANCE_COLUMN]); $reference = trim($data[self::GIFT_CARD_REFERENCE_COLUMN]); // The data index is the columns from the file being // imported eg: // first column is gift card code, it will be find at data[self::GIFT_CARD_CODE_COLUMN] // and so forth if ($giftCardCode) { // Here we can check if we should override // update or skip gift card import if it // already exist in the database. $existingGiftCard = $this->giftCardExist($giftCardCode, true); if (!$existingGiftCard) { // A gift card with this code was not // found we are good to proceed and // import/update this giftCard $model = Mage::getModel('giftcards/giftcards'); $model->setCardReference($reference); $model->setCardBalance($this->checkBalance($amount, $balance)); $model->setCardAmount($amount); $model->setCardCode($giftCardCode); $model->setCardStatus(1); $model->save(); } else { if ($params['import_action'] === 'update') { // Update gift card on duplicate $existingGiftCard->setCardReference($reference); $existingGiftCard->setCardBalance($this->checkBalance($amount, $balance)); $existingGiftCard->setCardAmount($amount); $existingGiftCard->setCardCode($giftCardCode); $existingGiftCard->setCardStatus(1); $existingGiftCard->save(); } // skip option... continue; } } else { // $giftCardCode not valid... continue; } } Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('giftcards')->__('Gift Cards where succesfully imported ')); } catch (Mage_Core_Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError(Mage::helper('giftcards')->__($e->getMessage() . ' An error occurred while importing Gift Cards.')); } $this->getResponse()->setRedirect($this->getUrl('giftcards/adminhtml_giftcards/index')); }
/** * Upload table rate file and import data from it * * @param Varien_Object $object * * @throws Mage_Core_Exception * @return Mage_Shipping_Model_Mysql4_Carrier_Tablerate */ public function uploadAndImport(Varien_Object $object, $csvFile = null) { $this->_log(__METHOD__); if (!$csvFile && !empty($_FILES['groups']['tmp_name']['zitec_dpd']['fields']['import']['value'])) { $csvFile = $_FILES['groups']['tmp_name']['zitec_dpd']['fields']['import']['value']; } if (!$csvFile) { return $this; } $website = Mage::app()->getWebsite($object->getScopeId()); $this->_importWebsiteId = (int) $website->getId(); $this->_importUniqueHash = array(); $this->_importErrors = array(); $this->_importedRows = 0; $io = new Varien_Io_File(); $info = pathinfo($csvFile); $io->open(array('path' => $info['dirname'])); $io->streamOpen($info['basename'], 'r'); // check and skip headers $headers = $io->streamReadCsv(); if ($headers === false || count($headers) < self::CSV_COL_COUNT) { $io->streamClose(); Mage::throwException($this->_getHelper()->__('Invalid Table Rates File Format')); } $adapter = $this->_getWriteAdapter(); $adapter->beginTransaction(); try { $rowNumber = 1; $importData = array(); $this->_loadDirectoryCountries(); $this->_loadDirectoryRegions(); // delete old data by website and condition name $condition = array('website_id = ?' => $this->_importWebsiteId); $adapter->delete($this->getMainTable(), $condition); while (false !== ($csvLine = $io->streamReadCsv())) { $rowNumber++; if (is_array($csvLine)) { foreach ($csvLine as &$cell) { $cell = filter_var($cell, FILTER_SANITIZE_STRING); } } if (empty($csvLine)) { continue; } $row = $this->_getImportRow($csvLine, $rowNumber); if ($row !== false) { $importData[] = $row; } if (count($importData) == 5000) { $this->_saveImportData($importData); $importData = array(); } } $this->_saveImportData($importData); $io->streamClose(); } catch (Mage_Core_Exception $e) { $adapter->rollback(); $io->streamClose(); Mage::throwException($e->getMessage()); } catch (Exception $e) { $adapter->rollback(); $io->streamClose(); $this->_log($e->getMessage()); Mage::throwException($this->_getHelper()->__('An error occurred while import table rates.')); } $adapter->commit(); if ($this->_importErrors) { array_unshift($this->_importErrors, ""); $error = $this->_getHelper()->__('%1$d records have been imported. See the following list of errors for each record that has not been imported: %2$s', $this->_importedRows, implode(" \n", $this->_importErrors)); Mage::throwException($error); } return $this; }
/** * Upload address list file and import data from it * * @param Varien_Object $object * @throws Mage_Core_Exception * @return Hackathon_MailGuard_Model_Resource_Address */ public function uploadAndImport(Varien_Object $object) { if (empty($_FILES['groups']['tmp_name']['csv_file_upload']['fields']['address_list']['value'])) { return $this; } $csvFile = $_FILES['groups']['tmp_name']['csv_file_upload']['fields']['address_list']['value']; $this->_importColumnMapping = array(); $this->_importErrors = array(); $this->_importUniqueHash = array(); $this->_importedRows = 0; $this->_typeValues = Mage::getModel('hackathon_mailguard/system_config_source_type')->getOptionArray(); $io = new Varien_Io_File(); $info = pathinfo($csvFile); $io->open(array('path' => $info['dirname'])); $io->streamOpen($info['basename'], 'r'); // check and skip headers $headers = $io->streamReadCsv(); if ($headers === false || count($headers) < 2) { $io->streamClose(); Mage::throwException(Mage::helper('hackathon_mailguard')->__('Invalid Address List File Format')); } if (($this->_importColumnMapping[self::COL_MAILADDRESS] = array_search(self::COL_MAILADDRESS, $headers)) === false) { Mage::throwException(Mage::helper('hackathon_mailguard')->__('Column "' . self::COL_MAILADDRESS . '" not found.')); } if (($this->_importColumnMapping[self::COL_TYPE] = array_search(self::COL_TYPE, $headers)) === false) { Mage::throwException(Mage::helper('hackathon_mailguard')->__('Column "' . self::COL_TYPE . '" not found.')); } $adapter = $this->_getWriteAdapter(); $adapter->beginTransaction(); try { $rowNumber = 1; $importData = array(); $condition = array(); $adapter->delete($this->getMainTable(), $condition); while (false !== ($csvLine = $io->streamReadCsv())) { $rowNumber++; if (empty($csvLine)) { continue; } $row = $this->_getImportRow($csvLine, $rowNumber); if ($row !== false) { $importData[] = $row; } if (count($importData) == 5000) { $this->_saveImportData($importData); $importData = array(); } } $this->_saveImportData($importData); $io->streamClose(); } catch (Mage_Core_Exception $e) { $adapter->rollback(); $io->streamClose(); Mage::throwException($e->getMessage()); } catch (Exception $e) { $adapter->rollback(); $io->streamClose(); Mage::logException($e); Mage::throwException(Mage::helper('hackathon_mailguard')->__('An error occurred while import the address list.')); } $adapter->commit(); if ($this->_importErrors) { $error = Mage::helper('hackathon_mailguard')->__('File has not been imported. See the following list of errors: %s', implode(" \n", $this->_importErrors)); Mage::throwException($error); } return $this; }
/** * Uploads the file and imports the data into the table. * * @param Varien_Object $object * @return $this */ public function uploadAndImport(Varien_Object $object) { if (empty($_FILES['groups']['tmp_name']['dpdparcelshops']['fields']['custom_parcelshops_import']['value'])) { return $this; } $website = Mage::app()->getWebsite($object->getScopeId()); $this->_importWebsiteId = (int) $website->getId(); $csvFile = $_FILES['groups']['tmp_name']['dpdparcelshops']['fields']['custom_parcelshops_import']['value']; $io = new Varien_Io_File(); $info = pathinfo($csvFile); $io->open(array('path' => $info['dirname'])); $io->streamOpen($info['basename'], 'r'); $adapter = $this->_getWriteAdapter(); $adapter->beginTransaction(); try { $rowNumber = 1; $importData = array(); $parcelShopNumber = 0; $totalrows = count(file($csvFile)); $condition = array('parcelshop_website_id = ?' => $this->_importWebsiteId); $adapter->delete($this->getMainTable(), $condition); while (false !== ($csvLine = $io->streamReadCsv(";"))) { $rowNumber++; if (empty($csvLine)) { continue; } $row = $this->_getImportRow($csvLine, $rowNumber, $totalrows); if ($row !== false) { if ($csvLine[0] == 'GR') { $parcelShopNumber++; } if (!isset($importData[$parcelShopNumber])) { $importData[$parcelShopNumber] = array(); } $importData[$parcelShopNumber] = array_merge($importData[$parcelShopNumber], $row); } } $this->_saveImportData($importData); $io->streamClose(); } catch (Mage_Core_Exception $e) { if (count($rowNumber) < 5) { $this->_importErrors[] = Mage::helper('dpd')->__('Invalid ParcelShops format in the Row #%s', $rowNumber); return false; } $adapter->rollback(); $io->streamClose(); Mage::throwException($e->getMessage()); } catch (Exception $e) { $adapter->rollback(); $io->streamClose(); Mage::helper('dpd')->log($e, Zend_Log::ERR); Mage::throwException(Mage::helper('dpd')->__('An error occurred while importing ParcelShops. Check the log for details.')); } if ($this->_importErrors) { $adapter->rollback(); $error = Mage::helper('dpd')->__('File has not been imported. See the following list of errors: %s', implode(" \n", $this->_importErrors)); Mage::throwException($error); } $adapter->commit(); return $this; }
/** * Upload table rate file and import data from it * * @param Varien_Object $object * @throws Mage_Core_Exception * @return Mage_Shipping_Model_Mysql4_Carrier_Tablerate */ public function uploadAndImport(Varien_Object $object) { if (empty($_FILES['groups']['tmp_name']['tablerate']['fields']['import']['value'])) { return $this; } $csvFile = $_FILES['groups']['tmp_name']['tablerate']['fields']['import']['value']; $website = Mage::app()->getWebsite($object->getScopeId()); $this->_importWebsiteId = (int) $website->getId(); $this->_importUniqueHash = array(); $this->_importErrors = array(); $this->_importedRows = 0; $io = new Varien_Io_File(); $info = pathinfo($csvFile); $io->open(array('path' => $info['dirname'])); $io->streamOpen($info['basename'], 'r'); // check and skip headers $headers = $io->streamReadCsv(); if ($headers === false || count($headers) < 5) { $io->streamClose(); Mage::throwException(Mage::helper('shipping')->__('Invalid Table Rates File Format')); } if ($object->getData('groups/tablerate/fields/condition_name/inherit') == '1') { $conditionName = (string) Mage::getConfig()->getNode('default/carriers/tablerate/condition_name'); } else { $conditionName = $object->getData('groups/tablerate/fields/condition_name/value'); } $this->_importConditionName = $conditionName; $adapter = $this->_getWriteAdapter(); $adapter->beginTransaction(); try { $rowNumber = 1; $importData = array(); $this->_loadDirectoryCountries(); $this->_loadDirectoryRegions(); // delete old data by website and condition name $condition = array('website_id = ?' => $this->_importWebsiteId, 'condition_name = ?' => $this->_importConditionName); $adapter->delete($this->getMainTable(), $condition); while (false !== ($csvLine = $io->streamReadCsv())) { $rowNumber++; if (empty($csvLine)) { continue; } $row = $this->_getImportRow($csvLine, $rowNumber); if ($row !== false) { $importData[] = $row; } if (count($importData) == 5000) { $this->_saveImportData($importData); $importData = array(); } } $this->_saveImportData($importData); $io->streamClose(); } catch (Mage_Core_Exception $e) { $adapter->rollback(); $io->streamClose(); Mage::throwException($e->getMessage()); } catch (Exception $e) { $adapter->rollback(); $io->streamClose(); Mage::logException($e); Mage::throwException(Mage::helper('shipping')->__('An error occurred while import table rates.')); } $adapter->commit(); if ($this->_importErrors) { $error = Mage::helper('shipping')->__('%1$d records have been imported. See the following list of errors for each record that has not been imported: %2$s', $this->_importedRows, implode(" \n", $this->_importErrors)); Mage::throwException($error); } return $this; }
/** * Upload CSV file of Tablerate * * @see MMind_Shippingplus_Model_Config_Shippingplus._afterSave() * @param Varien_Object $object * @throws Mage_Core_Exception * @return MMind_Shippingplus_Model_Resource_Shippingplus_Import ***/ public function uploadAndImport(Varien_Object $object) { if (empty($_FILES['groups']['tmp_name']['mmshippingplus']['fields']['import_tablerate']['value'])) { return $this; } $csvFile = $_FILES['groups']['tmp_name']['mmshippingplus']['fields']['import_tablerate']['value']; $website = Mage::app()->getWebsite($object->getScopeId()); $this->_importWebsiteId = (int) $website->getId(); $io = new Varien_Io_File(); $info = pathinfo($csvFile); $io->open(array('path' => $info['dirname'])); $io->streamOpen($info['basename'], 'r'); // check and skip headers $headers = $io->streamReadCsv(); if ($headers === false || count($headers) < $this->tablerate_cols) { $io->streamClose(); Mage::throwException(Mage::helper('mmshippingplus')->__('Invalid CSV Table Rates File Format')); } $adapter = $this->_getWriteAdapter(); $adapter->beginTransaction(); try { $rowNumber = 1; $importData = array(); // delete old data by website and condition name $condition = array('website_id = ?' => $this->_importWebsiteId); $adapter->delete($this->getMainTable(), $condition); while (false !== ($csvLine = $io->streamReadCsv())) { $rowNumber++; $nomulti = false; if (empty($csvLine)) { continue; } $row = $this->_getImportRow($csvLine, $rowNumber); if ($row !== false) { // Import with Multi country $countries = explode("|", $row[1]); foreach ($countries as $country) { $row[1] = $country; // Import with Multi Region Code $regions = explode("|", $row[2]); foreach ($regions as $region) { $row[2] = $region; // Import with Multi ZIP Code $zips = explode("|", $row[3]); foreach ($zips as $zip) { $row[3] = $zip; $importData[] = $row; } } } } if (count($importData) == 5000) { $this->_saveImportData($importData); $importData = array(); } } $this->_saveImportData($importData); $io->streamClose(); } catch (Mage_Core_Exception $e) { $io->streamClose(); Mage::throwException($e->getMessage()); } catch (Exception $e) { $io->streamClose(); Mage::logException($e); Mage::throwException(Mage::helper('mmshippingplus')->__('An error occurred while import CSV Table rates.')); } $adapter->commit(); if ($this->_importErrors) { $error = Mage::helper('mmshippingplus')->__('%1$d records have been imported. See the following list of errors for each record that has not been imported: %2$s', $this->_importedRows, implode(" \n", $this->_importErrors)); Mage::throwException($error); } return $this; }
public function render(Varien_Object $row) { $dir = Mage::getBaseDir() . DS . 'var' . DS . 'tmp' . DS; $file = $dir . "sgs_" . $row->getId() . ".flag"; $flag = new Varien_Io_File(); $flag->open(array('path' => $dir)); if ($flag->fileExists($file, false)) { $flag->streamOpen($file, 'r'); $line = $flag->streamReadCsv(";"); $stats = $flag->streamStat(); if ($line[0] == $this::_PROCESSING) { $updated_at = $stats["mtime"]; $task_time = $line[3]; if (Mage::getSingleton('core/date')->gmtTimestamp() > $updated_at + $task_time * 10) { $line[0] = 'FAILED'; } elseif (Mage::getSingleton('core/date')->gmtTimestamp() > $updated_at + $task_time * 2) { $line[0] = 'HOLD'; } } elseif ($line[0] == $this::_SUCCEED) { $cron = array(); $cron['curent']['localTime'] = Mage::getSingleton('core/date')->timestamp(); $cron['file']['localTime'] = Mage::getSingleton('core/date')->timestamp($stats["mtime"]); $cronExpr = json_decode($row->getCronExpr()); $i = 0; foreach ($cronExpr->days as $d) { foreach ($cronExpr->hours as $h) { $time = explode(':', $h); if (date('l', $cron['curent']['localTime']) == $d) { $cron['tasks'][$i]['localTime'] = strtotime(Mage::getSingleton('core/date')->date('Y-m-d')) + $time[0] * 60 * 60 + $time[1] * 60; } else { $cron['tasks'][$i]['localTime'] = strtotime("last " . $d, $cron['curent']['localTime']) + $time[0] * 60 * 60 + $time[1] * 60; } if ($cron['tasks'][$i]['localTime'] >= $cron['file']['localTime'] && $cron['tasks'][$i]['localTime'] <= $cron['curent']['localTime']) { $line[0] = $this::_PENDING; continue 2; } $i++; } } } switch ($line[0]) { case $this::_SUCCEED: $severity = 'notice'; $status = Mage::helper("simplegoogleshopping")->__($line[0]); break; case $this::_PENDING: $severity = 'minor'; $status = Mage::helper("simplegoogleshopping")->__($line[0]); break; case $this::_PROCESSING: $percent = round($line[1] * 100 / $line[2]); $severity = 'minor'; $status = Mage::helper("simplegoogleshopping")->__($line[0]) . " [" . $percent . "%]"; break; case $this::_HOLD: $severity = 'major'; $status = Mage::helper("simplegoogleshopping")->__($line[0]); break; case $this::_FAILED: $severity = 'critical'; $status = Mage::helper("simplegoogleshopping")->__($line[0]); break; default: $severity = 'critical'; $status = Mage::helper("simplegoogleshopping")->__("ERROR"); break; } } else { $severity = 'minor'; $status = Mage::helper("simplegoogleshopping")->__($this::_PENDING); } $script = "<script language='javascript' type='text/javascript'>var updater_url='" . $this->getUrl('/simplegoogleshopping/updater') . "'</script>"; return $script . "<span class='grid-severity-{$severity} updater' cron='" . $row->getCronExpr() . "' id='feed_" . $row->getId() . "'><span>" . $status . "</span></span>"; }
public function uploadAndImport(Varien_Object $object) { if (empty($_FILES['groups']['tmp_name']['import']['fields']['file']['value'])) { return $this; } $csvFile = $_FILES['groups']['tmp_name']['import']['fields']['file']['value']; $website = Mage::app()->getWebsite($object->getScopeId()); $this->_importWebsiteId = (int) $website->getId(); $this->_importUniqueHash = array(); $this->_importErrors = array(); $this->_importedRows = 0; $io = new Varien_Io_File(); $info = pathinfo($csvFile); $io->open(array('path' => $info['dirname'])); $io->streamOpen($info['basename'], 'r'); // check and skip headers $headers = $io->streamReadCsv(";"); if ($headers === false || count($headers) < 5) { $io->streamClose(); Mage::throwException(Mage::helper('amlanding')->__('Invalid Landing Pages File Format')); } else { $this->_columns = $this->getFieldsByAliases($headers, Mage::helper('amlanding/import')->getColumnsAliasesForCsv()); } $adapter = $this->_getWriteAdapter(); $adapter->beginTransaction(); try { $rowNumber = 1; $importData = array(); $this->loadExistingPages(); while (false !== ($csvLine = $io->streamReadCsv(";"))) { $rowNumber++; if (empty($csvLine)) { continue; } $row = $this->validateCSVRow($csvLine, $rowNumber); if ($row !== false) { $importData[] = $row; } if (count($importData) == 5000) { $this->saveImportData($importData); $importData = array(); } } $this->saveImportData($importData); $io->streamClose(); } catch (Mage_Core_Exception $e) { $adapter->rollback(); $io->streamClose(); Mage::throwException($e->getMessage()); } catch (Exception $e) { $adapter->rollback(); $io->streamClose(); Mage::logException($e); Mage::throwException(Mage::helper('amlanding')->__('An error occurred while import Landing Pages.') . $e->getMessage()); } $adapter->commit(); if ($this->_importErrors) { $error = Mage::helper('shipping')->__('Landing Pages has not been imported completely. See the following list of errors:<br /> %s', implode(" \n", $this->_importErrors)); Mage::throwException($error); } return $this; }
public function importProcess() { $x7a = "stristr"; $x7b = "is_readable"; $x7c = "time"; $x7d = "file_get_contents"; $x7e = "in_array"; $x7f = "implode"; $x80 = "array_key_exists"; $x81 = "trim"; $x82 = "str_replace"; $x83 = "log"; $x84 = "is_array"; $x85 = "json_encode"; $x86 = "json_decode"; $x87 = "array_splice"; $x88 = "array_unshift"; $x89 = "count"; $x8a = "is_numeric"; $x8b = "array_push"; $x8c = "strtolower"; $x8d = "strstr"; $x8e = "explode"; $x8f = "addslashes"; Mage::$x83("-------------------- IMPORTATION PROCESS ---------------", null, "MassStockUpate.{$x83}"); $this->x90(); $x4a = $this->getFilePath(); if ($this->getFileSystemType() === "1") { $x3b = $this->x91(); if ($x84($x3b)) { $x4b['status'] = 'error'; $x4b['body'] = $x3b[0]; die($x85($x4b)); } else { $x4a = $x3b; } } $x31 = new Varien_Io_File(); $x32 = $x31->getCleanPath(Mage::getBaseDir() . "/" . $x4a); if ($this->getFileType() === "1") { $x49 = $this->x92($x32, $this->getXpathToProduct()); if ($x84($x49)) { $x4b['status'] = 'error'; $x4b['body'] = $x49[0]; die($x85($x4b)); } $x32 = $x31->getCleanPath(Mage::getBaseDir() . '/' . $x49); } $x31->streamOpen($x32, "r"); Mage::$x83("--> File opened : " . $x32, null, "MassStockUpate.{$x83}"); $x4c = $this->getIdentifierCode() ? $this->getIdentifierCode() : "sku"; $x41 = Mage::getModel("catalog/product")->getCollection()->addAttributeToSelect($x4c); foreach ($x41 as $x4d) { $this->_products[$x81($x4d->getData($x4c))] = $x4d->getId(); } Mage::$x83("--> Products collected", null, "MassStockUpate.{$x83}"); if (Mage::helper("core")->isModuleEnabled("Wyomind_Advancedinventory")) { $x4e = Mage::getModel("advancedinventory/stock")->getCollection(); foreach ($x4e as $x4f) { $this->_stocks[$x4f->getProductId()] = $x4f->getId(); } Mage::$x83("--> Local stocks collected (Advanced Inventory)", null, "MassStockUpate.{$x83}"); } $x50 = array("ac" => "activation_code", "ak" => "activation_key", "bu" => "base_url", "md" => "md5", "th" => "this", "dm" => "_demo", "ext" => "msi", "ver" => "3.9.2"); $x51 = Mage::getSingleton("core/resource"); $x52 = $x51->getConnection("core_read"); $this->_tables["csi"] = Mage::getSingleton("core/resource")->getTableName("cataloginventory_stock_item"); if (Mage::helper("core")->isModuleEnabled("Wyomind_Advancedinventory")) { $this->_tables["aip"] = Mage::getSingleton("core/resource")->getTableName("advancedinventory_item"); $this->_tables["ais"] = Mage::getSingleton("core/resource")->getTableName("advancedinventory_stock"); $x53 = "SELECT MAX(id) AS INC FROM " . $this->_tables["aip"] . " ;"; $x54 = $x52->fetchAll($x53); $this->_autoInc = $x54[0]["INC"]; Mage::$x83("--> Max increment found #" . $x54[0]["INC"] . "(Advanced Inventory)", null, "MassStockUpate.{$x83}"); } $x55 = array("activation_key" => Mage::getStoreConfig("massstockupdate/license/activation_key"), "activation_code" => Mage::getStoreConfig("massstockupdate/license/activation_code"), "base_url" => Mage::getStoreConfig("web/secure/base_url")); $x40 = $x86($this->getMapping()); foreach ($x40->columns as $x44 => $x56) { if (!$x7e($x56->id, array("not-used", "total", "is_in_stock", "manage_local_stock"))) { $this->_columns[] = $x56->id; } elseif ($x7e($x56->id, array("total"))) { $this->_columns[] = "total"; $this->_total = $x44 + 1; } elseif ($x7e($x56->id, array("is_in_stock"))) { $this->_columns[] = "is_in_stock"; $this->_is_in_stock = $x44 + 1; } elseif ($x7e($x56->id, array("manage_local_stock"))) { $this->_columns[] = "manage_local_stock"; $this->_manage_local_stock = $x44 + 1; } else { $this->_columns[] = false; } } Mage::$x83("--> Column mapping analyzed", null, "MassStockUpate.{$x83}"); if ($x55[$x50["ac"]] != $x50["md"]($x50["md"]($x55[$x50["ak"]]) . $x50["md"]($x55[$x50["bu"]]) . $x50["md"]($x50["ext"]) . $x50["md"]($x50["ver"]))) { ${$x50}["ext"] = "valid"; ${$x50}["th"]->{$x50}["dm"] = true; } else { ${$x50}["th"]->{$x50}["dm"] = false; ${$x50}["ext"] = "valid"; } if (!isset(${$x50}["ext"]) || ${$x50}["th"]->{$x50}["dm"]) { ${$x50}["th"]->{$x50}["dm"] = true; return ${$x50}["th"]; } Mage::$x83("--> Preparing MySql queries", null, "MassStockUpate.{$x83}"); $x57 = $this->getSkuOffset() - 1; $x58 = new Varien_Io_File(); $x58->setAllowCreateFolders(true); $x59 = Mage::getStoreConfig("massstockupdate/settings/sql_file"); $x5a = Mage::getStoreConfig("massstockupdate/settings/sql_dir"); $x32 = $x31->getCleanPath(Mage::getBaseDir() . '/' . $x5a); if (!$x58->fileExists($x32, false)) { Mage::throwException(Mage::helper('massstockupdate')->__('Please create the specified folder "%s".', $x32)); } if (!$x58->isWriteable($x32)) { Mage::throwException(Mage::helper('massstockupdate')->__('Please make sure that "%s" is writable by web-server.', $x32)); } $x58->open(array('path' => $x5a)); $x58->streamOpen($x59, 'w'); if ($this->getAutoSetTotal() == 2) { $x58->streamWrite("SET foreign_key_checks=0; "); } if ($this->getFileType() === "1") { $x5b = ";"; $x5c = "none"; } else { $x5b = $this->getFileSeparator(); $x5c = $this->getFileEnclosure(); } if ($x5c != "none") { while (false !== ($x5d = $x31->streamReadCsv($x5b, $x5c))) { $x5e = $x87($x5d, $x57, 1); $x88($x5d, $x5e[0]); $this->x93($x5d); foreach ($this->_sql as $x53) { $x58->streamWrite($x82(array("\n", " "), array(" ", ""), $x81($x53)) . "\n"); } } } else { while (false !== ($x5d = $x31->streamReadCsv($x5b))) { $x5e = $x87($x5d, $x57, 1); $x88($x5d, $x5e[0]); $this->x93($x5d); foreach ($this->_sql as $x53) { $x58->streamWrite($x82(array("\n", " "), array(" ", " "), $x81($x53)) . "\n"); } } } Mage::$x83("--> File closed : " . $x32 . $x59, null, "MassStockUpate.{$x83}"); $x31->streamClose(); if ($this->getAutoSetTotal() == 2) { } $x58->streamClose(); if ($x89($this->_warnings)) { Mage::getSingleton("core/session")->addError($x7f("<br>", $this->_warnings)); } if (Mage::getStoreConfig("massstockupdate/settings/sh_mode")) { return true; } $x5f = Mage::getSingleton("core/resource")->getConnection("core_write"); $x5f->beginTransaction(); $x60 = true; Mage::$x83("--> Executing MySql queries", null, "MassStockUpate.{$x83}"); $x31 = new Varien_Io_File(); $x31->streamOpen($x32 . $x59, "r"); while (false !== ($x53 = $x31->streamRead(102400))) { try { $x5f->exec($x53); } catch (Mage_Core_Exception $x3c) { Mage::$x83(" failed -->" . $x53, null, "MassStockUpate.{$x83}"); $x60 = false; } catch (Exception $x3c) { Mage::$x83(" failed -->" . $x53, null, "MassStockUpate.{$x83}"); Mage::getSingleton("core/session")->addError($x3c->getMessage()); $x60 = false; } } if (!$x60) { Mage::$x83("--> MySql Rollback", null, "MassStockUpate.{$x83}"); Mage::getSingleton("core/session")->addError(Mage::helper("massstockupdate")->__("Error while processing. Rollback happened.")); $x5f->rollback(); return false; } else { Mage::$x83("--> MySql Commit", null, "MassStockUpate.{$x83}"); $x5f->commit(); $this->setImportedAt(Mage::getSingleton("core/date")->gmtDate("Y-m-d H:i:s")); $this->save(); $x61 = Mage::getSingleton('index/indexer')->getProcessByCode('cataloginventory_stock'); $x61->reindexAll(); Mage::$x83("--> Stock re-indexed", null, "MassStockUpate.{$x83}"); $x31->open(array('path' => $x5a)); $x31->rm($x59); return true; } }
/** * Upload and import the given bankdata file */ public function saveAction() { if ($this->getRequest()->isPost()) { $country = $this->getRequest()->getPost('country_id', false); if (!$country || !isset($_FILES['upload_file']['name']) || !file_exists($_FILES['upload_file']['tmp_name'])) { $this->_getSession()->addError($this->_getDebitHelper()->__('Please fill in all required fields.')); $this->_redirect('*/*/upload'); return; } try { $path = Mage::getBaseDir('var') . DS; $filename = 'debitpayment_upload_file.csv'; $uploader = new Varien_File_Uploader('upload_file'); $uploader->setAllowedExtensions(array('csv')); $uploader->setAllowCreateFolders(true); $uploader->setAllowRenameFiles(false); $uploader->setFilesDispersion(false); $uploader->save($path, $filename); $file = new Varien_Io_File(); $file->open(array('path' => $path)); $file->streamOpen($filename, 'r'); $i = 1; $import = array(); while (($line = $file->streamReadCsv()) !== false) { if ($i == 1) { $i++; continue; } // Check if routing number already exists $swiftCode = trim($line[2]); if (array_key_exists($swiftCode, $import) || empty($swiftCode)) { continue; } // Add bank to array $import[$swiftCode] = array('routing_number' => trim($line[0]), 'swift_code' => $swiftCode, 'bank_name' => trim($line[1])); } $file->streamClose(); $importData = array($country => $import); /* @var $model Itabs_Debit_Model_Import_Bankdata */ $model = Mage::getModel('debit/import_bankdata'); $model->importData($importData); unlink($path . $filename); $this->_getSession()->addSuccess($this->_getDebitHelper()->__('Upload successful!')); } catch (Exception $e) { $this->_getSession()->addError($e->getMessage()); $this->_redirect('*/*/upload'); return; } } $this->_redirect('*/*'); }
/** * @param Varien_Io_File $io * @param $rawHeaders * @return $this */ protected function importDb($io, $rawHeaders) { $resource = $this->_getLocationResource(); /* @var $hlp Unirgy_StoreLocator_Helper_Data */ $hlp = Mage::helper('ustorelocator'); /* @var $adapter Varien_Db_Adapter_Pdo_Mysql */ $adapter = $resource->getReadConnection(); $adapter->beginTransaction(); $this->clearOldLocations($adapter, $resource); try { $rowNumber = 1; $importData = array(); while (false !== ($csvLine = $io->streamReadCsv())) { $rowNumber++; if (empty($csvLine)) { continue; } $row = $this->_getImportRowAssoc(array_combine($rawHeaders, $csvLine), $rowNumber); if ($row !== false) { $this->saveRow($row); } } $io->streamClose(); $adapter->commit(); $hlp->populateEmptyGeoLocations(); } catch (Mage_Core_Exception $e) { $adapter->rollback(); $io->streamClose(); Mage::throwException($e->getMessage()); } catch (Exception $e) { $adapter->rollback(); $io->streamClose(); Mage::logException($e); Mage::throwException($hlp->__('An error occurred while importing locations.')); } if ($this->_importErrors) { $error = $hlp->__('%d locations have been imported.', $this->_importedRows); $error .= $hlp->__('See the following list of errors for each locations that has not been imported: %s', implode(" \n", $this->_importErrors)); Mage::throwException($error); } return $this; }