|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2019-2025 |
|
6
|
|
|
* @package Controller |
|
7
|
|
|
* @subpackage Common |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace Aimeos\Controller\Jobs\Common\Import\Xml\Processor\Property; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Property processor for XML imports |
|
16
|
|
|
* |
|
17
|
|
|
* @package Controller |
|
18
|
|
|
* @subpackage Common |
|
19
|
|
|
*/ |
|
20
|
|
|
class Standard |
|
21
|
|
|
extends \Aimeos\Controller\Jobs\Common\Import\Xml\Processor\Base |
|
22
|
|
|
implements \Aimeos\Controller\Jobs\Common\Import\Xml\Processor\Iface |
|
23
|
|
|
{ |
|
24
|
|
|
/** controller/jobs/common/import/xml/processor/property/name |
|
25
|
|
|
* Name of the property processor implementation |
|
26
|
|
|
* |
|
27
|
|
|
* Use "Myname" if your class is named "\Aimeos\Controller\Jobs\Common\Import\Xml\Processor\Property\Myname". |
|
28
|
|
|
* The name is case-sensitive and you should avoid camel case names like "MyName". |
|
29
|
|
|
* |
|
30
|
|
|
* @param string Last part of the processor class name |
|
31
|
|
|
* @since 2019.04 |
|
32
|
|
|
*/ |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Updates the given item using the data from the DOM node |
|
37
|
|
|
* |
|
38
|
|
|
* @param \Aimeos\MShop\Common\Item\Iface $item Item which should be updated |
|
39
|
|
|
* @param \DOMNode $node XML document node containing a list of nodes to process |
|
40
|
|
|
* @return \Aimeos\MShop\Common\Item\Iface Updated item |
|
41
|
|
|
*/ |
|
42
|
|
|
public function process( \Aimeos\MShop\Common\Item\Iface $item, \DOMNode $node ) : \Aimeos\MShop\Common\Item\Iface |
|
43
|
|
|
{ |
|
44
|
|
|
\Aimeos\Utils::implements( $item, \Aimeos\MShop\Common\Item\PropertyRef\Iface::class ); |
|
45
|
|
|
|
|
46
|
|
|
$resource = $item->getResourceType(); |
|
47
|
|
|
$manager = \Aimeos\MShop::create( $this->context(), $resource ); |
|
48
|
|
|
$propItems = $item->getPropertyItems( null, false ); |
|
49
|
|
|
$map = []; |
|
50
|
|
|
|
|
51
|
|
|
foreach( $propItems as $propItem ) { |
|
52
|
|
|
$map[$propItem->getType()][$propItem->getLanguageId()][$propItem->getValue()] = $propItem->getId(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
foreach( $node->childNodes as $propNode ) |
|
56
|
|
|
{ |
|
57
|
|
|
if( $propNode->nodeName !== 'propertyitem' ) { |
|
58
|
|
|
continue; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
$list = []; |
|
62
|
|
|
|
|
63
|
|
|
foreach( $propNode->childNodes as $tagNode ) { |
|
64
|
|
|
$list[$tagNode->nodeName] = \Aimeos\Base\Str::decode( $tagNode->nodeValue ); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
$propItem = $manager->createPropertyItem()->fromArray( $list ); |
|
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
if( isset( $map[$propItem->getType()][$propItem->getLanguageId()][$propItem->getValue()] ) ) { |
|
70
|
|
|
$propItems->remove( $map[$propItem->getType()][$propItem->getLanguageId()][$propItem->getValue()] ); |
|
71
|
|
|
} else { |
|
72
|
|
|
$item->addPropertyItem( $propItem ); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
$this->addType( $resource . '/property/type', 'product', $propItem->getType() ); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
return $item->deletePropertyItems( $propItems->toArray() ); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
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.