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\Lists\Price; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Price list 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
|
|
|
use \Aimeos\Controller\Jobs\Common\Import\Xml\Traits; |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
/** controller/jobs/common/import/xml/processor/lists/price/name |
28
|
|
|
* Name of the lists processor implementation |
29
|
|
|
* |
30
|
|
|
* Use "Myname" if your class is named "\Aimeos\Controller\Jobs\Common\Import\Xml\Processor\Lists\Price\Myname". |
31
|
|
|
* The name is case-sensitive and you should avoid camel case names like "MyName". |
32
|
|
|
* |
33
|
|
|
* @param string Last part of the processor class name |
34
|
|
|
* @since 2019.04 |
35
|
|
|
*/ |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Updates the given item using the data from the DOM node |
40
|
|
|
* |
41
|
|
|
* @param \Aimeos\MShop\Common\Item\Iface $item Item which should be updated |
42
|
|
|
* @param \DOMNode $node XML document node containing a list of nodes to process |
43
|
|
|
* @return \Aimeos\MShop\Common\Item\Iface Updated item |
44
|
|
|
*/ |
45
|
|
|
public function process( \Aimeos\MShop\Common\Item\Iface $item, \DOMNode $node ) : \Aimeos\MShop\Common\Item\Iface |
46
|
|
|
{ |
47
|
|
|
\Aimeos\Utils::implements( $item, \Aimeos\MShop\Common\Item\ListsRef\Iface::class ); |
48
|
|
|
|
49
|
|
|
$listItems = $item->getListItems( 'price', null, null, false )->reverse(); |
50
|
|
|
$resource = $item->getResourceType(); |
51
|
|
|
$context = $this->context(); |
52
|
|
|
|
53
|
|
|
$manager = \Aimeos\MShop::create( $context, $resource ); |
54
|
|
|
$priceManager = \Aimeos\MShop::create( $context, 'price' ); |
55
|
|
|
|
56
|
|
|
foreach( $node->childNodes as $refNode ) |
57
|
|
|
{ |
58
|
|
|
if( $refNode->nodeName !== 'priceitem' ) { |
59
|
|
|
continue; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
if( ( $listItem = $listItems->pop() ) === null ) { |
63
|
|
|
$listItem = $manager->createListItem(); |
|
|
|
|
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
if( ( $refItem = $listItem->getRefItem() ) === null ) { |
67
|
|
|
$refItem = $priceManager->create(); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
$list = []; |
71
|
|
|
|
72
|
|
|
foreach( $refNode->childNodes as $tag ) |
73
|
|
|
{ |
74
|
|
|
if( in_array( $tag->nodeName, ['lists'] ) ) { |
75
|
|
|
$refItem = $this->getProcessor( $tag->nodeName )->process( $refItem, $tag ); |
76
|
|
|
} else { |
77
|
|
|
$list[$tag->nodeName] = \Aimeos\Base\Str::decode( $tag->nodeValue ); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
$refItem = $refItem->fromArray( $list ); |
82
|
|
|
|
83
|
|
|
foreach( $refNode->attributes as $attrName => $attrNode ) { |
84
|
|
|
$list[$resource . '.' . $attrName] = \Aimeos\Base\Str::decode( $attrNode->nodeValue ); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
$name = $resource . '.lists.config'; |
88
|
|
|
$list[$name] = ( isset( $list[$name] ) ? (array) json_decode( $list[$name] ) : [] ); |
89
|
|
|
$name = $resource . '.lists.type'; |
90
|
|
|
$list[$name] = ( isset( $list[$name] ) ? $list[$name] : 'default' ); |
91
|
|
|
|
92
|
|
|
$this->addType( $resource . '/lists/type', 'price', $list[$resource . '.lists.type'] ); |
93
|
|
|
|
94
|
|
|
$listItem = $listItem->fromArray( $list ); |
95
|
|
|
$item->addListItem( 'price', $listItem, $refItem ); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
return $item->deleteListItems( $listItems->toArray() ); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
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.