@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
| 43 | 43 | * @param \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object Decorated processor |
| 44 | 44 | */ |
| 45 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 46 | - \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object = null ) |
|
| 45 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 46 | + \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object = null) |
|
| 47 | 47 | { |
| 48 | - parent::__construct( $context, $mapping, $object ); |
|
| 48 | + parent::__construct($context, $mapping, $object); |
|
| 49 | 49 | |
| 50 | 50 | /** controller/common/catalog/import/csv/processor/text/listtypes |
| 51 | 51 | * Names of the catalog list types for texts that are updated or removed |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * @see controller/common/catalog/import/csv/processor/price/listtypes |
| 67 | 67 | * @see controller/common/catalog/import/csv/processor/catalog/listtypes |
| 68 | 68 | */ |
| 69 | - $this->listTypes = $context->getConfig()->get( 'controller/common/catalog/import/csv/processor/text/listtypes' ); |
|
| 69 | + $this->listTypes = $context->getConfig()->get('controller/common/catalog/import/csv/processor/text/listtypes'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | |
@@ -77,40 +77,40 @@ discard block |
||
| 77 | 77 | * @param array $data List of CSV fields with position as key and data as value |
| 78 | 78 | * @return array List of data which hasn't been imported |
| 79 | 79 | */ |
| 80 | - public function process( \Aimeos\MShop\Catalog\Item\Iface $catalog, array $data ) |
|
| 80 | + public function process(\Aimeos\MShop\Catalog\Item\Iface $catalog, array $data) |
|
| 81 | 81 | { |
| 82 | - $listManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
| 83 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'text' ); |
|
| 82 | + $listManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
| 83 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'text'); |
|
| 84 | 84 | $manager->begin(); |
| 85 | 85 | |
| 86 | 86 | try |
| 87 | 87 | { |
| 88 | 88 | $delete = $listMap = []; |
| 89 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
| 90 | - $listItems = $catalog->getListItems( 'text', $this->listTypes ); |
|
| 89 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
| 90 | + $listItems = $catalog->getListItems('text', $this->listTypes); |
|
| 91 | 91 | |
| 92 | - foreach( $listItems as $listItem ) |
|
| 92 | + foreach ($listItems as $listItem) |
|
| 93 | 93 | { |
| 94 | - if( ( $refItem = $listItem->getRefItem() ) !== null ) { |
|
| 95 | - $listMap[ $refItem->getContent() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem; |
|
| 94 | + if (($refItem = $listItem->getRefItem()) !== null) { |
|
| 95 | + $listMap[$refItem->getContent()][$refItem->getType()][$listItem->getType()] = $listItem; |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - foreach( $map as $pos => $list ) |
|
| 99 | + foreach ($map as $pos => $list) |
|
| 100 | 100 | { |
| 101 | - if( $this->checkEntry( $list ) === false ) { |
|
| 101 | + if ($this->checkEntry($list) === false) { |
|
| 102 | 102 | continue; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - $content = trim( $list['text.content'] ); |
|
| 106 | - $type = trim( isset( $list['text.type'] ) ? $list['text.type'] : 'name' ); |
|
| 107 | - $typecode = trim( isset( $list['catalog.lists.type'] ) ? $list['catalog.lists.type'] : 'default' ); |
|
| 105 | + $content = trim($list['text.content']); |
|
| 106 | + $type = trim(isset($list['text.type']) ? $list['text.type'] : 'name'); |
|
| 107 | + $typecode = trim(isset($list['catalog.lists.type']) ? $list['catalog.lists.type'] : 'default'); |
|
| 108 | 108 | |
| 109 | - if( isset( $listMap[$content][$type][$typecode] ) ) |
|
| 109 | + if (isset($listMap[$content][$type][$typecode])) |
|
| 110 | 110 | { |
| 111 | 111 | $listItem = $listMap[$content][$type][$typecode]; |
| 112 | 112 | $refItem = $listItem->getRefItem(); |
| 113 | - unset( $listItems[ $listItem->getId() ] ); |
|
| 113 | + unset($listItems[$listItem->getId()]); |
|
| 114 | 114 | } |
| 115 | 115 | else |
| 116 | 116 | { |
@@ -118,33 +118,33 @@ discard block |
||
| 118 | 118 | $refItem = $manager->createItem(); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - $list['text.typeid'] = $this->getTypeId( 'text/type', 'catalog', $type ); |
|
| 121 | + $list['text.typeid'] = $this->getTypeId('text/type', 'catalog', $type); |
|
| 122 | 122 | $list['text.domain'] = 'catalog'; |
| 123 | 123 | |
| 124 | - $refItem->fromArray( $this->addItemDefaults( $list ) ); |
|
| 125 | - $refItem = $manager->saveItem( $refItem ); |
|
| 124 | + $refItem->fromArray($this->addItemDefaults($list)); |
|
| 125 | + $refItem = $manager->saveItem($refItem); |
|
| 126 | 126 | |
| 127 | - $list['catalog.lists.typeid'] = $this->getTypeId( 'catalog/lists/type', 'text', $typecode ); |
|
| 127 | + $list['catalog.lists.typeid'] = $this->getTypeId('catalog/lists/type', 'text', $typecode); |
|
| 128 | 128 | $list['catalog.lists.parentid'] = $catalog->getId(); |
| 129 | 129 | $list['catalog.lists.refid'] = $refItem->getId(); |
| 130 | 130 | $list['catalog.lists.domain'] = 'text'; |
| 131 | 131 | |
| 132 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos ) ); |
|
| 133 | - $listManager->saveItem( $listItem, false ); |
|
| 132 | + $listItem->fromArray($this->addListItemDefaults($list, $pos)); |
|
| 133 | + $listManager->saveItem($listItem, false); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - foreach( $listItems as $listItem ) { |
|
| 136 | + foreach ($listItems as $listItem) { |
|
| 137 | 137 | $delete[] = $listItem->getRefId(); |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - $manager->deleteItems( $delete ); |
|
| 141 | - $listManager->deleteItems( array_keys( $listItems ) ); |
|
| 140 | + $manager->deleteItems($delete); |
|
| 141 | + $listManager->deleteItems(array_keys($listItems)); |
|
| 142 | 142 | |
| 143 | - $data = $this->getObject()->process( $catalog, $data ); |
|
| 143 | + $data = $this->getObject()->process($catalog, $data); |
|
| 144 | 144 | |
| 145 | 145 | $manager->commit(); |
| 146 | 146 | } |
| 147 | - catch( \Exception $e ) |
|
| 147 | + catch (\Exception $e) |
|
| 148 | 148 | { |
| 149 | 149 | $manager->rollback(); |
| 150 | 150 | throw $e; |
@@ -160,13 +160,13 @@ discard block |
||
| 160 | 160 | * @param array $list Associative list of domain item keys and their values, e.g. "text.status" => 1 |
| 161 | 161 | * @return array Given associative list enriched by default values if they were not already set |
| 162 | 162 | */ |
| 163 | - protected function addItemDefaults( array $list ) |
|
| 163 | + protected function addItemDefaults(array $list) |
|
| 164 | 164 | { |
| 165 | - if( !isset( $list['text.label'] ) ) { |
|
| 166 | - $list['text.label'] = mb_strcut( trim( $list['text.content'] ), 0, 255 ); |
|
| 165 | + if (!isset($list['text.label'])) { |
|
| 166 | + $list['text.label'] = mb_strcut(trim($list['text.content']), 0, 255); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if( !isset( $list['text.status'] ) ) { |
|
| 169 | + if (!isset($list['text.status'])) { |
|
| 170 | 170 | $list['text.status'] = 1; |
| 171 | 171 | } |
| 172 | 172 | |
@@ -180,10 +180,10 @@ discard block |
||
| 180 | 180 | * @param array $list Associative list of key/value pairs from the mapping |
| 181 | 181 | * @return boolean True if valid, false if not |
| 182 | 182 | */ |
| 183 | - protected function checkEntry( array $list ) |
|
| 183 | + protected function checkEntry(array $list) |
|
| 184 | 184 | { |
| 185 | - if( !isset( $list['text.content'] ) || trim( $list['text.content'] ) === '' || isset( $list['catalog.lists.type'] ) |
|
| 186 | - && $this->listTypes !== null && !in_array( trim( $list['catalog.lists.type'] ), (array) $this->listTypes ) |
|
| 185 | + if (!isset($list['text.content']) || trim($list['text.content']) === '' || isset($list['catalog.lists.type']) |
|
| 186 | + && $this->listTypes !== null && !in_array(trim($list['catalog.lists.type']), (array) $this->listTypes) |
|
| 187 | 187 | ) { |
| 188 | 188 | return false; |
| 189 | 189 | } |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
| 43 | 43 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor |
| 44 | 44 | */ |
| 45 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 46 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null ) |
|
| 45 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 46 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null) |
|
| 47 | 47 | { |
| 48 | - parent::__construct( $context, $mapping, $object ); |
|
| 48 | + parent::__construct($context, $mapping, $object); |
|
| 49 | 49 | |
| 50 | 50 | /** controller/common/product/import/csv/processor/text/listtypes |
| 51 | 51 | * Names of the product list types for texts that are updated or removed |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * @see controller/common/product/import/csv/processor/price/listtypes |
| 67 | 67 | * @see controller/common/product/import/csv/processor/product/listtypes |
| 68 | 68 | */ |
| 69 | - $this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/text/listtypes' ); |
|
| 69 | + $this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/text/listtypes'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | |
@@ -77,40 +77,40 @@ discard block |
||
| 77 | 77 | * @param array $data List of CSV fields with position as key and data as value |
| 78 | 78 | * @return array List of data which hasn't been imported |
| 79 | 79 | */ |
| 80 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
| 80 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
| 81 | 81 | { |
| 82 | - $listManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' ); |
|
| 83 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'text' ); |
|
| 82 | + $listManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists'); |
|
| 83 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'text'); |
|
| 84 | 84 | $manager->begin(); |
| 85 | 85 | |
| 86 | 86 | try |
| 87 | 87 | { |
| 88 | 88 | $delete = $listMap = []; |
| 89 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
| 90 | - $listItems = $product->getListItems( 'text', $this->listTypes ); |
|
| 89 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
| 90 | + $listItems = $product->getListItems('text', $this->listTypes); |
|
| 91 | 91 | |
| 92 | - foreach( $listItems as $listItem ) |
|
| 92 | + foreach ($listItems as $listItem) |
|
| 93 | 93 | { |
| 94 | - if( ( $refItem = $listItem->getRefItem() ) !== null ) { |
|
| 95 | - $listMap[ $refItem->getContent() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem; |
|
| 94 | + if (($refItem = $listItem->getRefItem()) !== null) { |
|
| 95 | + $listMap[$refItem->getContent()][$refItem->getType()][$listItem->getType()] = $listItem; |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - foreach( $map as $pos => $list ) |
|
| 99 | + foreach ($map as $pos => $list) |
|
| 100 | 100 | { |
| 101 | - if( $this->checkEntry( $list ) === false ) { |
|
| 101 | + if ($this->checkEntry($list) === false) { |
|
| 102 | 102 | continue; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - $content = trim( $list['text.content'] ); |
|
| 106 | - $type = trim( isset( $list['text.type'] ) ? $list['text.type'] : 'name' ); |
|
| 107 | - $typecode = trim( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' ); |
|
| 105 | + $content = trim($list['text.content']); |
|
| 106 | + $type = trim(isset($list['text.type']) ? $list['text.type'] : 'name'); |
|
| 107 | + $typecode = trim(isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default'); |
|
| 108 | 108 | |
| 109 | - if( isset( $listMap[$content][$type][$typecode] ) ) |
|
| 109 | + if (isset($listMap[$content][$type][$typecode])) |
|
| 110 | 110 | { |
| 111 | 111 | $listItem = $listMap[$content][$type][$typecode]; |
| 112 | 112 | $refItem = $listItem->getRefItem(); |
| 113 | - unset( $listItems[ $listItem->getId() ] ); |
|
| 113 | + unset($listItems[$listItem->getId()]); |
|
| 114 | 114 | } |
| 115 | 115 | else |
| 116 | 116 | { |
@@ -118,33 +118,33 @@ discard block |
||
| 118 | 118 | $refItem = $manager->createItem(); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - $list['text.typeid'] = $this->getTypeId( 'text/type', 'product', $type ); |
|
| 121 | + $list['text.typeid'] = $this->getTypeId('text/type', 'product', $type); |
|
| 122 | 122 | $list['text.domain'] = 'product'; |
| 123 | 123 | |
| 124 | - $refItem->fromArray( $this->addItemDefaults( $list ) ); |
|
| 125 | - $refItem = $manager->saveItem( $refItem ); |
|
| 124 | + $refItem->fromArray($this->addItemDefaults($list)); |
|
| 125 | + $refItem = $manager->saveItem($refItem); |
|
| 126 | 126 | |
| 127 | - $list['product.lists.typeid'] = $this->getTypeId( 'product/lists/type', 'text', $typecode ); |
|
| 127 | + $list['product.lists.typeid'] = $this->getTypeId('product/lists/type', 'text', $typecode); |
|
| 128 | 128 | $list['product.lists.parentid'] = $product->getId(); |
| 129 | 129 | $list['product.lists.refid'] = $refItem->getId(); |
| 130 | 130 | $list['product.lists.domain'] = 'text'; |
| 131 | 131 | |
| 132 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos ) ); |
|
| 133 | - $listManager->saveItem( $listItem, false ); |
|
| 132 | + $listItem->fromArray($this->addListItemDefaults($list, $pos)); |
|
| 133 | + $listManager->saveItem($listItem, false); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - foreach( $listItems as $listItem ) { |
|
| 136 | + foreach ($listItems as $listItem) { |
|
| 137 | 137 | $delete[] = $listItem->getRefId(); |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - $manager->deleteItems( $delete ); |
|
| 141 | - $listManager->deleteItems( array_keys( $listItems ) ); |
|
| 140 | + $manager->deleteItems($delete); |
|
| 141 | + $listManager->deleteItems(array_keys($listItems)); |
|
| 142 | 142 | |
| 143 | - $data = $this->getObject()->process( $product, $data ); |
|
| 143 | + $data = $this->getObject()->process($product, $data); |
|
| 144 | 144 | |
| 145 | 145 | $manager->commit(); |
| 146 | 146 | } |
| 147 | - catch( \Exception $e ) |
|
| 147 | + catch (\Exception $e) |
|
| 148 | 148 | { |
| 149 | 149 | $manager->rollback(); |
| 150 | 150 | throw $e; |
@@ -160,13 +160,13 @@ discard block |
||
| 160 | 160 | * @param array $list Associative list of domain item keys and their values, e.g. "text.status" => 1 |
| 161 | 161 | * @return array Given associative list enriched by default values if they were not already set |
| 162 | 162 | */ |
| 163 | - protected function addItemDefaults( array $list ) |
|
| 163 | + protected function addItemDefaults(array $list) |
|
| 164 | 164 | { |
| 165 | - if( !isset( $list['text.label'] ) ) { |
|
| 166 | - $list['text.label'] = mb_strcut( trim( $list['text.content'] ), 0, 255 ); |
|
| 165 | + if (!isset($list['text.label'])) { |
|
| 166 | + $list['text.label'] = mb_strcut(trim($list['text.content']), 0, 255); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if( !isset( $list['text.status'] ) ) { |
|
| 169 | + if (!isset($list['text.status'])) { |
|
| 170 | 170 | $list['text.status'] = 1; |
| 171 | 171 | } |
| 172 | 172 | |
@@ -180,10 +180,10 @@ discard block |
||
| 180 | 180 | * @param array $list Associative list of key/value pairs from the mapping |
| 181 | 181 | * @return boolean True if valid, false if not |
| 182 | 182 | */ |
| 183 | - protected function checkEntry( array $list ) |
|
| 183 | + protected function checkEntry(array $list) |
|
| 184 | 184 | { |
| 185 | - if( !isset( $list['text.content'] ) || trim( $list['text.content'] ) === '' || isset( $list['product.lists.type'] ) |
|
| 186 | - && $this->listTypes !== null && !in_array( trim( $list['product.lists.type'] ), (array) $this->listTypes ) |
|
| 185 | + if (!isset($list['text.content']) || trim($list['text.content']) === '' || isset($list['product.lists.type']) |
|
| 186 | + && $this->listTypes !== null && !in_array(trim($list['product.lists.type']), (array) $this->listTypes) |
|
| 187 | 187 | ) { |
| 188 | 188 | return false; |
| 189 | 189 | } |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
| 43 | 43 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor |
| 44 | 44 | */ |
| 45 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 46 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null ) |
|
| 45 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 46 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null) |
|
| 47 | 47 | { |
| 48 | - parent::__construct( $context, $mapping, $object ); |
|
| 48 | + parent::__construct($context, $mapping, $object); |
|
| 49 | 49 | |
| 50 | 50 | /** controller/common/product/import/csv/processor/price/listtypes |
| 51 | 51 | * Names of the product list types for prices that are updated or removed |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * @see controller/common/product/import/csv/processor/product/listtypes |
| 67 | 67 | * @see controller/common/product/import/csv/processor/text/listtypes |
| 68 | 68 | */ |
| 69 | - $this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/price/listtypes' ); |
|
| 69 | + $this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/price/listtypes'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | |
@@ -77,40 +77,40 @@ discard block |
||
| 77 | 77 | * @param array $data List of CSV fields with position as key and data as value |
| 78 | 78 | * @return array List of data which hasn't been imported |
| 79 | 79 | */ |
| 80 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
| 80 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
| 81 | 81 | { |
| 82 | - $listManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' ); |
|
| 83 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'price' ); |
|
| 82 | + $listManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists'); |
|
| 83 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'price'); |
|
| 84 | 84 | $manager->begin(); |
| 85 | 85 | |
| 86 | 86 | try |
| 87 | 87 | { |
| 88 | 88 | $delete = $listMap = []; |
| 89 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
| 90 | - $listItems = $product->getListItems( 'price', $this->listTypes ); |
|
| 89 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
| 90 | + $listItems = $product->getListItems('price', $this->listTypes); |
|
| 91 | 91 | |
| 92 | - foreach( $listItems as $listItem ) |
|
| 92 | + foreach ($listItems as $listItem) |
|
| 93 | 93 | { |
| 94 | - if( ( $refItem = $listItem->getRefItem() ) !== null ) { |
|
| 95 | - $listMap[ $refItem->getValue() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem; |
|
| 94 | + if (($refItem = $listItem->getRefItem()) !== null) { |
|
| 95 | + $listMap[$refItem->getValue()][$refItem->getType()][$listItem->getType()] = $listItem; |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - foreach( $map as $pos => $list ) |
|
| 99 | + foreach ($map as $pos => $list) |
|
| 100 | 100 | { |
| 101 | - if( $this->checkEntry( $list ) === false ) { |
|
| 101 | + if ($this->checkEntry($list) === false) { |
|
| 102 | 102 | continue; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - $value = trim( isset( $list['price.value'] ) ? $list['price.value'] : '0.00' ); |
|
| 106 | - $type = trim( isset( $list['price.type'] ) ? $list['price.type'] : 'default' ); |
|
| 107 | - $typecode = trim( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' ); |
|
| 105 | + $value = trim(isset($list['price.value']) ? $list['price.value'] : '0.00'); |
|
| 106 | + $type = trim(isset($list['price.type']) ? $list['price.type'] : 'default'); |
|
| 107 | + $typecode = trim(isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default'); |
|
| 108 | 108 | |
| 109 | - if( isset( $listMap[$value][$type][$typecode] ) ) |
|
| 109 | + if (isset($listMap[$value][$type][$typecode])) |
|
| 110 | 110 | { |
| 111 | 111 | $listItem = $listMap[$value][$type][$typecode]; |
| 112 | 112 | $refItem = $listItem->getRefItem(); |
| 113 | - unset( $listItems[ $listItem->getId() ] ); |
|
| 113 | + unset($listItems[$listItem->getId()]); |
|
| 114 | 114 | } |
| 115 | 115 | else |
| 116 | 116 | { |
@@ -118,33 +118,33 @@ discard block |
||
| 118 | 118 | $refItem = $manager->createItem(); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - $list['price.typeid'] = $this->getTypeId( 'price/type', 'product', $type ); |
|
| 121 | + $list['price.typeid'] = $this->getTypeId('price/type', 'product', $type); |
|
| 122 | 122 | $list['price.domain'] = 'product'; |
| 123 | 123 | |
| 124 | - $refItem->fromArray( $this->addItemDefaults( $list ) ); |
|
| 125 | - $refItem = $manager->saveItem( $refItem ); |
|
| 124 | + $refItem->fromArray($this->addItemDefaults($list)); |
|
| 125 | + $refItem = $manager->saveItem($refItem); |
|
| 126 | 126 | |
| 127 | - $list['product.lists.typeid'] = $this->getTypeId( 'product/lists/type', 'price', $typecode ); |
|
| 127 | + $list['product.lists.typeid'] = $this->getTypeId('product/lists/type', 'price', $typecode); |
|
| 128 | 128 | $list['product.lists.parentid'] = $product->getId(); |
| 129 | 129 | $list['product.lists.refid'] = $refItem->getId(); |
| 130 | 130 | $list['product.lists.domain'] = 'price'; |
| 131 | 131 | |
| 132 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos ) ); |
|
| 133 | - $listManager->saveItem( $listItem, false ); |
|
| 132 | + $listItem->fromArray($this->addListItemDefaults($list, $pos)); |
|
| 133 | + $listManager->saveItem($listItem, false); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - foreach( $listItems as $listItem ) { |
|
| 136 | + foreach ($listItems as $listItem) { |
|
| 137 | 137 | $delete[] = $listItem->getRefId(); |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - $manager->deleteItems( $delete ); |
|
| 141 | - $listManager->deleteItems( array_keys( $listItems ) ); |
|
| 140 | + $manager->deleteItems($delete); |
|
| 141 | + $listManager->deleteItems(array_keys($listItems)); |
|
| 142 | 142 | |
| 143 | - $data = $this->getObject()->process( $product, $data ); |
|
| 143 | + $data = $this->getObject()->process($product, $data); |
|
| 144 | 144 | |
| 145 | 145 | $manager->commit(); |
| 146 | 146 | } |
| 147 | - catch( \Exception $e ) |
|
| 147 | + catch (\Exception $e) |
|
| 148 | 148 | { |
| 149 | 149 | $manager->rollback(); |
| 150 | 150 | throw $e; |
@@ -160,13 +160,13 @@ discard block |
||
| 160 | 160 | * @param array $list Associative list of domain item keys and their values, e.g. "price.status" => 1 |
| 161 | 161 | * @return array Given associative list enriched by default values if they were not already set |
| 162 | 162 | */ |
| 163 | - protected function addItemDefaults( array $list ) |
|
| 163 | + protected function addItemDefaults(array $list) |
|
| 164 | 164 | { |
| 165 | - if( !isset( $list['price.label'] ) ) { |
|
| 165 | + if (!isset($list['price.label'])) { |
|
| 166 | 166 | $list['price.label'] = $list['price.currencyid'] . ' ' . $list['price.value']; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if( !isset( $list['price.status'] ) ) { |
|
| 169 | + if (!isset($list['price.status'])) { |
|
| 170 | 170 | $list['price.status'] = 1; |
| 171 | 171 | } |
| 172 | 172 | |
@@ -180,10 +180,10 @@ discard block |
||
| 180 | 180 | * @param array $list Associative list of key/value pairs from the mapping |
| 181 | 181 | * @return boolean True if valid, false if not |
| 182 | 182 | */ |
| 183 | - protected function checkEntry( array $list ) |
|
| 183 | + protected function checkEntry(array $list) |
|
| 184 | 184 | { |
| 185 | - if( !isset( $list['price.value'] ) || trim( $list['price.value'] ) === '' || isset( $list['product.lists.type'] ) |
|
| 186 | - && $this->listTypes !== null && !in_array( trim( $list['product.lists.type'] ), (array) $this->listTypes ) |
|
| 185 | + if (!isset($list['price.value']) || trim($list['price.value']) === '' || isset($list['product.lists.type']) |
|
| 186 | + && $this->listTypes !== null && !in_array(trim($list['product.lists.type']), (array) $this->listTypes) |
|
| 187 | 187 | ) { |
| 188 | 188 | return false; |
| 189 | 189 | } |