public function __construct(ProductFromCsv $product_from_csv) { if (!array_key_exists('argv',$GLOBALS) || !array_key_exists(1, $GLOBALS['argv'])) { throw new Exception('Missing description to parse'); } if (!array_key_exists('argv',$GLOBALS) || !array_key_exists(2, $GLOBALS['argv'])) { throw new Exception('Missing brand to parse'); } if (!array_key_exists('argv',$GLOBALS) || !array_key_exists(3, $GLOBALS['argv'])) { throw new Exception('Missing procuct code'); } if (!array_key_exists('argv',$GLOBALS) || !array_key_exists(4, $GLOBALS['argv'])) { throw new Exception('Missing procuct description'); } parent::__construct($product_from_csv); $this->data['DESCRIZIONE']=$GLOBALS['argv'][1]; $this->data['MARCA']=$GLOBALS['argv'][2]; $this->data['COD.PRODOTTO']=$GLOBALS['argv'][3]; $this->data['VENDITA']='10'; $this->data['IVA']='22'; $this->data['ESISTENZA']='1'; $this->data['IMPEGNATO']='0'; $this->data['FOTO_ARTICOLO']=''; $this->data['EAN13']='8003670365679'; $this->data['LOCAZIONE_MAG']='1'; $this->data['REPARTO']='15.2'; $this->data['TESTO']=$GLOBALS['argv'][4]; }
/** * Deletes the image trought FTP */ private function deleteFtp() { $size = 0; $count = 0; $deleted = false; do { $ftp = $this->mastroProduct->getProductFromCsv()->getFtp(); if ( $this->magentoUrl != '' && is_resource($ftp) && $this->mastroProduct->getProductFromCsv()->getConfig(self::$mainImageConvert) !== false && is_file($this->magentoFileName . $this->magentoPath) ) { ftp_chdir($ftp, $this->mastroProduct->getProductFromCsv()->getConfig('FTP_BASE_DIR')); foreach ($this->imagesSubDirs as $dir) { $fileList = ftp_nlist($ftp,'.'); if (!in_array($dir, $fileList)) { ftp_mkdir($ftp,$dir); } ftp_chdir($ftp,$dir); } $fileList = ftp_nlist($ftp,'.'); if ( !in_array($this->fileName['parsedFilename'] .$this->suffix . '.jpeg', $fileList) ) { echo 'Deleted image '.$this->fileName['filename'].PHP_EOL; $deleted = ftp_delete($ftp, $this->fileName['parsedFilename'] . $this->suffix. '.jpeg', $this->magentoFileName . $this->magentoPath, FTP_BINARY); } ftp_chdir($ftp, $this->mastroProduct->getProductFromCsv()->getConfig('FTP_BASE_DIR')); foreach ($this->imagesSubDirs as $dir) { $fileList = ftp_nlist($ftp,'.'); if (!in_array($dir, $fileList)) { ftp_mkdir($ftp,$dir); } ftp_chdir($ftp,$dir); } $fileList = ftp_nlist($ftp,'.'); if ( in_array($this->fileName['parsedFilename'] .$this->suffix . '.jpeg', $fileList) ) { $size = ftp_size ($ftp,$this->fileName['parsedFilename'] . $this->suffix . '.jpeg') != filesize($this->magentoFileName . $this->magentoPath); } ftp_chdir($ftp, $this->mastroProduct->getProductFromCsv()->getConfig('FTP_BASE_DIR')); } $count++; } while ($deleted == true && $count < 10); $updated = true; if ($count >=10) { $this->mastroProduct->getProductFromCsv()->appendToLog('Error on image delete :'.$this->mastroFile); $updated = false; } return $updated; }
/** * Creates reference to PrductFromCsv * @param MastroProduct $mastroProduct */ public function __construct(MastroProduct $mastroProduct) { foreach($mastroProduct->getHeaders() as $header) self::$headers['MASTRO_'.$header]=null; $this->productFromCsv = $mastroProduct->getProductFromCsv(); }
/** * Gets a reference to the custom price handler */ public function getMagentoExcludedCsvHandler() { if (ftell($this->magentoExcludedCsvHandler) == 0) { $tempMastro = new MastroProduct($this); fwrite($this->magentoExcludedCsvHandler, "\xEF\xBB\xBF".'"EAN","reason","info",' . implode(',',$tempMastro->getHeaders()) . PHP_EOL); } return $this->magentoExcludedCsvHandler; }