| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @copyright Aimeos (aimeos.org), 2019-2022 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @package Controller | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @subpackage Jobs | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | namespace Aimeos\Controller\Jobs\Supplier\Import\Xml; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * Job controller for XML supplier imports | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * @package Controller | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * @subpackage Jobs | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 19 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  | class Standard | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  | 	extends \Aimeos\Controller\Jobs\Base | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  | 	implements \Aimeos\Controller\Jobs\Iface | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  | 	/** controller/jobs/supplier/import/xml/name | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  | 	 * Class name of the used supplier suggestions scheduler controller implementation | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  | 	 * Each default job controller can be replace by an alternative imlementation. | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  | 	 * To use this implementation, you have to set the last part of the class | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  | 	 * name as configuration value so the controller factory knows which class it | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  | 	 * has to instantiate. | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  | 	 * For example, if the name of the default class is | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  | 	 *  \Aimeos\Controller\Jobs\Supplier\Import\Xml\Standard | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  | 	 * and you want to replace it with your own version named | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  | 	 *  \Aimeos\Controller\Jobs\Supplier\Import\Xml\Myxml | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  | 	 * then you have to set the this configuration option: | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  | 	 *  controller/jobs/supplier/import/xml/name = Myxml | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  | 	 * The value is the last part of your own class name and it's case sensitive, | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  | 	 * so take care that the configuration value is exactly named like the last | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  | 	 * part of the class name. | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  | 	 * The allowed characters of the class name are A-Z, a-z and 0-9. No other | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  | 	 * characters are possible! You should always start the last part of the class | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  | 	 * name with an upper case character and continue only with lower case characters | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  | 	 * or numbers. Avoid chamel case names like "MyXml"! | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  | 	 * @param string Last part of the class name | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  | 	 * @since 2019.04 | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  | 	/** controller/jobs/supplier/import/xml/decorators/excludes | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  | 	 * Excludes decorators added by the "common" option from the supplier import CSV job controller | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  | 	 * Decorators extend the functionality of a class by adding new aspects | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  | 	 * (e.g. log what is currently done), executing the methods of the underlying | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  | 	 * class only in certain conditions (e.g. only for logged in users) or | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  | 	 * modify what is returned to the caller. | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  | 	 * This option allows you to remove a decorator added via | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  | 	 * "controller/jobs/common/decorators/default" before they are wrapped | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  | 	 * around the job controller. | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  | 	 *  controller/jobs/supplier/import/xml/decorators/excludes = array( 'decorator1' ) | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  | 	 * This would remove the decorator named "decorator1" from the list of | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  | 	 * common decorators ("\Aimeos\Controller\Jobs\Common\Decorator\*") added via | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  | 	 * "controller/jobs/common/decorators/default" to the job controller. | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  | 	 * @param array List of decorator names | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  | 	 * @since 2019.04 | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  | 	 * @see controller/jobs/common/decorators/default | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  | 	 * @see controller/jobs/supplier/import/xml/decorators/global | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  | 	 * @see controller/jobs/supplier/import/xml/decorators/local | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  | 	/** controller/jobs/supplier/import/xml/decorators/global | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  | 	 * Adds a list of globally available decorators only to the supplier import CSV job controller | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  | 	 * Decorators extend the functionality of a class by adding new aspects | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  | 	 * (e.g. log what is currently done), executing the methods of the underlying | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  | 	 * class only in certain conditions (e.g. only for logged in users) or | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  | 	 * modify what is returned to the caller. | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  | 	 * This option allows you to wrap global decorators | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  | 	 * ("\Aimeos\Controller\Jobs\Common\Decorator\*") around the job controller. | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  | 	 *  controller/jobs/supplier/import/xml/decorators/global = array( 'decorator1' ) | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  | 	 * This would add the decorator named "decorator1" defined by | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  | 	 * "\Aimeos\Controller\Jobs\Common\Decorator\Decorator1" only to the job controller. | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  | 	 * @param array List of decorator names | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  | 	 * @since 2019.04 | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  | 	 * @see controller/jobs/common/decorators/default | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  | 	 * @see controller/jobs/supplier/import/xml/decorators/excludes | 
            
                                                                        
                            
            
                                    
            
            
                | 102 |  |  | 	 * @see controller/jobs/supplier/import/xml/decorators/local | 
            
                                                                        
                            
            
                                    
            
            
                | 103 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 105 |  |  | 	/** controller/jobs/supplier/import/xml/decorators/local | 
            
                                                                        
                            
            
                                    
            
            
                | 106 |  |  | 	 * Adds a list of local decorators only to the supplier import CSV job controller | 
            
                                                                        
                            
            
                                    
            
            
                | 107 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  | 	 * Decorators extend the functionality of a class by adding new aspects | 
            
                                                                        
                            
            
                                    
            
            
                | 109 |  |  | 	 * (e.g. log what is currently done), executing the methods of the underlying | 
            
                                                                        
                            
            
                                    
            
            
                | 110 |  |  | 	 * class only in certain conditions (e.g. only for logged in users) or | 
            
                                                                        
                            
            
                                    
            
            
                | 111 |  |  | 	 * modify what is returned to the caller. | 
            
                                                                        
                            
            
                                    
            
            
                | 112 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 113 |  |  | 	 * This option allows you to wrap local decorators | 
            
                                                                        
                            
            
                                    
            
            
                | 114 |  |  | 	 * ("\Aimeos\Controller\Jobs\Supplier\Import\Xml\Decorator\*") around the job | 
            
                                                                        
                            
            
                                    
            
            
                | 115 |  |  | 	 * controller. | 
            
                                                                        
                            
            
                                    
            
            
                | 116 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 117 |  |  | 	 *  controller/jobs/supplier/import/xml/decorators/local = array( 'decorator2' ) | 
            
                                                                        
                            
            
                                    
            
            
                | 118 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 119 |  |  | 	 * This would add the decorator named "decorator2" defined by | 
            
                                                                        
                            
            
                                    
            
            
                | 120 |  |  | 	 * "\Aimeos\Controller\Jobs\Supplier\Import\Xml\Decorator\Decorator2" | 
            
                                                                        
                            
            
                                    
            
            
                | 121 |  |  | 	 * only to the job controller. | 
            
                                                                        
                            
            
                                    
            
            
                | 122 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 123 |  |  | 	 * @param array List of decorator names | 
            
                                                                        
                            
            
                                    
            
            
                | 124 |  |  | 	 * @since 2019.04 | 
            
                                                                        
                            
            
                                    
            
            
                | 125 |  |  | 	 * @see controller/jobs/common/decorators/default | 
            
                                                                        
                            
            
                                    
            
            
                | 126 |  |  | 	 * @see controller/jobs/supplier/import/xml/decorators/excludes | 
            
                                                                        
                            
            
                                    
            
            
                | 127 |  |  | 	 * @see controller/jobs/supplier/import/xml/decorators/global | 
            
                                                                        
                            
            
                                    
            
            
                | 128 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 131 |  |  | 	use \Aimeos\Controller\Common\Common\Import\Traits; | 
            
                                                                        
                            
            
                                    
            
            
                | 132 |  |  | 	use \Aimeos\Controller\Common\Common\Import\Xml\Traits; | 
            
                                                                        
                            
            
                                    
            
            
                | 133 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 134 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 135 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 136 |  |  | 	 * Returns the localized name of the job. | 
            
                                                                        
                            
            
                                    
            
            
                | 137 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 138 |  |  | 	 * @return string Name of the job | 
            
                                                                        
                            
            
                                    
            
            
                | 139 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 140 |  |  | 	public function getName() : string | 
            
                                                                        
                            
            
                                    
            
            
                | 141 |  |  | 	{ | 
            
                                                                        
                            
            
                                    
            
            
                | 142 |  |  | 		return $this->context()->translate( 'controller/jobs', 'Supplier import XML' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 143 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 144 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 146 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 147 |  |  | 	 * Returns the localized description of the job. | 
            
                                                                        
                            
            
                                    
            
            
                | 148 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 149 |  |  | 	 * @return string Description of the job | 
            
                                                                        
                            
            
                                    
            
            
                | 150 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 	public function getDescription() : string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 	{ | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 153 |  |  | 		return $this->context()->translate( 'controller/jobs', 'Imports new and updates existing suppliers from XML files' ); | 
            
                                                                        
                                                                
            
                                    
            
            
                | 154 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 155 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 156 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 157 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 158 |  |  | 	 * Executes the job. | 
            
                                                                        
                            
            
                                    
            
            
                | 159 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 160 |  |  | 	 * @throws \Aimeos\Controller\Jobs\Exception If an error occurs | 
            
                                                                        
                            
            
                                    
            
            
                | 161 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 162 |  |  | 	public function run() | 
            
                                                                        
                            
            
                                    
            
            
                | 163 |  |  | 	{ | 
            
                                                                        
                            
            
                                    
            
            
                | 164 |  |  | 		$context = $this->context(); | 
            
                                                                        
                            
            
                                    
            
            
                | 165 |  |  | 		$logger = $context->logger(); | 
            
                                                                        
                            
            
                                    
            
            
                | 166 |  |  | 		$process = $context->process(); | 
            
                                                                        
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 168 |  |  | 		$location = $this->location(); | 
            
                                                                        
                            
            
                                    
            
            
                | 169 |  |  | 		$fs = $context->fs( 'fs-import' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 170 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 171 |  |  | 		if( $fs->isDir( $location ) === false ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 172 |  |  | 			return; | 
            
                                                                        
                            
            
                                    
            
            
                | 173 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 174 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 175 |  |  | 		try | 
            
                                                                        
                            
            
                                    
            
            
                | 176 |  |  | 		{ | 
            
                                                                        
                            
            
                                    
            
            
                | 177 |  |  | 			$logger->info( sprintf( 'Started supplier import from "%1$s"', $location ), 'import/xml/supplier' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 178 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 179 |  |  | 			$fcn = function( \Aimeos\MShop\ContextIface $context, string $path ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 180 |  |  | 				$this->import( $context, $path ); | 
            
                                                                        
                            
            
                                    
            
            
                | 181 |  |  | 			}; | 
            
                                                                        
                            
            
                                    
            
            
                | 182 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 183 |  |  | 			foreach( map( $fs->scan( $location ) )->sort() as $filename ) | 
            
                                                                        
                            
            
                                    
            
            
                | 184 |  |  | 			{ | 
            
                                                                        
                            
            
                                    
            
            
                | 185 |  |  | 				$path = $location . '/' . $filename; | 
            
                                                                        
                            
            
                                    
            
            
                | 186 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 187 |  |  | 				if( $fs instanceof \Aimeos\Base\Filesystem\DirIface && $fs->isDir( $path ) ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 188 |  |  | 					continue; | 
            
                                                                        
                            
            
                                    
            
            
                | 189 |  |  | 				} | 
            
                                                                        
                            
            
                                    
            
            
                | 190 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 191 |  |  | 				$process->start( $fcn, [$context, $fs->readf( $path )] ); | 
            
                                                                        
                            
            
                                    
            
            
                | 192 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 193 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 194 |  |  | 			$process->wait(); | 
            
                                                                        
                            
            
                                    
            
            
                | 195 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 196 |  |  | 			$logger->info( sprintf( 'Finished supplier import from "%1$s"', $location ), 'import/xml/supplier' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 197 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 198 |  |  | 		catch( \Exception $e ) | 
            
                                                                        
                            
            
                                    
            
            
                | 199 |  |  | 		{ | 
            
                                                                        
                            
            
                                    
            
            
                | 200 |  |  | 			$logger->error( 'Supplier import error: ' . $e->getMessage() . "\n" . $e->getTraceAsString(), 'import/xml/supplier' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 201 |  |  | 			$this->mail( 'Supplier XML import error', $e->getMessage() . "\n" . $e->getTraceAsString() ); | 
            
                                                                        
                            
            
                                    
            
            
                | 202 |  |  | 			throw $e; | 
            
                                                                        
                            
            
                                    
            
            
                | 203 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 204 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 205 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 206 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 207 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 208 |  |  | 	 * Returns the directory for storing imported files | 
            
                                                                        
                            
            
                                    
            
            
                | 209 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 210 |  |  | 	 * @return string Directory for storing imported files | 
            
                                                                        
                            
            
                                    
            
            
                | 211 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  | 	protected function backup() : string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  | 		/** controller/jobs/supplier/import/xml/backup | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  | 		 * Name of the backup for sucessfully imported files | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  | 		 * After a XML file was imported successfully, you can move it to another | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  | 		 * location, so it won't be imported again and isn't overwritten by the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  | 		 * next file that is stored at the same location in the file system. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  | 		 * You should use an absolute path to be sure but can be relative path | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  | 		 * if you absolutely know from where the job will be executed from. The | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  | 		 * name of the new backup location can contain placeholders understood | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  | 		 * by the PHP DateTime::format() method (with percent signs prefix) to | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  | 		 * create dynamic paths, e.g. "backup/%Y-%m-%d" which would create | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  | 		 * "backup/2000-01-01". For more information about the date() placeholders, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  | 		 * please have a look  into the PHP documentation of the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  | 		 * {@link https://www.php.net/manual/en/datetime.format.php format() method}. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  | 		 * **Note:** If no backup name is configured, the file or directory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  | 		 * won't be moved away. Please make also sure that the parent directory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  | 		 * and the new directory are writable so the file or directory could be | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  | 		 * moved. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  | 		 * @param integer Name of the backup file, optionally with date/time placeholders | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  | 		 * @since 2019.04 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  | 		 * @see controller/jobs/supplier/import/xml/domains | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  | 		 * @see controller/jobs/supplier/import/xml/location | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  | 		 * @see controller/jobs/supplier/import/xml/max-query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  | 		 */ | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 241 |  |  | 		return (string) $this->context()->config()->get( 'controller/jobs/supplier/import/xml/backup' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 242 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 243 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 244 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 245 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 246 |  |  | 	 * Returns the list of domain names that should be retrieved along with the attribute items | 
            
                                                                        
                            
            
                                    
            
            
                | 247 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 248 |  |  | 	 * @return array List of domain names | 
            
                                                                        
                            
            
                                    
            
            
                | 249 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 250 |  |  | 	protected function domains() : array | 
            
                                                                        
                            
            
                                    
            
            
                | 251 |  |  | 	{ | 
            
                                                                        
                            
            
                                    
            
            
                | 252 |  |  | 		/** controller/jobs/supplier/import/xml/domains | 
            
                                                                        
                            
            
                                    
            
            
                | 253 |  |  | 		 * List of item domain names that should be retrieved along with the attribute items | 
            
                                                                        
                            
            
                                    
            
            
                | 254 |  |  | 		 * | 
            
                                                                        
                            
            
                                    
            
            
                | 255 |  |  | 		 * For efficient processing, the items associated to the suppliers can be | 
            
                                                                        
                            
            
                                    
            
            
                | 256 |  |  | 		 * fetched to, minimizing the number of database queries required. To be | 
            
                                                                        
                            
            
                                    
            
            
                | 257 |  |  | 		 * most effective, the list of item domain names should be used in the | 
            
                                                                        
                            
            
                                    
            
            
                | 258 |  |  | 		 * mapping configuration too, so the retrieved items will be used during | 
            
                                                                        
                            
            
                                    
            
            
                | 259 |  |  | 		 * the import. | 
            
                                                                        
                            
            
                                    
            
            
                | 260 |  |  | 		 * | 
            
                                                                        
                            
            
                                    
            
            
                | 261 |  |  | 		 * @param array Associative list of MShop item domain names | 
            
                                                                        
                            
            
                                    
            
            
                | 262 |  |  | 		 * @since 2019.04 | 
            
                                                                        
                            
            
                                    
            
            
                | 263 |  |  | 		 * @see controller/jobs/supplier/import/xml/backup | 
            
                                                                        
                            
            
                                    
            
            
                | 264 |  |  | 		 * @see controller/jobs/supplier/import/xml/location | 
            
                                                                        
                            
            
                                    
            
            
                | 265 |  |  | 		 * @see controller/jobs/supplier/import/xml/max-query | 
            
                                                                        
                            
            
                                    
            
            
                | 266 |  |  | 		 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 267 |  |  | 		$domains = ['supplier/address', 'media', 'text']; | 
            
                                                                        
                            
            
                                    
            
            
                | 268 |  |  | 		return $this->context()->config()->get( 'controller/jobs/supplier/import/xml/domains', $domains ); | 
            
                                                                        
                            
            
                                    
            
            
                | 269 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 270 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 271 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 272 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 273 |  |  | 	 * Imports the XML file given by its path | 
            
                                                                        
                            
            
                                    
            
            
                | 274 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 275 |  |  | 	 * @param \Aimeos\MShop\ContextIface $context Context object | 
            
                                                                        
                            
            
                                    
            
            
                | 276 |  |  | 	 * @param string $filename Absolute or relative path to the XML file | 
            
                                                                        
                            
            
                                    
            
            
                | 277 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 278 |  |  | 	protected function import( \Aimeos\MShop\ContextIface $context, string $filename ) | 
            
                                                                        
                            
            
                                    
            
            
                | 279 |  |  | 	{ | 
            
                                                                        
                            
            
                                    
            
            
                | 280 |  |  | 		$slice = 0; | 
            
                                                                        
                            
            
                                    
            
            
                | 281 |  |  | 		$nodes = []; | 
            
                                                                        
                            
            
                                    
            
            
                | 282 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 283 |  |  | 		$xml = new \XMLReader(); | 
            
                                                                        
                            
            
                                    
            
            
                | 284 |  |  | 		$maxquery = $this->max(); | 
            
                                                                        
                            
            
                                    
            
            
                | 285 |  |  | 		$logger = $context->logger(); | 
            
                                                                        
                            
            
                                    
            
            
                | 286 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 287 |  |  | 		if( $xml->open( $filename, LIBXML_COMPACT | LIBXML_PARSEHUGE ) === false ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 288 |  |  | 			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No XML file "%1$s" found', $filename ) ); | 
            
                                                                        
                            
            
                                    
            
            
                | 289 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 290 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 291 |  |  | 		$logger->info( sprintf( 'Started supplier import from file "%1$s"', $filename ), 'import/xml/supplier' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 292 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 293 |  |  | 		while( $xml->read() === true ) | 
            
                                                                        
                            
            
                                    
            
            
                | 294 |  |  | 		{ | 
            
                                                                        
                            
            
                                    
            
            
                | 295 |  |  | 			if( $xml->depth === 1 && $xml->nodeType === \XMLReader::ELEMENT && $xml->name === 'supplieritem' ) | 
            
                                                                        
                            
            
                                    
            
            
                | 296 |  |  | 			{ | 
            
                                                                        
                            
            
                                    
            
            
                | 297 |  |  | 				if( ( $dom = $xml->expand() ) === false ) | 
            
                                                                        
                            
            
                                    
            
            
                | 298 |  |  | 				{ | 
            
                                                                        
                            
            
                                    
            
            
                | 299 |  |  | 					$msg = sprintf( 'Expanding "%1$s" node failed', 'supplieritem' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 300 |  |  | 					throw new \Aimeos\Controller\Jobs\Exception( $msg ); | 
            
                                                                        
                            
            
                                    
            
            
                | 301 |  |  | 				} | 
            
                                                                        
                            
            
                                    
            
            
                | 302 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 303 |  |  | 				$nodes[] = $dom; | 
            
                                                                        
                            
            
                                    
            
            
                | 304 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 305 |  |  | 				if( $slice++ >= $maxquery ) | 
            
                                                                        
                            
            
                                    
            
            
                | 306 |  |  | 				{ | 
            
                                                                        
                            
            
                                    
            
            
                | 307 |  |  | 					$this->importNodes( $nodes ); | 
            
                                                                        
                            
            
                                    
            
            
                | 308 |  |  | 					unset( $nodes ); | 
            
                                                                        
                            
            
                                    
            
            
                | 309 |  |  | 					$nodes = []; | 
            
                                                                        
                            
            
                                    
            
            
                | 310 |  |  | 					$slice = 0; | 
            
                                                                        
                            
            
                                    
            
            
                | 311 |  |  | 				} | 
            
                                                                        
                            
            
                                    
            
            
                | 312 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 313 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 314 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 315 |  |  | 		$this->importNodes( $nodes ); | 
            
                                                                        
                            
            
                                    
            
            
                | 316 |  |  | 		unset( $nodes ); | 
            
                                                                        
                            
            
                                    
            
            
                | 317 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 318 |  |  | 		$this->saveTypes(); | 
            
                                                                        
                            
            
                                    
            
            
                | 319 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 320 |  |  | 		foreach( $this->getProcessors() as $proc ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 321 |  |  | 			$proc->finish(); | 
            
                                                                        
                            
            
                                    
            
            
                | 322 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 323 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 324 |  |  | 		unlink( $filename ); | 
            
                                                                        
                            
            
                                    
            
            
                | 325 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 326 |  |  | 		$logger->info( sprintf( 'Finished supplier import from file "%1$s"', $filename ), 'import/xml/supplier' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 327 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 328 |  |  | 		if( !empty( $backup = $this->backup() ) && @rename( $filename, $backup = \Aimeos\Base\Str::strtime( $backup ) ) === false ) | 
            
                                                                        
                            
            
                                    
            
            
                | 329 |  |  | 		{ | 
            
                                                                        
                            
            
                                    
            
            
                | 330 |  |  | 			$msg = sprintf( 'Unable to move imported file "%1$s" to "%2$s"', $filename, $backup ); | 
            
                                                                        
                            
            
                                    
            
            
                | 331 |  |  | 			throw new \Aimeos\Controller\Jobs\Exception( $msg ); | 
            
                                                                        
                            
            
                                    
            
            
                | 332 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 333 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 334 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 335 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 336 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 337 |  |  | 	 * Imports the given DOM nodes | 
            
                                                                        
                            
            
                                    
            
            
                | 338 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 339 |  |  | 	 * @param \DomElement[] $nodes List of nodes to import | 
            
                                                                        
                            
            
                                    
            
            
                | 340 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 341 |  |  | 	protected function importNodes( array $nodes ) | 
            
                                                                        
                            
            
                                    
            
            
                | 342 |  |  | 	{ | 
            
                                                                        
                            
            
                                    
            
            
                | 343 |  |  | 		$codes = []; | 
            
                                                                        
                            
            
                                    
            
            
                | 344 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 345 |  |  | 		foreach( $nodes as $node ) | 
            
                                                                        
                            
            
                                    
            
            
                | 346 |  |  | 		{ | 
            
                                                                        
                            
            
                                    
            
            
                | 347 |  |  | 			if( ( $attr = $node->attributes->getNamedItem( 'ref' ) ) !== null ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 348 |  |  | 				$codes[$attr->nodeValue] = null; | 
            
                                                                        
                            
            
                                    
            
            
                | 349 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 350 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 351 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 352 |  |  | 		$manager = \Aimeos\MShop::create( $this->context(), 'supplier' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 353 |  |  | 		$search = $manager->filter()->slice( 0, count( $codes ) )->add( ['supplier.code' => array_keys( $codes )] ); | 
            
                                                                        
                            
            
                                    
            
            
                | 354 |  |  | 		$map = $manager->search( $search, $this->domains() )->col( null, 'supplier.code' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 355 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 356 |  |  | 		foreach( $nodes as $node ) | 
            
                                                                        
                            
            
                                    
            
            
                | 357 |  |  | 		{ | 
            
                                                                        
                            
            
                                    
            
            
                | 358 |  |  | 			if( ( $attr = $node->attributes->getNamedItem( 'ref' ) ) !== null && isset( $map[$attr->nodeValue] ) ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 359 |  |  | 				$item = $this->process( $map[$attr->nodeValue], $node ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 360 |  |  | 			} else { | 
            
                                                                        
                            
            
                                    
            
            
                | 361 |  |  | 				$item = $this->process( $manager->create(), $node ); | 
            
                                                                        
                            
            
                                    
            
            
                | 362 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 363 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 364 |  |  | 			$manager->save( $item ); | 
            
                                                                        
                            
            
                                    
            
            
                | 365 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 366 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 367 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 368 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 369 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 370 |  |  | 	 * Returns the path to the directory with the XML file | 
            
                                                                        
                            
            
                                    
            
            
                | 371 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 372 |  |  | 	 * @return string Path to the directory with the XML file | 
            
                                                                        
                            
            
                                    
            
            
                | 373 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 374 |  |  | 	protected function location() : string | 
            
                                                                        
                            
            
                                    
            
            
                | 375 |  |  | 	{ | 
            
                                                                        
                            
            
                                    
            
            
                | 376 |  |  | 		/** controller/jobs/supplier/import/xml/location | 
            
                                                                        
                            
            
                                    
            
            
                | 377 |  |  | 		 * File or directory where the content is stored which should be imported | 
            
                                                                        
                            
            
                                    
            
            
                | 378 |  |  | 		 * | 
            
                                                                        
                            
            
                                    
            
            
                | 379 |  |  | 		 * You need to configure the XML file or directory with the XML files that | 
            
                                                                        
                            
            
                                    
            
            
                | 380 |  |  | 		 * should be imported. It should be an absolute path to be sure but can be | 
            
                                                                        
                            
            
                                    
            
            
                | 381 |  |  | 		 * relative path if you absolutely know from where the job will be executed | 
            
                                                                        
                            
            
                                    
            
            
                | 382 |  |  | 		 * from. | 
            
                                                                        
                            
            
                                    
            
            
                | 383 |  |  | 		 * | 
            
                                                                        
                            
            
                                    
            
            
                | 384 |  |  | 		 * @param string Relative path to the XML files | 
            
                                                                        
                            
            
                                    
            
            
                | 385 |  |  | 		 * @since 2019.04 | 
            
                                                                        
                            
            
                                    
            
            
                | 386 |  |  | 		 * @see controller/jobs/supplier/import/xml/backup | 
            
                                                                        
                            
            
                                    
            
            
                | 387 |  |  | 		 * @see controller/jobs/supplier/import/xml/domains | 
            
                                                                        
                            
            
                                    
            
            
                | 388 |  |  | 		 * @see controller/jobs/supplier/import/xml/max-query | 
            
                                                                        
                            
            
                                    
            
            
                | 389 |  |  | 		 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 390 |  |  | 		return (string) $this->context()->config()->get( 'controller/jobs/supplier/import/xml/location', 'supplier' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 391 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 392 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 393 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 394 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 395 |  |  | 	 * Returns the maximum number of XML nodes processed at once | 
            
                                                                        
                            
            
                                    
            
            
                | 396 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 397 |  |  | 	 * @return int Maximum number of XML nodes | 
            
                                                                        
                            
            
                                    
            
            
                | 398 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  | 	protected function max() : int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  | 		/** controller/jobs/supplier/import/xml/max-query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  | 		 * Maximum number of XML nodes processed at once | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  | 		 * Processing and fetching several attribute items at once speeds up importing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  | 		 * the XML files. The more items can be processed at once, the faster the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  | 		 * import. More items also increases the memory usage of the importer and | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  | 		 * thus, this parameter should be low enough to avoid reaching the memory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  | 		 * limit of the PHP process. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  | 		 * @param integer Number of XML nodes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  | 		 * @since 2019.04 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | 		 * @see controller/jobs/supplier/import/xml/domains | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  | 		 * @see controller/jobs/supplier/import/xml/location | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  | 		 * @see controller/jobs/supplier/import/xml/backup | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  | 		 */ | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 416 |  |  | 		return $this->context()->config()->get( 'controller/jobs/supplier/import/xml/max-query', 100 ); | 
            
                                                                        
                                                                
            
                                    
            
            
                | 417 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 418 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 419 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 420 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 421 |  |  | 	 * Updates the supplier item and its referenced items using the given DOM node | 
            
                                                                        
                            
            
                                    
            
            
                | 422 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 423 |  |  | 	 * @param \Aimeos\MShop\Supplier\Item\Iface $item Supplier item object to update | 
            
                                                                        
                            
            
                                    
            
            
                | 424 |  |  | 	 * @param \DomElement $node DOM node used for updateding the supplier item | 
            
                                                                        
                            
            
                                    
            
            
                | 425 |  |  | 	 * @return \Aimeos\MShop\Supplier\Item\Iface $item Updated supplier item object | 
            
                                                                        
                            
            
                                    
            
            
                | 426 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  | 	protected function process( \Aimeos\MShop\Supplier\Item\Iface $item, \DomElement $node ) : \Aimeos\MShop\Supplier\Item\Iface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  | 		try | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  | 			$list = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  | 			foreach( $node->attributes as $attr ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  | 				$list[$attr->nodeName] = $attr->nodeValue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  | 			foreach( $node->childNodes as $tag ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  | 				if( in_array( $tag->nodeName, ['address', 'lists'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  | 					$item = $this->getProcessor( $tag->nodeName )->process( $item, $tag ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  | 				} elseif( $tag->nodeName[0] !== '#' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  | 					$list[$tag->nodeName] = $tag->nodeValue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  | 			$item->fromArray( $list, true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  | 		catch( \Exception $e ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  | 			$msg = 'Supplier import error: ' . $e->getMessage() . "\n" . $e->getTraceAsString(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  | 			$this->context()->logger()->error( $msg, 'import/xml/supplier' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 454 |  |  | 		return $item; | 
            
                                                                        
                                                                
            
                                    
            
            
                | 455 |  |  | 	} | 
            
                                                                        
                                                                
            
                                    
            
            
                | 456 |  |  | } | 
            
                                                                        
                                                                
            
                                    
            
            
                | 457 |  |  |  | 
            
                        
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.