@@ -43,10 +43,10 @@ discard block |
||
| 43 | 43 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
| 44 | 44 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor |
| 45 | 45 | */ |
| 46 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 47 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null ) |
|
| 46 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 47 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null) |
|
| 48 | 48 | { |
| 49 | - parent::__construct( $context, $mapping, $object ); |
|
| 49 | + parent::__construct($context, $mapping, $object); |
|
| 50 | 50 | |
| 51 | 51 | /** controller/common/product/import/csv/processor/product/listtypes |
| 52 | 52 | * Names of the product list types that are updated or removed |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | * @see controller/common/product/import/csv/processor/price/listtypes |
| 74 | 74 | * @see controller/common/product/import/csv/processor/text/listtypes |
| 75 | 75 | */ |
| 76 | - $default = array( 'default', 'suggestion' ); |
|
| 76 | + $default = array('default', 'suggestion'); |
|
| 77 | 77 | $key = 'controller/common/product/import/csv/processor/product/listtypes'; |
| 78 | - $this->listTypes = $context->getConfig()->get( $key, $default ); |
|
| 78 | + $this->listTypes = $context->getConfig()->get($key, $default); |
|
| 79 | 79 | |
| 80 | - $this->cache = $this->getCache( 'product' ); |
|
| 80 | + $this->cache = $this->getCache('product'); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | |
@@ -88,13 +88,13 @@ discard block |
||
| 88 | 88 | * @param array $data List of CSV fields with position as key and data as value |
| 89 | 89 | * @return array List of data which hasn't been imported |
| 90 | 90 | */ |
| 91 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
| 91 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
| 92 | 92 | { |
| 93 | 93 | $context = $this->getContext(); |
| 94 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
| 95 | - $separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" ); |
|
| 94 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
| 95 | + $separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n"); |
|
| 96 | 96 | |
| 97 | - $this->cache->set( $product ); |
|
| 97 | + $this->cache->set($product); |
|
| 98 | 98 | |
| 99 | 99 | $manager->begin(); |
| 100 | 100 | |
@@ -102,39 +102,39 @@ discard block |
||
| 102 | 102 | { |
| 103 | 103 | $types = array(); |
| 104 | 104 | |
| 105 | - foreach( $this->getMappedChunk( $data ) as $list ) |
|
| 105 | + foreach ($this->getMappedChunk($data) as $list) |
|
| 106 | 106 | { |
| 107 | - if( !isset( $list['product.code'] ) || $list['product.code'] === '' || isset( $list['product.lists.type'] ) |
|
| 108 | - && $this->listTypes !== null && !in_array( $list['product.lists.type'], (array) $this->listTypes ) |
|
| 107 | + if (!isset($list['product.code']) || $list['product.code'] === '' || isset($list['product.lists.type']) |
|
| 108 | + && $this->listTypes !== null && !in_array($list['product.lists.type'], (array) $this->listTypes) |
|
| 109 | 109 | ) { |
| 110 | 110 | continue; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | $listMap = array(); |
| 114 | - $type = ( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' ); |
|
| 114 | + $type = (isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default'); |
|
| 115 | 115 | $types[] = $type; |
| 116 | 116 | |
| 117 | - foreach( explode( $separator, $list['product.code'] ) as $code ) |
|
| 117 | + foreach (explode($separator, $list['product.code']) as $code) |
|
| 118 | 118 | { |
| 119 | - if( ( $prodid = $this->cache->get( $code ) ) === null ) |
|
| 119 | + if (($prodid = $this->cache->get($code)) === null) |
|
| 120 | 120 | { |
| 121 | 121 | $msg = 'No product for code "%1$s" available when importing product with code "%2$s"'; |
| 122 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( $msg, $code, $product->getCode() ) ); |
|
| 122 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf($msg, $code, $product->getCode())); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $listMap[$prodid] = $list; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $manager->updateListItems( $product, $listMap, 'product', $type ); |
|
| 128 | + $manager->updateListItems($product, $listMap, 'product', $type); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - $this->deleteListItems( $product->getId(), $types ); |
|
| 131 | + $this->deleteListItems($product->getId(), $types); |
|
| 132 | 132 | |
| 133 | - $remaining = $this->getObject()->process( $product, $data ); |
|
| 133 | + $remaining = $this->getObject()->process($product, $data); |
|
| 134 | 134 | |
| 135 | 135 | $manager->commit(); |
| 136 | 136 | } |
| 137 | - catch( \Exception $e ) |
|
| 137 | + catch (\Exception $e) |
|
| 138 | 138 | { |
| 139 | 139 | $manager->rollback(); |
| 140 | 140 | throw $e; |
@@ -150,19 +150,19 @@ discard block |
||
| 150 | 150 | * @param string $prodId Unique product ID |
| 151 | 151 | * @param array $types List of types that have been updated |
| 152 | 152 | */ |
| 153 | - protected function deleteListItems( $prodId, array $types ) |
|
| 153 | + protected function deleteListItems($prodId, array $types) |
|
| 154 | 154 | { |
| 155 | - $codes = array_diff( $this->listTypes, $types ); |
|
| 156 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' ); |
|
| 155 | + $codes = array_diff($this->listTypes, $types); |
|
| 156 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists'); |
|
| 157 | 157 | |
| 158 | 158 | $search = $manager->createSearch(); |
| 159 | 159 | $expr = array( |
| 160 | - $search->compare( '==', 'product.lists.parentid', $prodId ), |
|
| 161 | - $search->compare( '==', 'product.lists.domain', 'product' ), |
|
| 162 | - $search->compare( '==', 'product.lists.type.code', $codes ), |
|
| 160 | + $search->compare('==', 'product.lists.parentid', $prodId), |
|
| 161 | + $search->compare('==', 'product.lists.domain', 'product'), |
|
| 162 | + $search->compare('==', 'product.lists.type.code', $codes), |
|
| 163 | 163 | ); |
| 164 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 164 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 165 | 165 | |
| 166 | - $manager->deleteItems( array_keys( $manager->searchItems( $search ) ) ); |
|
| 166 | + $manager->deleteItems(array_keys($manager->searchItems($search))); |
|
| 167 | 167 | } |
| 168 | 168 | } |
@@ -129,8 +129,7 @@ |
||
| 129 | 129 | $remaining = $this->getObject()->process( $product, $data ); |
| 130 | 130 | |
| 131 | 131 | $manager->commit(); |
| 132 | - } |
|
| 133 | - catch( \Exception $e ) |
|
| 132 | + } catch( \Exception $e ) |
|
| 134 | 133 | { |
| 135 | 134 | $manager->rollback(); |
| 136 | 135 | throw $e; |
@@ -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,60 +77,60 @@ 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 | - $listItems = $product->getListItems( 'text' ); |
|
| 89 | - $map = $this->getMappedChunk( $data ); |
|
| 88 | + $listItems = $product->getListItems('text'); |
|
| 89 | + $map = $this->getMappedChunk($data); |
|
| 90 | 90 | |
| 91 | - foreach( $map as $pos => $list ) |
|
| 91 | + foreach ($map as $pos => $list) |
|
| 92 | 92 | { |
| 93 | - if( !isset( $list['text.content'] ) || $list['text.content'] === '' || isset( $list['product.lists.type'] ) |
|
| 94 | - && $this->listTypes !== null && !in_array( $list['product.lists.type'], (array) $this->listTypes ) |
|
| 93 | + if (!isset($list['text.content']) || $list['text.content'] === '' || isset($list['product.lists.type']) |
|
| 94 | + && $this->listTypes !== null && !in_array($list['product.lists.type'], (array) $this->listTypes) |
|
| 95 | 95 | ) { |
| 96 | 96 | continue; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if( ( $listItem = array_shift( $listItems ) ) !== null ) { |
|
| 99 | + if (($listItem = array_shift($listItems)) !== null) { |
|
| 100 | 100 | $refItem = $listItem->getRefItem(); |
| 101 | 101 | } else { |
| 102 | 102 | $listItem = $listManager->createItem(); |
| 103 | 103 | $refItem = $manager->createItem(); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - $typecode = ( isset( $list['text.type'] ) ? $list['text.type'] : 'name' ); |
|
| 107 | - $list['text.typeid'] = $this->getTypeId( 'text/type', 'product', $typecode ); |
|
| 106 | + $typecode = (isset($list['text.type']) ? $list['text.type'] : 'name'); |
|
| 107 | + $list['text.typeid'] = $this->getTypeId('text/type', 'product', $typecode); |
|
| 108 | 108 | $list['text.domain'] = 'product'; |
| 109 | 109 | |
| 110 | - $refItem->fromArray( $this->addItemDefaults( $list ) ); |
|
| 111 | - $manager->saveItem( $refItem ); |
|
| 110 | + $refItem->fromArray($this->addItemDefaults($list)); |
|
| 111 | + $manager->saveItem($refItem); |
|
| 112 | 112 | |
| 113 | - $typecode = ( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' ); |
|
| 114 | - $list['product.lists.typeid'] = $this->getTypeId( 'product/lists/type', 'text', $typecode ); |
|
| 113 | + $typecode = (isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default'); |
|
| 114 | + $list['product.lists.typeid'] = $this->getTypeId('product/lists/type', 'text', $typecode); |
|
| 115 | 115 | $list['product.lists.parentid'] = $product->getId(); |
| 116 | 116 | $list['product.lists.refid'] = $refItem->getId(); |
| 117 | 117 | $list['product.lists.domain'] = 'text'; |
| 118 | 118 | |
| 119 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos ) ); |
|
| 120 | - $listManager->saveItem( $listItem ); |
|
| 119 | + $listItem->fromArray($this->addListItemDefaults($list, $pos)); |
|
| 120 | + $listManager->saveItem($listItem); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - foreach( $listItems as $listItem ) |
|
| 123 | + foreach ($listItems as $listItem) |
|
| 124 | 124 | { |
| 125 | - $manager->deleteItem( $listItem->getRefItem()->getId() ); |
|
| 126 | - $listManager->deleteItem( $listItem->getId() ); |
|
| 125 | + $manager->deleteItem($listItem->getRefItem()->getId()); |
|
| 126 | + $listManager->deleteItem($listItem->getId()); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - $remaining = $this->getObject()->process( $product, $data ); |
|
| 129 | + $remaining = $this->getObject()->process($product, $data); |
|
| 130 | 130 | |
| 131 | 131 | $manager->commit(); |
| 132 | 132 | } |
| 133 | - catch( \Exception $e ) |
|
| 133 | + catch (\Exception $e) |
|
| 134 | 134 | { |
| 135 | 135 | $manager->rollback(); |
| 136 | 136 | throw $e; |
@@ -146,17 +146,17 @@ discard block |
||
| 146 | 146 | * @param array $list Associative list of domain item keys and their values, e.g. "text.status" => 1 |
| 147 | 147 | * @return array Given associative list enriched by default values if they were not already set |
| 148 | 148 | */ |
| 149 | - protected function addItemDefaults( array $list ) |
|
| 149 | + protected function addItemDefaults(array $list) |
|
| 150 | 150 | { |
| 151 | - if( !isset( $list['text.label'] ) ) { |
|
| 152 | - $list['text.label'] = mb_strcut( $list['text.content'], 0, 255 ); |
|
| 151 | + if (!isset($list['text.label'])) { |
|
| 152 | + $list['text.label'] = mb_strcut($list['text.content'], 0, 255); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - if( !isset( $list['text.languageid'] ) ) { |
|
| 155 | + if (!isset($list['text.languageid'])) { |
|
| 156 | 156 | $list['text.languageid'] = $this->getContext()->getLocale()->getLanguageId(); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if( !isset( $list['text.status'] ) ) { |
|
| 159 | + if (!isset($list['text.status'])) { |
|
| 160 | 160 | $list['text.status'] = 1; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -129,8 +129,7 @@ |
||
| 129 | 129 | $remaining = $this->getObject()->process( $product, $data ); |
| 130 | 130 | |
| 131 | 131 | $manager->commit(); |
| 132 | - } |
|
| 133 | - catch( \Exception $e ) |
|
| 132 | + } catch( \Exception $e ) |
|
| 134 | 133 | { |
| 135 | 134 | $manager->rollback(); |
| 136 | 135 | throw $e; |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
| 34 | 34 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor |
| 35 | 35 | */ |
| 36 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 37 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null ) |
|
| 36 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 37 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null) |
|
| 38 | 38 | { |
| 39 | 39 | $this->context = $context; |
| 40 | 40 | $this->mapping = $mapping; |
@@ -49,13 +49,13 @@ discard block |
||
| 49 | 49 | * @param integer $pos Computed position of the list item in the associated list of items |
| 50 | 50 | * @return array Given associative list enriched by default values if they were not already set |
| 51 | 51 | */ |
| 52 | - protected function addListItemDefaults( array $list, $pos ) |
|
| 52 | + protected function addListItemDefaults(array $list, $pos) |
|
| 53 | 53 | { |
| 54 | - if( !isset( $list['product.lists.position'] ) ) { |
|
| 54 | + if (!isset($list['product.lists.position'])) { |
|
| 55 | 55 | $list['product.lists.position'] = $pos; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if( !isset( $list['product.lists.status'] ) ) { |
|
| 58 | + if (!isset($list['product.lists.status'])) { |
|
| 59 | 59 | $list['product.lists.status'] = 1; |
| 60 | 60 | } |
| 61 | 61 | |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | protected function getObject() |
| 95 | 95 | { |
| 96 | - if( $this->object === null ) { |
|
| 97 | - throw new \Aimeos\Controller\Jobs\Exception( 'No processor object available' ); |
|
| 96 | + if ($this->object === null) { |
|
| 97 | + throw new \Aimeos\Controller\Jobs\Exception('No processor object available'); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | return $this->object; |
@@ -107,21 +107,21 @@ discard block |
||
| 107 | 107 | * @param array $data List of CSV fields with position as key and domain item key as value |
| 108 | 108 | * @return array List of associative arrays containing the chunked properties |
| 109 | 109 | */ |
| 110 | - protected function getMappedChunk( array &$data ) |
|
| 110 | + protected function getMappedChunk(array &$data) |
|
| 111 | 111 | { |
| 112 | 112 | $idx = 0; |
| 113 | 113 | $map = array(); |
| 114 | 114 | |
| 115 | - foreach( $this->getMapping() as $pos => $key ) |
|
| 115 | + foreach ($this->getMapping() as $pos => $key) |
|
| 116 | 116 | { |
| 117 | - if( isset( $map[$idx][$key] ) ) { |
|
| 117 | + if (isset($map[$idx][$key])) { |
|
| 118 | 118 | $idx++; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - if( isset( $data[$pos] ) ) |
|
| 121 | + if (isset($data[$pos])) |
|
| 122 | 122 | { |
| 123 | 123 | $map[$idx][$key] = $data[$pos]; |
| 124 | - unset( $data[$pos] ); |
|
| 124 | + unset($data[$pos]); |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
| 42 | 42 | */ |
| 43 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 43 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 44 | 44 | { |
| 45 | - parent::__construct( $context ); |
|
| 45 | + parent::__construct($context); |
|
| 46 | 46 | |
| 47 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'attribute' ); |
|
| 48 | - $result = $manager->searchItems( $manager->createSearch() ); |
|
| 47 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'attribute'); |
|
| 48 | + $result = $manager->searchItems($manager->createSearch()); |
|
| 49 | 49 | |
| 50 | - foreach( $result as $id => $item ) { |
|
| 51 | - $this->attributes[ $item->getCode() ][ $item->getType() ] = $item; |
|
| 50 | + foreach ($result as $id => $item) { |
|
| 51 | + $this->attributes[$item->getCode()][$item->getType()] = $item; |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
@@ -60,24 +60,24 @@ discard block |
||
| 60 | 60 | * @param string|null $type Attribute type |
| 61 | 61 | * @return \Aimeos\MShop\Attribute\Item\Iface|null Attribute object or null if not found |
| 62 | 62 | */ |
| 63 | - public function get( $code, $type = null ) |
|
| 63 | + public function get($code, $type = null) |
|
| 64 | 64 | { |
| 65 | - if( isset( $this->attributes[$code] ) && isset( $this->attributes[$code][$type] ) ) { |
|
| 65 | + if (isset($this->attributes[$code]) && isset($this->attributes[$code][$type])) { |
|
| 66 | 66 | return $this->attributes[$code][$type]; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
| 69 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
| 70 | 70 | |
| 71 | 71 | $search = $manager->createSearch(); |
| 72 | 72 | $expr = array( |
| 73 | - $search->compare( '==', 'attribute.code', $code ), |
|
| 74 | - $search->compare( '==', 'attribute.type.code', $type ), |
|
| 73 | + $search->compare('==', 'attribute.code', $code), |
|
| 74 | + $search->compare('==', 'attribute.type.code', $type), |
|
| 75 | 75 | ); |
| 76 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 76 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 77 | 77 | |
| 78 | - $result = $manager->searchItems( $search ); |
|
| 78 | + $result = $manager->searchItems($search); |
|
| 79 | 79 | |
| 80 | - if( ( $item = reset( $result ) ) !== false ) |
|
| 80 | + if (($item = reset($result)) !== false) |
|
| 81 | 81 | { |
| 82 | 82 | $this->attributes[$code][$type] = $item; |
| 83 | 83 | return $item; |
@@ -90,14 +90,14 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @param \Aimeos\MShop\Common\Item\Iface $item Attribute object |
| 92 | 92 | */ |
| 93 | - public function set( \Aimeos\MShop\Common\Item\Iface $item ) |
|
| 93 | + public function set(\Aimeos\MShop\Common\Item\Iface $item) |
|
| 94 | 94 | { |
| 95 | 95 | $code = $item->getCode(); |
| 96 | 96 | |
| 97 | - if( !isset( $this->attributes[$code] ) || !is_array( $this->attributes[$code] ) ) { |
|
| 97 | + if (!isset($this->attributes[$code]) || !is_array($this->attributes[$code])) { |
|
| 98 | 98 | $this->attributes[$code] = array(); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - $this->attributes[$code][ $item->getType() ] = $item; |
|
| 101 | + $this->attributes[$code][$item->getType()] = $item; |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | \ No newline at end of file |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
| 26 | 26 | */ |
| 27 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ); |
|
| 27 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context); |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Returns the item or ID for the given code |
@@ -33,12 +33,12 @@ discard block |
||
| 33 | 33 | * @param string|null $type Item type if used and required |
| 34 | 34 | * @return \Aimeos\MShop\Common\Item\Iface|string|null Item object, unique ID or null if not found |
| 35 | 35 | */ |
| 36 | - public function get( $code, $type = null ); |
|
| 36 | + public function get($code, $type = null); |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * Adds the item or ID to the cache |
| 40 | 40 | * |
| 41 | 41 | * @param \Aimeos\MShop\Common\Item\Iface $item Item object |
| 42 | 42 | */ |
| 43 | - public function set( \Aimeos\MShop\Common\Item\Iface $item ); |
|
| 43 | + public function set(\Aimeos\MShop\Common\Item\Iface $item); |
|
| 44 | 44 | } |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
| 42 | 42 | */ |
| 43 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 43 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 44 | 44 | { |
| 45 | - parent::__construct( $context ); |
|
| 45 | + parent::__construct($context); |
|
| 46 | 46 | |
| 47 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'catalog' ); |
|
| 48 | - $result = $manager->searchItems( $manager->createSearch() ); |
|
| 47 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'catalog'); |
|
| 48 | + $result = $manager->searchItems($manager->createSearch()); |
|
| 49 | 49 | |
| 50 | - foreach( $result as $id => $item ) { |
|
| 51 | - $this->categories[ $item->getCode() ] = $id; |
|
| 50 | + foreach ($result as $id => $item) { |
|
| 51 | + $this->categories[$item->getCode()] = $id; |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
@@ -60,20 +60,20 @@ discard block |
||
| 60 | 60 | * @param string|null $type Not used |
| 61 | 61 | * @return string|null Catalog ID or null if not found |
| 62 | 62 | */ |
| 63 | - public function get( $code, $type = null ) |
|
| 63 | + public function get($code, $type = null) |
|
| 64 | 64 | { |
| 65 | - if( isset( $this->categories[$code] ) ) { |
|
| 65 | + if (isset($this->categories[$code])) { |
|
| 66 | 66 | return $this->categories[$code]; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog' ); |
|
| 69 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog'); |
|
| 70 | 70 | |
| 71 | 71 | $search = $manager->createSearch(); |
| 72 | - $search->setConditions( $search->compare( '==', 'catalog.code', $code ) ); |
|
| 72 | + $search->setConditions($search->compare('==', 'catalog.code', $code)); |
|
| 73 | 73 | |
| 74 | - $result = $manager->searchItems( $search ); |
|
| 74 | + $result = $manager->searchItems($search); |
|
| 75 | 75 | |
| 76 | - if( ( $item = reset( $result ) ) !== false ) |
|
| 76 | + if (($item = reset($result)) !== false) |
|
| 77 | 77 | { |
| 78 | 78 | $this->categories[$code] = $item->getId(); |
| 79 | 79 | return $item->getId(); |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @param \Aimeos\MShop\Common\Item\Iface $item Catalog object |
| 88 | 88 | */ |
| 89 | - public function set( \Aimeos\MShop\Common\Item\Iface $item ) |
|
| 89 | + public function set(\Aimeos\MShop\Common\Item\Iface $item) |
|
| 90 | 90 | { |
| 91 | - $this->categories[ $item->getCode() ] = $item->getId(); |
|
| 91 | + $this->categories[$item->getCode()] = $item->getId(); |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | \ No newline at end of file |
@@ -40,16 +40,16 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
| 42 | 42 | */ |
| 43 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 43 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 44 | 44 | { |
| 45 | - parent::__construct( $context ); |
|
| 45 | + parent::__construct($context); |
|
| 46 | 46 | |
| 47 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product/stock/warehouse' ); |
|
| 47 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product/stock/warehouse'); |
|
| 48 | 48 | $search = $manager->createSearch(); |
| 49 | - $search->setSlice( 0, 1000 ); |
|
| 49 | + $search->setSlice(0, 1000); |
|
| 50 | 50 | |
| 51 | - foreach( $manager->searchItems( $search ) as $id => $item ) { |
|
| 52 | - $this->warehouses[ $item->getCode() ] = $id; |
|
| 51 | + foreach ($manager->searchItems($search) as $id => $item) { |
|
| 52 | + $this->warehouses[$item->getCode()] = $id; |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | * @param string|null $type Attribute type |
| 62 | 62 | * @return string|null Warehouse ID or null if not found |
| 63 | 63 | */ |
| 64 | - public function get( $code, $type = null ) |
|
| 64 | + public function get($code, $type = null) |
|
| 65 | 65 | { |
| 66 | - if( isset( $this->warehouses[$code] ) ) { |
|
| 66 | + if (isset($this->warehouses[$code])) { |
|
| 67 | 67 | return $this->warehouses[$code]; |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @param \Aimeos\MShop\Common\Item\Iface $item Warehouse object |
| 76 | 76 | */ |
| 77 | - public function set( \Aimeos\MShop\Common\Item\Iface $item ) |
|
| 77 | + public function set(\Aimeos\MShop\Common\Item\Iface $item) |
|
| 78 | 78 | { |
| 79 | - $this->warehouses[ $item->getCode() ] = $item->getId(); |
|
| 79 | + $this->warehouses[$item->getCode()] = $item->getId(); |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | \ No newline at end of file |
@@ -42,20 +42,20 @@ discard block |
||
| 42 | 42 | * @param string|null $type Attribute type |
| 43 | 43 | * @return string|null Product ID or null if not found |
| 44 | 44 | */ |
| 45 | - public function get( $code, $type = null ) |
|
| 45 | + public function get($code, $type = null) |
|
| 46 | 46 | { |
| 47 | - if( isset( $this->prodmap[$code] ) ) { |
|
| 47 | + if (isset($this->prodmap[$code])) { |
|
| 48 | 48 | return $this->prodmap[$code]; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
| 51 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
| 52 | 52 | |
| 53 | 53 | $search = $manager->createSearch(); |
| 54 | - $search->setConditions( $search->compare( '==', 'product.code', $code ) ); |
|
| 54 | + $search->setConditions($search->compare('==', 'product.code', $code)); |
|
| 55 | 55 | |
| 56 | - $result = $manager->searchItems( $search ); |
|
| 56 | + $result = $manager->searchItems($search); |
|
| 57 | 57 | |
| 58 | - if( ( $item = reset( $result ) ) !== false ) |
|
| 58 | + if (($item = reset($result)) !== false) |
|
| 59 | 59 | { |
| 60 | 60 | $this->prodmap[$code] = $item->getId(); |
| 61 | 61 | return $this->prodmap[$code]; |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @param \Aimeos\MShop\Common\Item\Iface $item Product object |
| 70 | 70 | */ |
| 71 | - public function set( \Aimeos\MShop\Common\Item\Iface $item ) |
|
| 71 | + public function set(\Aimeos\MShop\Common\Item\Iface $item) |
|
| 72 | 72 | { |
| 73 | - $this->prodmap[ $item->getCode() ] = $item->getId(); |
|
| 73 | + $this->prodmap[$item->getCode()] = $item->getId(); |
|
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | \ No newline at end of file |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | * |
| 28 | 28 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
| 29 | 29 | */ |
| 30 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 30 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 31 | 31 | { |
| 32 | 32 | $this->context = $context; |
| 33 | 33 | } |