_processedFilesStorage = "./var/integration/xml_products_processed/" . date("Y-m-d_H_i_s"); parent::__construct(); } public function convertProducts( $product ) { /* put standard xml-to-magento conversion here.. */ return $product; } protected function parseFile () { $this->_xmlObject = simplexml_load_file ( $this->_xmlFilename ) ; if ( !$this->_xmlObject ) throw new Exception("Could not parse " . $this->_xmlFilename); // try to find all nodes in the document matching the tag $products = $this->_xmlObject->xpath( "//" . $this->_productTag ); if ( !$this->_parsedProducts ) $this->_parsedProducts = array(); $this->_parsedProducts = array_merge ( $this->_parsedProducts, $products ); } public function readCustomNamespace ( $prefix, $object, $name ) { $tmp = $object->xpath("//".$prefix.":" . $name); return $tmp[0]; } public function getProducts( $params ) { if ( !$this->_xmlFilename ) throw new Exception("XML File is not specified."); if ( file_exists ( Mage::getBaseDir('base') . "/" . $this->_xmlFilename ) ) { $this->_xmlFilename = Mage::getBaseDir('base') . "/" . $this->_xmlFilename; } if ( is_dir ( $this->_xmlFilename ) ) { foreach ( glob ( $this->_xmlFilename . "/*" . $this->_extension ) as $filename ) { $this->_xmlFilename = $filename; $this->parseFile(); $this->_processedFiles []= $this->_xmlFilename; } } else { $this->parseFile(); $this->_processedFiles []= $this->_xmlFilename; } return $this->_parsedProducts; } }