@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function getName() |
31 | 31 | { |
32 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Removes unpaid orders' ); |
|
32 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Removes unpaid orders'); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function getDescription() |
42 | 42 | { |
43 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Deletes unpaid orders to keep the database clean' ); |
|
43 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Deletes unpaid orders to keep the database clean'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | public function run() |
53 | 53 | { |
54 | 54 | $context = $this->getContext(); |
55 | - $controller = \Aimeos\Controller\Common\Order\Factory::createController( $context ); |
|
56 | - $baseManager = \Aimeos\MShop::create( $context, 'order/base' ); |
|
57 | - $manager = \Aimeos\MShop::create( $context, 'order' ); |
|
55 | + $controller = \Aimeos\Controller\Common\Order\Factory::createController($context); |
|
56 | + $baseManager = \Aimeos\MShop::create($context, 'order/base'); |
|
57 | + $manager = \Aimeos\MShop::create($context, 'order'); |
|
58 | 58 | |
59 | 59 | /** controller/jobs/order/cleanup/unpaid/keep-days |
60 | 60 | * Removes all orders from the database that are unpaid |
@@ -71,35 +71,35 @@ discard block |
||
71 | 71 | * @since 2014.07 |
72 | 72 | * @category User |
73 | 73 | */ |
74 | - $days = $context->getConfig()->get( 'controller/jobs/order/cleanup/unpaid/keep-days', 3 ); |
|
75 | - $limit = date( 'Y-m-d H:i:s', time() - 86400 * $days ); |
|
74 | + $days = $context->getConfig()->get('controller/jobs/order/cleanup/unpaid/keep-days', 3); |
|
75 | + $limit = date('Y-m-d H:i:s', time() - 86400 * $days); |
|
76 | 76 | |
77 | 77 | $search = $manager->createSearch(); |
78 | 78 | $expr = array( |
79 | - $search->compare( '<', 'order.mtime', $limit ), |
|
80 | - $search->compare( '<', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_REFUND ), |
|
79 | + $search->compare('<', 'order.mtime', $limit), |
|
80 | + $search->compare('<', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_REFUND), |
|
81 | 81 | ); |
82 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
82 | + $search->setConditions($search->combine('&&', $expr)); |
|
83 | 83 | |
84 | 84 | $start = 0; |
85 | 85 | |
86 | 86 | do |
87 | 87 | { |
88 | 88 | $baseIds = []; |
89 | - $items = $manager->searchItems( $search ); |
|
89 | + $items = $manager->searchItems($search); |
|
90 | 90 | |
91 | - foreach( $items as $item ) |
|
91 | + foreach ($items as $item) |
|
92 | 92 | { |
93 | - $controller->unblock( $item ); |
|
93 | + $controller->unblock($item); |
|
94 | 94 | $baseIds[] = $item->getBaseId(); |
95 | 95 | } |
96 | 96 | |
97 | - $baseManager->deleteItems( $baseIds ); |
|
97 | + $baseManager->deleteItems($baseIds); |
|
98 | 98 | |
99 | - $count = count( $items ); |
|
99 | + $count = count($items); |
|
100 | 100 | $start += $count; |
101 | - $search->setSlice( $start ); |
|
101 | + $search->setSlice($start); |
|
102 | 102 | } |
103 | - while( $count >= $search->getSliceSize() ); |
|
103 | + while ($count >= $search->getSliceSize()); |
|
104 | 104 | } |
105 | 105 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function getName() |
31 | 31 | { |
32 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Process order delivery services' ); |
|
32 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Process order delivery services'); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function getDescription() |
42 | 42 | { |
43 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Sends paid orders to the ERP system or logistic partner' ); |
|
43 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Sends paid orders to the ERP system or logistic partner'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | * @see controller/jobs/order/email/delivery/standard/limit-days |
70 | 70 | * @see controller/jobs/order/service/delivery/batch-max |
71 | 71 | */ |
72 | - $days = $context->getConfig()->get( 'controller/jobs/order/service/delivery/limit-days', 90 ); |
|
73 | - $date = date( 'Y-m-d 00:00:00', time() - 86400 * $days ); |
|
72 | + $days = $context->getConfig()->get('controller/jobs/order/service/delivery/limit-days', 90); |
|
73 | + $date = date('Y-m-d 00:00:00', time() - 86400 * $days); |
|
74 | 74 | |
75 | 75 | /** controller/jobs/order/service/delivery/batch-max |
76 | 76 | * Maximum number of orders processed at once by the delivery service provider |
@@ -85,71 +85,71 @@ discard block |
||
85 | 85 | * @category Developer |
86 | 86 | * @see controller/jobs/order/service/delivery/limit-days |
87 | 87 | */ |
88 | - $maxItems = $context->getConfig()->get( 'controller/jobs/order/service/delivery/batch-max', 100 ); |
|
88 | + $maxItems = $context->getConfig()->get('controller/jobs/order/service/delivery/batch-max', 100); |
|
89 | 89 | |
90 | 90 | |
91 | - $serviceManager = \Aimeos\MShop\Service\Manager\Factory::create( $context ); |
|
91 | + $serviceManager = \Aimeos\MShop\Service\Manager\Factory::create($context); |
|
92 | 92 | $serviceSearch = $serviceManager->createSearch(); |
93 | - $serviceSearch->setConditions( $serviceSearch->compare( '==', 'service.type', 'delivery' ) ); |
|
93 | + $serviceSearch->setConditions($serviceSearch->compare('==', 'service.type', 'delivery')); |
|
94 | 94 | |
95 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::create( $context ); |
|
95 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::create($context); |
|
96 | 96 | $orderSearch = $orderManager->createSearch(); |
97 | 97 | |
98 | 98 | $start = 0; |
99 | 99 | |
100 | 100 | do |
101 | 101 | { |
102 | - $serviceItems = $serviceManager->searchItems( $serviceSearch ); |
|
102 | + $serviceItems = $serviceManager->searchItems($serviceSearch); |
|
103 | 103 | |
104 | - foreach( $serviceItems as $serviceItem ) |
|
104 | + foreach ($serviceItems as $serviceItem) |
|
105 | 105 | { |
106 | 106 | try |
107 | 107 | { |
108 | - $serviceProvider = $serviceManager->getProvider( $serviceItem, $serviceItem->getType() ); |
|
108 | + $serviceProvider = $serviceManager->getProvider($serviceItem, $serviceItem->getType()); |
|
109 | 109 | |
110 | 110 | $expr = array( |
111 | - $orderSearch->compare( '>', 'order.datepayment', $date ), |
|
112 | - $orderSearch->compare( '>', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_PENDING ), |
|
113 | - $orderSearch->compare( '==', 'order.statusdelivery', \Aimeos\MShop\Order\Item\Base::STAT_UNFINISHED ), |
|
114 | - $orderSearch->compare( '==', 'order.base.service.code', $serviceItem->getCode() ), |
|
115 | - $orderSearch->compare( '==', 'order.base.service.type', 'delivery' ), |
|
111 | + $orderSearch->compare('>', 'order.datepayment', $date), |
|
112 | + $orderSearch->compare('>', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_PENDING), |
|
113 | + $orderSearch->compare('==', 'order.statusdelivery', \Aimeos\MShop\Order\Item\Base::STAT_UNFINISHED), |
|
114 | + $orderSearch->compare('==', 'order.base.service.code', $serviceItem->getCode()), |
|
115 | + $orderSearch->compare('==', 'order.base.service.type', 'delivery'), |
|
116 | 116 | ); |
117 | - $orderSearch->setConditions( $orderSearch->combine( '&&', $expr ) ); |
|
117 | + $orderSearch->setConditions($orderSearch->combine('&&', $expr)); |
|
118 | 118 | |
119 | 119 | $orderStart = 0; |
120 | 120 | |
121 | 121 | do |
122 | 122 | { |
123 | - $orderSearch->setSlice( $orderStart, $maxItems ); |
|
124 | - $orderItems = $orderManager->searchItems( $orderSearch ); |
|
123 | + $orderSearch->setSlice($orderStart, $maxItems); |
|
124 | + $orderItems = $orderManager->searchItems($orderSearch); |
|
125 | 125 | |
126 | 126 | try |
127 | 127 | { |
128 | - $serviceProvider->processBatch( $orderItems ); |
|
129 | - $orderManager->saveItems( $orderItems ); |
|
128 | + $serviceProvider->processBatch($orderItems); |
|
129 | + $orderManager->saveItems($orderItems); |
|
130 | 130 | } |
131 | - catch( \Exception $e ) |
|
131 | + catch (\Exception $e) |
|
132 | 132 | { |
133 | 133 | $str = 'Error while processing orders by delivery service "%1$s": %2$s'; |
134 | - $context->getLogger()->log( sprintf( $str, $serviceItem->getLabel(), $e->getMessage() ) ); |
|
134 | + $context->getLogger()->log(sprintf($str, $serviceItem->getLabel(), $e->getMessage())); |
|
135 | 135 | } |
136 | 136 | |
137 | - $orderCount = count( $orderItems ); |
|
137 | + $orderCount = count($orderItems); |
|
138 | 138 | $orderStart += $orderCount; |
139 | 139 | } |
140 | - while( $orderCount >= $orderSearch->getSliceSize() ); |
|
140 | + while ($orderCount >= $orderSearch->getSliceSize()); |
|
141 | 141 | } |
142 | - catch( \Exception $e ) |
|
142 | + catch (\Exception $e) |
|
143 | 143 | { |
144 | 144 | $str = 'Error while processing service with ID "%1$s": %2$s'; |
145 | - $context->getLogger()->log( sprintf( $str, $serviceItem->getId(), $e->getMessage() ) ); |
|
145 | + $context->getLogger()->log(sprintf($str, $serviceItem->getId(), $e->getMessage())); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | - $count = count( $serviceItems ); |
|
149 | + $count = count($serviceItems); |
|
150 | 150 | $start += $count; |
151 | - $serviceSearch->setSlice( $start ); |
|
151 | + $serviceSearch->setSlice($start); |
|
152 | 152 | } |
153 | - while( $count >= $serviceSearch->getSliceSize() ); |
|
153 | + while ($count >= $serviceSearch->getSliceSize()); |
|
154 | 154 | } |
155 | 155 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function getName() |
31 | 31 | { |
32 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Batch update of payment/delivery status' ); |
|
32 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Batch update of payment/delivery status'); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function getDescription() |
42 | 42 | { |
43 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Executes payment or delivery service providers that uses batch updates' ); |
|
43 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Executes payment or delivery service providers that uses batch updates'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -52,32 +52,32 @@ discard block |
||
52 | 52 | public function run() |
53 | 53 | { |
54 | 54 | $context = $this->getContext(); |
55 | - $serviceManager = \Aimeos\MShop::create( $context, 'service' ); |
|
55 | + $serviceManager = \Aimeos\MShop::create($context, 'service'); |
|
56 | 56 | |
57 | 57 | $search = $serviceManager->createSearch(); |
58 | 58 | $start = 0; |
59 | 59 | |
60 | 60 | do |
61 | 61 | { |
62 | - $serviceItems = $serviceManager->searchItems( $search ); |
|
62 | + $serviceItems = $serviceManager->searchItems($search); |
|
63 | 63 | |
64 | - foreach( $serviceItems as $serviceItem ) |
|
64 | + foreach ($serviceItems as $serviceItem) |
|
65 | 65 | { |
66 | 66 | try |
67 | 67 | { |
68 | - $serviceManager->getProvider( $serviceItem, $serviceItem->getType() )->updateAsync(); |
|
68 | + $serviceManager->getProvider($serviceItem, $serviceItem->getType())->updateAsync(); |
|
69 | 69 | } |
70 | - catch( \Exception $e ) |
|
70 | + catch (\Exception $e) |
|
71 | 71 | { |
72 | 72 | $msg = 'Executing updateAsyc() of "%1$s" failed: %2$s'; |
73 | - $context->getLogger()->log( sprintf( $msg, $serviceItem->getProvider(), $e->getMessage() ) ); |
|
73 | + $context->getLogger()->log(sprintf($msg, $serviceItem->getProvider(), $e->getMessage())); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | - $count = count( $serviceItems ); |
|
77 | + $count = count($serviceItems); |
|
78 | 78 | $start += $count; |
79 | - $search->setSlice( $start ); |
|
79 | + $search->setSlice($start); |
|
80 | 80 | } |
81 | - while( $count >= $search->getSliceSize() ); |
|
81 | + while ($count >= $search->getSliceSize()); |
|
82 | 82 | } |
83 | 83 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function getName() |
31 | 31 | { |
32 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Capture authorized payments' ); |
|
32 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Capture authorized payments'); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function getDescription() |
42 | 42 | { |
43 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Authorized payments of orders will be captured after dispatching or after a configurable amount of time' ); |
|
43 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Authorized payments of orders will be captured after dispatching or after a configurable amount of time'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * @category User |
69 | 69 | * @category Developer |
70 | 70 | */ |
71 | - $days = $config->get( 'controller/jobs/order/service/payment/limit-days', 90 ); |
|
72 | - $date = date( 'Y-m-d 00:00:00', time() - 86400 * $days ); |
|
71 | + $days = $config->get('controller/jobs/order/service/payment/limit-days', 90); |
|
72 | + $date = date('Y-m-d 00:00:00', time() - 86400 * $days); |
|
73 | 73 | |
74 | 74 | /** controller/jobs/order/service/payment/capture-days |
75 | 75 | * Automatically capture payments after the configured amount of days |
@@ -84,90 +84,90 @@ discard block |
||
84 | 84 | * @category User |
85 | 85 | * @category Developer |
86 | 86 | */ |
87 | - $capDays = $config->get( 'controller/jobs/order/service/payment/capture-days', null ); |
|
87 | + $capDays = $config->get('controller/jobs/order/service/payment/capture-days', null); |
|
88 | 88 | |
89 | 89 | |
90 | - $serviceManager = \Aimeos\MShop::create( $context, 'service' ); |
|
90 | + $serviceManager = \Aimeos\MShop::create($context, 'service'); |
|
91 | 91 | $serviceSearch = $serviceManager->createSearch(); |
92 | - $serviceSearch->setConditions( $serviceSearch->compare( '==', 'service.type', 'payment' ) ); |
|
92 | + $serviceSearch->setConditions($serviceSearch->compare('==', 'service.type', 'payment')); |
|
93 | 93 | |
94 | - $orderManager = \Aimeos\MShop::create( $context, 'order' ); |
|
94 | + $orderManager = \Aimeos\MShop::create($context, 'order'); |
|
95 | 95 | $orderSearch = $orderManager->createSearch(); |
96 | 96 | |
97 | - $status = array( \Aimeos\MShop\Order\Item\Base::STAT_DISPATCHED, \Aimeos\MShop\Order\Item\Base::STAT_DELIVERED ); |
|
97 | + $status = array(\Aimeos\MShop\Order\Item\Base::STAT_DISPATCHED, \Aimeos\MShop\Order\Item\Base::STAT_DELIVERED); |
|
98 | 98 | $start = 0; |
99 | 99 | |
100 | 100 | do |
101 | 101 | { |
102 | - $serviceItems = $serviceManager->searchItems( $serviceSearch ); |
|
102 | + $serviceItems = $serviceManager->searchItems($serviceSearch); |
|
103 | 103 | |
104 | - foreach( $serviceItems as $serviceItem ) |
|
104 | + foreach ($serviceItems as $serviceItem) |
|
105 | 105 | { |
106 | 106 | try |
107 | 107 | { |
108 | - $serviceProvider = $serviceManager->getProvider( $serviceItem, $serviceItem->getType() ); |
|
108 | + $serviceProvider = $serviceManager->getProvider($serviceItem, $serviceItem->getType()); |
|
109 | 109 | |
110 | - if( !$serviceProvider->isImplemented( \Aimeos\MShop\Service\Provider\Payment\Base::FEAT_CAPTURE ) ) { |
|
110 | + if (!$serviceProvider->isImplemented(\Aimeos\MShop\Service\Provider\Payment\Base::FEAT_CAPTURE)) { |
|
111 | 111 | continue; |
112 | 112 | } |
113 | 113 | |
114 | 114 | |
115 | 115 | $expr = []; |
116 | - $expr[] = $orderSearch->compare( '>', 'order.datepayment', $date ); |
|
116 | + $expr[] = $orderSearch->compare('>', 'order.datepayment', $date); |
|
117 | 117 | |
118 | - if( $capDays !== null ) |
|
118 | + if ($capDays !== null) |
|
119 | 119 | { |
120 | - $capdate = date( 'Y-m-d 00:00:00', time() - 86400 * $capDays ); |
|
121 | - $expr[] = $orderSearch->compare( '<=', 'order.datepayment', $capdate ); |
|
120 | + $capdate = date('Y-m-d 00:00:00', time() - 86400 * $capDays); |
|
121 | + $expr[] = $orderSearch->compare('<=', 'order.datepayment', $capdate); |
|
122 | 122 | } |
123 | 123 | else |
124 | 124 | { |
125 | - $expr[] = $orderSearch->compare( '==', 'order.statusdelivery', $status ); |
|
125 | + $expr[] = $orderSearch->compare('==', 'order.statusdelivery', $status); |
|
126 | 126 | } |
127 | 127 | |
128 | - $expr[] = $orderSearch->compare( '==', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED ); |
|
129 | - $expr[] = $orderSearch->compare( '==', 'order.base.service.code', $serviceItem->getCode() ); |
|
130 | - $expr[] = $orderSearch->compare( '==', 'order.base.service.type', 'payment' ); |
|
128 | + $expr[] = $orderSearch->compare('==', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED); |
|
129 | + $expr[] = $orderSearch->compare('==', 'order.base.service.code', $serviceItem->getCode()); |
|
130 | + $expr[] = $orderSearch->compare('==', 'order.base.service.type', 'payment'); |
|
131 | 131 | |
132 | - $orderSearch->setConditions( $orderSearch->combine( '&&', $expr ) ); |
|
132 | + $orderSearch->setConditions($orderSearch->combine('&&', $expr)); |
|
133 | 133 | |
134 | 134 | |
135 | 135 | $orderStart = 0; |
136 | 136 | |
137 | 137 | do |
138 | 138 | { |
139 | - $orderItems = $orderManager->searchItems( $orderSearch ); |
|
139 | + $orderItems = $orderManager->searchItems($orderSearch); |
|
140 | 140 | |
141 | - foreach( $orderItems as $orderItem ) |
|
141 | + foreach ($orderItems as $orderItem) |
|
142 | 142 | { |
143 | 143 | try |
144 | 144 | { |
145 | - $serviceProvider->capture( $orderItem ); |
|
145 | + $serviceProvider->capture($orderItem); |
|
146 | 146 | } |
147 | - catch( \Exception $e ) |
|
147 | + catch (\Exception $e) |
|
148 | 148 | { |
149 | 149 | $str = 'Error while capturing payment for order with ID "%1$s": %2$s'; |
150 | - $context->getLogger()->log( sprintf( $str, $orderItem->getId(), $e->getMessage() ) ); |
|
150 | + $context->getLogger()->log(sprintf($str, $orderItem->getId(), $e->getMessage())); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | - $orderCount = count( $orderItems ); |
|
154 | + $orderCount = count($orderItems); |
|
155 | 155 | $orderStart += $orderCount; |
156 | - $orderSearch->setSlice( $orderStart ); |
|
156 | + $orderSearch->setSlice($orderStart); |
|
157 | 157 | } |
158 | - while( $orderCount >= $orderSearch->getSliceSize() ); |
|
158 | + while ($orderCount >= $orderSearch->getSliceSize()); |
|
159 | 159 | } |
160 | - catch( \Exception $e ) |
|
160 | + catch (\Exception $e) |
|
161 | 161 | { |
162 | 162 | $str = 'Error while capturing payments for service with ID "%1$s": %2$s'; |
163 | - $context->getLogger()->log( sprintf( $str, $serviceItem->getId(), $e->getMessage() ) ); |
|
163 | + $context->getLogger()->log(sprintf($str, $serviceItem->getId(), $e->getMessage())); |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | - $count = count( $serviceItems ); |
|
167 | + $count = count($serviceItems); |
|
168 | 168 | $start += $count; |
169 | - $serviceSearch->setSlice( $start ); |
|
169 | + $serviceSearch->setSlice($start); |
|
170 | 170 | } |
171 | - while( $count >= $serviceSearch->getSliceSize() ); |
|
171 | + while ($count >= $serviceSearch->getSliceSize()); |
|
172 | 172 | } |
173 | 173 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function getName() |
30 | 30 | { |
31 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Order export CSV' ); |
|
31 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Order export CSV'); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function getDescription() |
41 | 41 | { |
42 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Exports orders to CSV file' ); |
|
42 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Exports orders to CSV file'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @category Developer |
74 | 74 | * @see controller/common/order/export/csv/max-size |
75 | 75 | */ |
76 | - $mappings = $config->get( 'controller/common/order/export/csv/mapping', $mappings ); |
|
76 | + $mappings = $config->get('controller/common/order/export/csv/mapping', $mappings); |
|
77 | 77 | |
78 | 78 | /** controller/jobs/order/export/csv/mapping |
79 | 79 | * List of mappings between the position in the CSV file and item keys |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @category Developer |
89 | 89 | * @see controller/common/order/export/csv/max-size |
90 | 90 | */ |
91 | - $mappings = $config->get( 'controller/jobs/order/export/csv/mapping', $mappings ); |
|
91 | + $mappings = $config->get('controller/jobs/order/export/csv/mapping', $mappings); |
|
92 | 92 | |
93 | 93 | |
94 | 94 | /** controller/common/order/export/csv/max-size |
@@ -106,29 +106,29 @@ discard block |
||
106 | 106 | * @category Developer |
107 | 107 | * @see controller/common/order/export/csv/mapping |
108 | 108 | */ |
109 | - $maxcnt = (int) $config->get( 'controller/common/order/export/csv/max-size', 1000 ); |
|
109 | + $maxcnt = (int) $config->get('controller/common/order/export/csv/max-size', 1000); |
|
110 | 110 | |
111 | 111 | |
112 | - $processors = $this->getProcessors( $mappings ); |
|
113 | - $mq = $context->getMessageQueueManager()->get( 'mq-admin' )->getQueue( 'order-export' ); |
|
112 | + $processors = $this->getProcessors($mappings); |
|
113 | + $mq = $context->getMessageQueueManager()->get('mq-admin')->getQueue('order-export'); |
|
114 | 114 | |
115 | - while( ( $msg = $mq->get() ) !== null ) |
|
115 | + while (($msg = $mq->get()) !== null) |
|
116 | 116 | { |
117 | 117 | try |
118 | 118 | { |
119 | - if( ( $data = json_decode( $msg->getBody(), true ) ) === null ) { |
|
120 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid message: %1$s', $msg->getBody() ) ); |
|
119 | + if (($data = json_decode($msg->getBody(), true)) === null) { |
|
120 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid message: %1$s', $msg->getBody())); |
|
121 | 121 | } |
122 | 122 | |
123 | - $this->export( $processors, $data, $maxcnt ); |
|
123 | + $this->export($processors, $data, $maxcnt); |
|
124 | 124 | } |
125 | - catch( \Exception $e ) |
|
125 | + catch (\Exception $e) |
|
126 | 126 | { |
127 | - $logger->log( 'Order export error: ' . $e->getMessage() ); |
|
128 | - $logger->log( $e->getTraceAsString() ); |
|
127 | + $logger->log('Order export error: ' . $e->getMessage()); |
|
128 | + $logger->log($e->getTraceAsString()); |
|
129 | 129 | } |
130 | 130 | |
131 | - $mq->del( $msg ); |
|
131 | + $mq->del($msg); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
@@ -139,15 +139,15 @@ discard block |
||
139 | 139 | * @param \Aimeos\MShop\Context\Item\Iface $context Context item |
140 | 140 | * @param string $path Absolute path to the exported file |
141 | 141 | */ |
142 | - protected function addJob( $context, $path ) |
|
142 | + protected function addJob($context, $path) |
|
143 | 143 | { |
144 | - $manager = \Aimeos\MAdmin::create( $context, 'job' ); |
|
144 | + $manager = \Aimeos\MAdmin::create($context, 'job'); |
|
145 | 145 | |
146 | 146 | $item = $manager->createItem(); |
147 | - $item->setResult( ['file' => $path] ); |
|
148 | - $item->setLabel( $path ); |
|
147 | + $item->setResult(['file' => $path]); |
|
148 | + $item->setLabel($path); |
|
149 | 149 | |
150 | - $manager->saveItem( $item, false ); |
|
150 | + $manager->saveItem($item, false); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @see controller/jobs/order/export/csv/container/content |
178 | 178 | * @see controller/jobs/order/export/csv/container/options |
179 | 179 | */ |
180 | - $location = $config->get( 'controller/jobs/order/export/csv/location', sys_get_temp_dir() ); |
|
180 | + $location = $config->get('controller/jobs/order/export/csv/location', sys_get_temp_dir()); |
|
181 | 181 | |
182 | 182 | /** controller/jobs/order/export/csv/container/type |
183 | 183 | * Nave of the container type to read the data from |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @see controller/jobs/order/export/csv/container/content |
201 | 201 | * @see controller/jobs/order/export/csv/container/options |
202 | 202 | */ |
203 | - $container = $config->get( 'controller/jobs/order/export/csv/container/type', 'Directory' ); |
|
203 | + $container = $config->get('controller/jobs/order/export/csv/container/type', 'Directory'); |
|
204 | 204 | |
205 | 205 | /** controller/jobs/order/export/csv/container/content |
206 | 206 | * Name of the content type inside the container to read the data from |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @see controller/jobs/order/export/csv/container/type |
222 | 222 | * @see controller/jobs/order/export/csv/container/options |
223 | 223 | */ |
224 | - $content = $config->get( 'controller/jobs/order/export/csv/container/content', 'CSV' ); |
|
224 | + $content = $config->get('controller/jobs/order/export/csv/container/content', 'CSV'); |
|
225 | 225 | |
226 | 226 | /** controller/jobs/order/export/csv/container/options |
227 | 227 | * List of file container options for the order export files |
@@ -239,9 +239,9 @@ discard block |
||
239 | 239 | * @see controller/jobs/order/export/csv/container/content |
240 | 240 | * @see controller/jobs/order/export/csv/container/type |
241 | 241 | */ |
242 | - $options = $config->get( 'controller/jobs/order/export/csv/container/options', [] ); |
|
242 | + $options = $config->get('controller/jobs/order/export/csv/container/options', []); |
|
243 | 243 | |
244 | - return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options ); |
|
244 | + return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | |
@@ -253,56 +253,56 @@ discard block |
||
253 | 253 | * @param integer $maxcnt Maximum number of retrieved orders at once |
254 | 254 | * @return string Path of the file containing the exported data |
255 | 255 | */ |
256 | - protected function export( array $processors, $msg, $maxcnt ) |
|
256 | + protected function export(array $processors, $msg, $maxcnt) |
|
257 | 257 | { |
258 | - $lcontext = $this->getLocaleContext( $msg ); |
|
258 | + $lcontext = $this->getLocaleContext($msg); |
|
259 | 259 | $baseRef = ['order/base/address', 'order/base/coupon', 'order/base/product', 'order/base/service']; |
260 | 260 | |
261 | - $manager = \Aimeos\MShop::create( $lcontext, 'order' ); |
|
262 | - $baseManager = \Aimeos\MShop::create( $lcontext, 'order/base' ); |
|
261 | + $manager = \Aimeos\MShop::create($lcontext, 'order'); |
|
262 | + $baseManager = \Aimeos\MShop::create($lcontext, 'order/base'); |
|
263 | 263 | |
264 | 264 | $container = $this->getContainer(); |
265 | - $content = $container->create( 'order-export_' . date( 'Y-m-d_H-i-s' ) ); |
|
266 | - $search = $this->initCriteria( $manager->createSearch()->setSlice( 0, 0x7fffffff ), $msg ); |
|
265 | + $content = $container->create('order-export_' . date('Y-m-d_H-i-s')); |
|
266 | + $search = $this->initCriteria($manager->createSearch()->setSlice(0, 0x7fffffff), $msg); |
|
267 | 267 | $start = 0; |
268 | 268 | |
269 | 269 | do |
270 | 270 | { |
271 | 271 | $baseIds = []; |
272 | - $search->setSlice( $start, $maxcnt ); |
|
273 | - $items = $manager->searchItems( $search ); |
|
272 | + $search->setSlice($start, $maxcnt); |
|
273 | + $items = $manager->searchItems($search); |
|
274 | 274 | |
275 | - foreach( $items as $item ) { |
|
275 | + foreach ($items as $item) { |
|
276 | 276 | $baseIds[] = $item->getBaseId(); |
277 | 277 | } |
278 | 278 | |
279 | 279 | $baseSearch = $baseManager->createSearch(); |
280 | - $baseSearch->setConditions( $baseSearch->compare( '==', 'order.base.id', $baseIds ) ); |
|
281 | - $baseSearch->setSlice( 0, count( $baseIds ) ); |
|
280 | + $baseSearch->setConditions($baseSearch->compare('==', 'order.base.id', $baseIds)); |
|
281 | + $baseSearch->setSlice(0, count($baseIds)); |
|
282 | 282 | |
283 | - $baseItems = $baseManager->searchItems( $baseSearch, $baseRef ); |
|
283 | + $baseItems = $baseManager->searchItems($baseSearch, $baseRef); |
|
284 | 284 | |
285 | - foreach( $items as $id => $item ) |
|
285 | + foreach ($items as $id => $item) |
|
286 | 286 | { |
287 | - foreach( $processors as $type => $processor ) |
|
287 | + foreach ($processors as $type => $processor) |
|
288 | 288 | { |
289 | - foreach( $processor->process( $item, $baseItems[$item->getBaseId()] ) as $line ) { |
|
290 | - $content->add( [0 => $type, 1 => $id] + $line ); |
|
289 | + foreach ($processor->process($item, $baseItems[$item->getBaseId()]) as $line) { |
|
290 | + $content->add([0 => $type, 1 => $id] + $line); |
|
291 | 291 | } |
292 | 292 | } |
293 | 293 | } |
294 | 294 | |
295 | - $count = count( $items ); |
|
295 | + $count = count($items); |
|
296 | 296 | $start += $count; |
297 | 297 | } |
298 | - while( $count === $search->getSliceSize() ); |
|
298 | + while ($count === $search->getSliceSize()); |
|
299 | 299 | |
300 | 300 | $path = $content->getResource(); |
301 | - $container->add( $content ); |
|
301 | + $container->add($content); |
|
302 | 302 | $container->close(); |
303 | 303 | |
304 | - $path = $this->moveFile( $lcontext, $path ); |
|
305 | - $this->addJob( $lcontext, $path ); |
|
304 | + $path = $this->moveFile($lcontext, $path); |
|
305 | + $this->addJob($lcontext, $path); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | |
@@ -312,15 +312,15 @@ discard block |
||
312 | 312 | * @param array $msg Message data including a "sitecode" value |
313 | 313 | * @return \Aimeos\MShop\Context\Item\Iface New context item with updated locale |
314 | 314 | */ |
315 | - protected function getLocaleContext( array $msg ) |
|
315 | + protected function getLocaleContext(array $msg) |
|
316 | 316 | { |
317 | 317 | $lcontext = clone $this->getContext(); |
318 | - $manager = \Aimeos\MShop::create( $lcontext, 'locale' ); |
|
318 | + $manager = \Aimeos\MShop::create($lcontext, 'locale'); |
|
319 | 319 | |
320 | - $sitecode = ( isset( $msg['sitecode'] ) ? $msg['sitecode'] : 'default' ); |
|
321 | - $localeItem = $manager->bootstrap( $sitecode, '', '', false, \Aimeos\MShop\Locale\Manager\Base::SITE_PATH ); |
|
320 | + $sitecode = (isset($msg['sitecode']) ? $msg['sitecode'] : 'default'); |
|
321 | + $localeItem = $manager->bootstrap($sitecode, '', '', false, \Aimeos\MShop\Locale\Manager\Base::SITE_PATH); |
|
322 | 322 | |
323 | - return $lcontext->setLocale( $localeItem ); |
|
323 | + return $lcontext->setLocale($localeItem); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | |
@@ -331,14 +331,14 @@ discard block |
||
331 | 331 | * @param array $msg Message data |
332 | 332 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
333 | 333 | */ |
334 | - protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $msg ) |
|
334 | + protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $msg) |
|
335 | 335 | { |
336 | - if( isset( $msg['filter'] ) ) { |
|
337 | - $criteria->setConditions( $criteria->toConditions( $msg['filter'] ) ); |
|
336 | + if (isset($msg['filter'])) { |
|
337 | + $criteria->setConditions($criteria->toConditions($msg['filter'])); |
|
338 | 338 | } |
339 | 339 | |
340 | - if( isset( $msg['sort'] ) ) { |
|
341 | - $criteria->setSortations( $criteria->toSortations( $msg['sort'] ) ); |
|
340 | + if (isset($msg['sort'])) { |
|
341 | + $criteria->setSortations($criteria->toSortations($msg['sort'])); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | return $criteria; |
@@ -352,12 +352,12 @@ discard block |
||
352 | 352 | * @param string $path Absolute path to the exported file |
353 | 353 | * @return string Relative path of the file in the storage |
354 | 354 | */ |
355 | - protected function moveFile( $context, $path ) |
|
355 | + protected function moveFile($context, $path) |
|
356 | 356 | { |
357 | - $filename = basename( $path ); |
|
358 | - $context->getFileSystemManager()->get( 'fs-admin' )->writef( $filename, $path ); |
|
357 | + $filename = basename($path); |
|
358 | + $context->getFileSystemManager()->get('fs-admin')->writef($filename, $path); |
|
359 | 359 | |
360 | - unlink( $path ); |
|
360 | + unlink($path); |
|
361 | 361 | return $filename; |
362 | 362 | } |
363 | 363 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function getName() |
31 | 31 | { |
32 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Cache cleanup' ); |
|
32 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Cache cleanup'); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function getDescription() |
42 | 42 | { |
43 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Removes the expired entries from the cache' ); |
|
43 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Removes the expired entries from the cache'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -51,6 +51,6 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function run() |
53 | 53 | { |
54 | - \Aimeos\MAdmin\Cache\Manager\Factory::create( $this->getContext() )->getCache()->cleanup(); |
|
54 | + \Aimeos\MAdmin\Cache\Manager\Factory::create($this->getContext())->getCache()->cleanup(); |
|
55 | 55 | } |
56 | 56 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function getName() |
31 | 31 | { |
32 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Log cleanup' ); |
|
32 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Log cleanup'); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function getDescription() |
42 | 42 | { |
43 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Removes the old log entries from the database and archives them (optional)' ); |
|
43 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Removes the old log entries from the database and archives them (optional)'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * @see controller/jobs/admin/log/standard/container/format |
72 | 72 | * @see controller/jobs/admin/log/standard/container/options |
73 | 73 | */ |
74 | - $limit = $config->get( 'controller/jobs/admin/log/standard/limit-days', 30 ); |
|
75 | - $limitDate = date( 'Y-m-d H:i:s', time() - $limit * 86400 ); |
|
74 | + $limit = $config->get('controller/jobs/admin/log/standard/limit-days', 30); |
|
75 | + $limitDate = date('Y-m-d H:i:s', time() - $limit * 86400); |
|
76 | 76 | |
77 | 77 | /** controller/jobs/admin/log/standard/path |
78 | 78 | * Path to a writable directory where the log archive files should be stored |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @see controller/jobs/admin/log/standard/container/options |
102 | 102 | * @see controller/jobs/admin/log/standard/limit-days |
103 | 103 | */ |
104 | - if( ( $path = $config->get( 'controller/jobs/admin/log/standard/path', null ) ) !== null ) |
|
104 | + if (($path = $config->get('controller/jobs/admin/log/standard/path', null)) !== null) |
|
105 | 105 | { |
106 | 106 | /** controller/jobs/admin/log/standard/container/type |
107 | 107 | * Container file type storing all coupon code files to import |
@@ -175,19 +175,19 @@ discard block |
||
175 | 175 | * @see controller/jobs/admin/log/standard/limit-days |
176 | 176 | */ |
177 | 177 | |
178 | - $type = $config->get( 'controller/jobs/admin/log/standard/container/type', 'Zip' ); |
|
179 | - $format = $config->get( 'controller/jobs/admin/log/standard/container/format', 'CSV' ); |
|
180 | - $options = $config->get( 'controller/jobs/admin/log/standard/container/options', [] ); |
|
178 | + $type = $config->get('controller/jobs/admin/log/standard/container/type', 'Zip'); |
|
179 | + $format = $config->get('controller/jobs/admin/log/standard/container/format', 'CSV'); |
|
180 | + $options = $config->get('controller/jobs/admin/log/standard/container/options', []); |
|
181 | 181 | |
182 | - $path .= DIRECTORY_SEPARATOR . str_replace( ' ', '_', $limitDate ); |
|
183 | - $container = \Aimeos\MW\Container\Factory::getContainer( $path, $type, $format, $options ); |
|
182 | + $path .= DIRECTORY_SEPARATOR . str_replace(' ', '_', $limitDate); |
|
183 | + $container = \Aimeos\MW\Container\Factory::getContainer($path, $type, $format, $options); |
|
184 | 184 | } |
185 | 185 | |
186 | - $manager = \Aimeos\MAdmin::create( $context, 'log' ); |
|
186 | + $manager = \Aimeos\MAdmin::create($context, 'log'); |
|
187 | 187 | |
188 | 188 | $search = $manager->createSearch(); |
189 | - $search->setConditions( $search->compare( '<=', 'log.timestamp', $limitDate ) ); |
|
190 | - $search->setSortations( array( $search->sort( '+', 'log.timestamp' ) ) ); |
|
189 | + $search->setConditions($search->compare('<=', 'log.timestamp', $limitDate)); |
|
190 | + $search->setSortations(array($search->sort('+', 'log.timestamp'))); |
|
191 | 191 | |
192 | 192 | $start = 0; |
193 | 193 | $contents = []; |
@@ -195,37 +195,37 @@ discard block |
||
195 | 195 | do |
196 | 196 | { |
197 | 197 | $ids = []; |
198 | - $items = $manager->searchItems( $search ); |
|
198 | + $items = $manager->searchItems($search); |
|
199 | 199 | |
200 | - foreach( $items as $id => $item ) |
|
200 | + foreach ($items as $id => $item) |
|
201 | 201 | { |
202 | - if( $container !== null ) |
|
202 | + if ($container !== null) |
|
203 | 203 | { |
204 | 204 | $facility = $item->getFacility(); |
205 | 205 | |
206 | - if( !isset( $contents[$facility] ) ) { |
|
207 | - $contents[$facility] = $container->create( $facility ); |
|
206 | + if (!isset($contents[$facility])) { |
|
207 | + $contents[$facility] = $container->create($facility); |
|
208 | 208 | } |
209 | 209 | |
210 | - $contents[$facility]->add( $item->toArray() ); |
|
210 | + $contents[$facility]->add($item->toArray()); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | $ids[] = $id; |
214 | 214 | } |
215 | 215 | |
216 | - $manager->deleteItems( $ids ); |
|
216 | + $manager->deleteItems($ids); |
|
217 | 217 | |
218 | - $count = count( $items ); |
|
218 | + $count = count($items); |
|
219 | 219 | $start += $count; |
220 | - $search->setSlice( $start ); |
|
220 | + $search->setSlice($start); |
|
221 | 221 | } |
222 | - while( $count >= $search->getSliceSize() ); |
|
222 | + while ($count >= $search->getSliceSize()); |
|
223 | 223 | |
224 | 224 | |
225 | - if( $container !== null && !empty( $contents ) ) |
|
225 | + if ($container !== null && !empty($contents)) |
|
226 | 226 | { |
227 | - foreach( $contents as $content ) { |
|
228 | - $container->add( $content ); |
|
227 | + foreach ($contents as $content) { |
|
228 | + $container->add($content); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | $container->close(); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function getName() |
30 | 30 | { |
31 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Coupon code import CSV' ); |
|
31 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Coupon code import CSV'); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function getDescription() |
41 | 41 | { |
42 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Imports new and updates existing coupon code from CSV files' ); |
|
42 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Imports new and updates existing coupon code from CSV files'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @see controller/jobs/coupon/import/csv/code/skip-lines |
72 | 72 | * @see controller/jobs/coupon/import/csv/code/max-size |
73 | 73 | */ |
74 | - $mappings = $config->get( 'controller/jobs/coupon/import/csv/code/mapping', $mappings ); |
|
74 | + $mappings = $config->get('controller/jobs/coupon/import/csv/code/mapping', $mappings); |
|
75 | 75 | |
76 | 76 | |
77 | 77 | /** controller/jobs/coupon/import/csv/code/max-size |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @see controller/jobs/coupon/import/csv/code/skip-lines |
91 | 91 | * @see controller/jobs/coupon/import/csv/code/mapping |
92 | 92 | */ |
93 | - $maxcnt = (int) $config->get( 'controller/jobs/coupon/import/csv/code/max-size', 1000 ); |
|
93 | + $maxcnt = (int) $config->get('controller/jobs/coupon/import/csv/code/max-size', 1000); |
|
94 | 94 | |
95 | 95 | |
96 | 96 | /** controller/jobs/coupon/import/csv/code/skip-lines |
@@ -108,64 +108,64 @@ discard block |
||
108 | 108 | * @see controller/jobs/coupon/import/csv/code/mapping |
109 | 109 | * @see controller/jobs/coupon/import/csv/code/max-size |
110 | 110 | */ |
111 | - $skiplines = (int) $config->get( 'controller/jobs/coupon/import/csv/code/skip-lines', 0 ); |
|
111 | + $skiplines = (int) $config->get('controller/jobs/coupon/import/csv/code/skip-lines', 0); |
|
112 | 112 | |
113 | 113 | |
114 | 114 | try |
115 | 115 | { |
116 | - $processor = $this->getProcessors( $mappings ); |
|
117 | - $codePos = $this->getCodePosition( $mappings['code'] ); |
|
118 | - $fs = $context->getFileSystemManager()->get( 'fs-import' ); |
|
116 | + $processor = $this->getProcessors($mappings); |
|
117 | + $codePos = $this->getCodePosition($mappings['code']); |
|
118 | + $fs = $context->getFileSystemManager()->get('fs-import'); |
|
119 | 119 | $dir = 'couponcode/' . $context->getLocale()->getSite()->getCode(); |
120 | 120 | |
121 | - if( $fs->isDir( $dir ) === false ) { |
|
121 | + if ($fs->isDir($dir) === false) { |
|
122 | 122 | return; |
123 | 123 | } |
124 | 124 | |
125 | - foreach( $fs->scan( $dir ) as $filename ) |
|
125 | + foreach ($fs->scan($dir) as $filename) |
|
126 | 126 | { |
127 | - if( $filename == '.' || $filename == '..' ) { |
|
127 | + if ($filename == '.' || $filename == '..') { |
|
128 | 128 | continue; |
129 | 129 | } |
130 | 130 | |
131 | - list( $couponId, ) = explode( '.', $filename ); |
|
132 | - $container = $this->getContainer( $fs->readf( $dir . '/' . $filename ) ); |
|
131 | + list($couponId,) = explode('.', $filename); |
|
132 | + $container = $this->getContainer($fs->readf($dir . '/' . $filename)); |
|
133 | 133 | |
134 | - $msg = sprintf( 'Started coupon import from "%1$s" (%2$s)', $filename, __CLASS__ ); |
|
135 | - $logger->log( $msg, \Aimeos\MW\Logger\Base::NOTICE ); |
|
134 | + $msg = sprintf('Started coupon import from "%1$s" (%2$s)', $filename, __CLASS__); |
|
135 | + $logger->log($msg, \Aimeos\MW\Logger\Base::NOTICE); |
|
136 | 136 | |
137 | - foreach( $container as $content ) |
|
137 | + foreach ($container as $content) |
|
138 | 138 | { |
139 | - for( $i = 0; $i < $skiplines; $i++ ) { |
|
139 | + for ($i = 0; $i < $skiplines; $i++) { |
|
140 | 140 | $content->next(); |
141 | 141 | } |
142 | 142 | |
143 | - while( ( $data = $this->getData( $content, $maxcnt, $codePos ) ) !== [] ) |
|
143 | + while (($data = $this->getData($content, $maxcnt, $codePos)) !== []) |
|
144 | 144 | { |
145 | - $items = $this->getCouponCodeItems( array_keys( $data ) ); |
|
146 | - $errcnt = $this->import( $items, $data, $couponId, $processor ); |
|
147 | - $chunkcnt = count( $data ); |
|
145 | + $items = $this->getCouponCodeItems(array_keys($data)); |
|
146 | + $errcnt = $this->import($items, $data, $couponId, $processor); |
|
147 | + $chunkcnt = count($data); |
|
148 | 148 | |
149 | 149 | $msg = 'Imported coupon lines from "%1$s": %2$d/%3$d (%4$s)'; |
150 | - $logger->log( sprintf( $msg, $filename, $chunkcnt - $errcnt, $chunkcnt, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE ); |
|
150 | + $logger->log(sprintf($msg, $filename, $chunkcnt - $errcnt, $chunkcnt, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE); |
|
151 | 151 | |
152 | 152 | $errors += $errcnt; |
153 | 153 | $total += $chunkcnt; |
154 | - unset( $items, $data ); |
|
154 | + unset($items, $data); |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
158 | 158 | $container->close(); |
159 | - $fs->rm( $dir . '/' . $filename ); |
|
159 | + $fs->rm($dir . '/' . $filename); |
|
160 | 160 | |
161 | 161 | $msg = 'Finished coupon import: %1$d successful, %2$s errors, %3$s total (%4$s)'; |
162 | - $logger->log( sprintf( $msg, $total - $errors, $errors, $total, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE ); |
|
162 | + $logger->log(sprintf($msg, $total - $errors, $errors, $total, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE); |
|
163 | 163 | } |
164 | 164 | } |
165 | - catch( \Exception $e ) |
|
165 | + catch (\Exception $e) |
|
166 | 166 | { |
167 | - $logger->log( 'Coupon import error: ' . $e->getMessage() ); |
|
168 | - $logger->log( $e->getTraceAsString() ); |
|
167 | + $logger->log('Coupon import error: ' . $e->getMessage()); |
|
168 | + $logger->log($e->getTraceAsString()); |
|
169 | 169 | |
170 | 170 | throw $e; |
171 | 171 | } |
@@ -179,16 +179,16 @@ discard block |
||
179 | 179 | * @return integer Position of the "coupon.code" column |
180 | 180 | * @throws \Aimeos\Controller\Jobs\Exception If no mapping for "coupon.code.code" is found |
181 | 181 | */ |
182 | - protected function getCodePosition( array $mapping ) |
|
182 | + protected function getCodePosition(array $mapping) |
|
183 | 183 | { |
184 | - foreach( $mapping as $pos => $key ) |
|
184 | + foreach ($mapping as $pos => $key) |
|
185 | 185 | { |
186 | - if( $key === 'coupon.code.code' ) { |
|
186 | + if ($key === 'coupon.code.code') { |
|
187 | 187 | return $pos; |
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No "coupon.code.code" column in CSV mapping found' ) ); |
|
191 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('No "coupon.code.code" column in CSV mapping found')); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @param string $filepath Path to the container file |
199 | 199 | * @return \Aimeos\MW\Container\Iface Container object |
200 | 200 | */ |
201 | - protected function getContainer( $filepath ) |
|
201 | + protected function getContainer($filepath) |
|
202 | 202 | { |
203 | 203 | $config = $this->getContext()->getConfig(); |
204 | 204 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @see controller/jobs/coupon/import/csv/code/container/content |
223 | 223 | * @see controller/jobs/coupon/import/csv/code/container/options |
224 | 224 | */ |
225 | - $container = $config->get( 'controller/jobs/coupon/import/csv/code/container/type', 'File' ); |
|
225 | + $container = $config->get('controller/jobs/coupon/import/csv/code/container/type', 'File'); |
|
226 | 226 | |
227 | 227 | /** controller/jobs/coupon/import/csv/code/container/content |
228 | 228 | * Name of the content type inside the container to read the data from |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @see controller/jobs/coupon/import/csv/code/container/type |
243 | 243 | * @see controller/jobs/coupon/import/csv/code/container/options |
244 | 244 | */ |
245 | - $content = $config->get( 'controller/jobs/coupon/import/csv/code/container/content', 'CSV' ); |
|
245 | + $content = $config->get('controller/jobs/coupon/import/csv/code/container/content', 'CSV'); |
|
246 | 246 | |
247 | 247 | /** controller/jobs/coupon/import/csv/code/container/options |
248 | 248 | * List of file container options for the coupon import files |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | * @see controller/jobs/coupon/import/csv/code/container/content |
260 | 260 | * @see controller/jobs/coupon/import/csv/code/container/type |
261 | 261 | */ |
262 | - $options = $config->get( 'controller/jobs/coupon/import/csv/code/container/options', [] ); |
|
262 | + $options = $config->get('controller/jobs/coupon/import/csv/code/container/options', []); |
|
263 | 263 | |
264 | - return \Aimeos\MW\Container\Factory::getContainer( $filepath, $container, $content, $options ); |
|
264 | + return \Aimeos\MW\Container\Factory::getContainer($filepath, $container, $content, $options); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | |
@@ -275,36 +275,36 @@ discard block |
||
275 | 275 | * @return integer Number of coupons that couldn't be imported |
276 | 276 | * @throws \Aimeos\Controller\Jobs\Exception |
277 | 277 | */ |
278 | - protected function import( array $items, array $data, $couponId, |
|
279 | - \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $processor ) |
|
278 | + protected function import(array $items, array $data, $couponId, |
|
279 | + \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $processor) |
|
280 | 280 | { |
281 | 281 | $errors = 0; |
282 | 282 | $context = $this->getContext(); |
283 | - $manager = \Aimeos\MShop::create( $context, 'coupon/code' ); |
|
283 | + $manager = \Aimeos\MShop::create($context, 'coupon/code'); |
|
284 | 284 | |
285 | - foreach( $data as $code => $list ) |
|
285 | + foreach ($data as $code => $list) |
|
286 | 286 | { |
287 | 287 | $manager->begin(); |
288 | 288 | |
289 | 289 | try |
290 | 290 | { |
291 | - if( isset( $items[$code] ) ) { |
|
291 | + if (isset($items[$code])) { |
|
292 | 292 | $item = $items[$code]; |
293 | 293 | } else { |
294 | 294 | $item = $manager->createItem(); |
295 | 295 | } |
296 | 296 | |
297 | - $item->setParentId( $couponId ); |
|
298 | - $list = $processor->process( $item, $list ); |
|
297 | + $item->setParentId($couponId); |
|
298 | + $list = $processor->process($item, $list); |
|
299 | 299 | |
300 | 300 | $manager->commit(); |
301 | 301 | } |
302 | - catch( \Exception $e ) |
|
302 | + catch (\Exception $e) |
|
303 | 303 | { |
304 | 304 | $manager->rollback(); |
305 | 305 | |
306 | - $msg = sprintf( 'Unable to import coupon with code "%1$s": %2$s', $code, $e->getMessage() ); |
|
307 | - $context->getLogger()->log( $msg ); |
|
306 | + $msg = sprintf('Unable to import coupon with code "%1$s": %2$s', $code, $e->getMessage()); |
|
307 | + $context->getLogger()->log($msg); |
|
308 | 308 | |
309 | 309 | $errors++; |
310 | 310 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function getName() |
30 | 30 | { |
31 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Catalog import CSV' ); |
|
31 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Catalog import CSV'); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function getDescription() |
41 | 41 | { |
42 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Imports new and updates existing categories from CSV files' ); |
|
42 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Imports new and updates existing categories from CSV files'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $context = $this->getContext(); |
55 | 55 | $config = $context->getConfig(); |
56 | 56 | $logger = $context->getLogger(); |
57 | - $domains = array( 'media', 'text' ); |
|
57 | + $domains = array('media', 'text'); |
|
58 | 58 | $mappings = $this->getDefaultMapping(); |
59 | 59 | |
60 | 60 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @see controller/common/catalog/import/csv/converter |
75 | 75 | * @see controller/common/catalog/import/csv/max-size |
76 | 76 | */ |
77 | - $domains = $config->get( 'controller/common/catalog/import/csv/domains', $domains ); |
|
77 | + $domains = $config->get('controller/common/catalog/import/csv/domains', $domains); |
|
78 | 78 | |
79 | 79 | /** controller/jobs/catalog/import/csv/domains |
80 | 80 | * List of item domain names that should be retrieved along with the catalog items |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @see controller/jobs/catalog/import/csv/backup |
95 | 95 | * @see controller/common/catalog/import/csv/max-size |
96 | 96 | */ |
97 | - $domains = $config->get( 'controller/jobs/catalog/import/csv/domains', $domains ); |
|
97 | + $domains = $config->get('controller/jobs/catalog/import/csv/domains', $domains); |
|
98 | 98 | |
99 | 99 | |
100 | 100 | /** controller/common/catalog/import/csv/mapping |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @see controller/common/catalog/import/csv/converter |
120 | 120 | * @see controller/common/catalog/import/csv/max-size |
121 | 121 | */ |
122 | - $mappings = $config->get( 'controller/common/catalog/import/csv/mapping', $mappings ); |
|
122 | + $mappings = $config->get('controller/common/catalog/import/csv/mapping', $mappings); |
|
123 | 123 | |
124 | 124 | /** controller/jobs/catalog/import/csv/mapping |
125 | 125 | * List of mappings between the position in the CSV file and item keys |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @see controller/jobs/catalog/import/csv/backup |
140 | 140 | * @see controller/common/catalog/import/csv/max-size |
141 | 141 | */ |
142 | - $mappings = $config->get( 'controller/jobs/catalog/import/csv/mapping', $mappings ); |
|
142 | + $mappings = $config->get('controller/jobs/catalog/import/csv/mapping', $mappings); |
|
143 | 143 | |
144 | 144 | |
145 | 145 | /** controller/common/catalog/import/csv/converter |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @see controller/common/catalog/import/csv/mapping |
182 | 182 | * @see controller/common/catalog/import/csv/max-size |
183 | 183 | */ |
184 | - $converters = $config->get( 'controller/common/catalog/import/csv/converter', [] ); |
|
184 | + $converters = $config->get('controller/common/catalog/import/csv/converter', []); |
|
185 | 185 | |
186 | 186 | /** controller/jobs/catalog/import/csv/converter |
187 | 187 | * List of converter names for the values at the position in the CSV file |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * @see controller/jobs/catalog/import/csv/backup |
202 | 202 | * @see controller/common/catalog/import/csv/max-size |
203 | 203 | */ |
204 | - $converters = $config->get( 'controller/jobs/catalog/import/csv/converter', $converters ); |
|
204 | + $converters = $config->get('controller/jobs/catalog/import/csv/converter', $converters); |
|
205 | 205 | |
206 | 206 | |
207 | 207 | /** controller/common/catalog/import/csv/max-size |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @see controller/common/catalog/import/csv/mapping |
222 | 222 | * @see controller/common/catalog/import/csv/converter |
223 | 223 | */ |
224 | - $maxcnt = (int) $config->get( 'controller/common/catalog/import/csv/max-size', 1000 ); |
|
224 | + $maxcnt = (int) $config->get('controller/common/catalog/import/csv/max-size', 1000); |
|
225 | 225 | |
226 | 226 | |
227 | 227 | /** controller/jobs/catalog/import/csv/skip-lines |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @see controller/jobs/catalog/import/csv/backup |
244 | 244 | * @see controller/common/catalog/import/csv/max-size |
245 | 245 | */ |
246 | - $skiplines = (int) $config->get( 'controller/jobs/catalog/import/csv/skip-lines', 0 ); |
|
246 | + $skiplines = (int) $config->get('controller/jobs/catalog/import/csv/skip-lines', 0); |
|
247 | 247 | |
248 | 248 | |
249 | 249 | /** controller/jobs/catalog/import/csv/strict |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @see controller/jobs/catalog/import/csv/backup |
268 | 268 | * @see controller/common/catalog/import/csv/max-size |
269 | 269 | */ |
270 | - $strict = (bool) $config->get( 'controller/jobs/catalog/import/csv/strict', true ); |
|
270 | + $strict = (bool) $config->get('controller/jobs/catalog/import/csv/strict', true); |
|
271 | 271 | |
272 | 272 | |
273 | 273 | /** controller/jobs/catalog/import/csv/backup |
@@ -300,75 +300,75 @@ discard block |
||
300 | 300 | * @see controller/jobs/catalog/import/csv/strict |
301 | 301 | * @see controller/common/catalog/import/csv/max-size |
302 | 302 | */ |
303 | - $backup = $config->get( 'controller/jobs/catalog/import/csv/backup' ); |
|
303 | + $backup = $config->get('controller/jobs/catalog/import/csv/backup'); |
|
304 | 304 | |
305 | 305 | |
306 | - if( !isset( $mappings['item'] ) || !is_array( $mappings['item'] ) ) |
|
306 | + if (!isset($mappings['item']) || !is_array($mappings['item'])) |
|
307 | 307 | { |
308 | - $msg = sprintf( 'Required mapping key "%1$s" is missing or contains no array', 'item' ); |
|
309 | - throw new \Aimeos\Controller\Jobs\Exception( $msg ); |
|
308 | + $msg = sprintf('Required mapping key "%1$s" is missing or contains no array', 'item'); |
|
309 | + throw new \Aimeos\Controller\Jobs\Exception($msg); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | try |
313 | 313 | { |
314 | 314 | $procMappings = $mappings; |
315 | - unset( $procMappings['item'] ); |
|
315 | + unset($procMappings['item']); |
|
316 | 316 | |
317 | - $codePos = $this->getCodePosition( $mappings['item'] ); |
|
318 | - $convlist = $this->getConverterList( $converters ); |
|
319 | - $processor = $this->getProcessors( $procMappings ); |
|
320 | - $catalogMap = $this->getCatalogMap( $domains ); |
|
317 | + $codePos = $this->getCodePosition($mappings['item']); |
|
318 | + $convlist = $this->getConverterList($converters); |
|
319 | + $processor = $this->getProcessors($procMappings); |
|
320 | + $catalogMap = $this->getCatalogMap($domains); |
|
321 | 321 | $container = $this->getContainer(); |
322 | 322 | $path = $container->getName(); |
323 | 323 | |
324 | 324 | |
325 | - $msg = sprintf( 'Started catalog import from "%1$s" (%2$s)', $path, __CLASS__ ); |
|
326 | - $logger->log( $msg, \Aimeos\MW\Logger\Base::NOTICE ); |
|
325 | + $msg = sprintf('Started catalog import from "%1$s" (%2$s)', $path, __CLASS__); |
|
326 | + $logger->log($msg, \Aimeos\MW\Logger\Base::NOTICE); |
|
327 | 327 | |
328 | - foreach( $container as $content ) |
|
328 | + foreach ($container as $content) |
|
329 | 329 | { |
330 | 330 | $name = $content->getName(); |
331 | 331 | |
332 | - for( $i = 0; $i < $skiplines; $i++ ) { |
|
332 | + for ($i = 0; $i < $skiplines; $i++) { |
|
333 | 333 | $content->next(); |
334 | 334 | } |
335 | 335 | |
336 | - while( ( $data = $this->getData( $content, $maxcnt, $codePos ) ) !== [] ) |
|
336 | + while (($data = $this->getData($content, $maxcnt, $codePos)) !== []) |
|
337 | 337 | { |
338 | - $data = $this->convertData( $convlist, $data ); |
|
339 | - $errcnt = $this->import( $catalogMap, $data, $mappings['item'], $processor, $strict ); |
|
340 | - $chunkcnt = count( $data ); |
|
338 | + $data = $this->convertData($convlist, $data); |
|
339 | + $errcnt = $this->import($catalogMap, $data, $mappings['item'], $processor, $strict); |
|
340 | + $chunkcnt = count($data); |
|
341 | 341 | |
342 | 342 | $msg = 'Imported catalog lines from "%1$s": %2$d/%3$d (%4$s)'; |
343 | - $logger->log( sprintf( $msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE ); |
|
343 | + $logger->log(sprintf($msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE); |
|
344 | 344 | |
345 | 345 | $errors += $errcnt; |
346 | 346 | $total += $chunkcnt; |
347 | - unset( $data ); |
|
347 | + unset($data); |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | |
351 | 351 | $container->close(); |
352 | 352 | } |
353 | - catch( \Exception $e ) |
|
353 | + catch (\Exception $e) |
|
354 | 354 | { |
355 | - $logger->log( 'Catalog import error: ' . $e->getMessage() ); |
|
356 | - $logger->log( $e->getTraceAsString() ); |
|
355 | + $logger->log('Catalog import error: ' . $e->getMessage()); |
|
356 | + $logger->log($e->getTraceAsString()); |
|
357 | 357 | |
358 | - throw new \Aimeos\Controller\Jobs\Exception( $e->getMessage() ); |
|
358 | + throw new \Aimeos\Controller\Jobs\Exception($e->getMessage()); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | $msg = 'Finished catalog import from "%1$s": %2$d successful, %3$s errors, %4$s total (%5$s)'; |
362 | - $logger->log( sprintf( $msg, $path, $total - $errors, $errors, $total, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE ); |
|
362 | + $logger->log(sprintf($msg, $path, $total - $errors, $errors, $total, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE); |
|
363 | 363 | |
364 | - if( $errors > 0 ) |
|
364 | + if ($errors > 0) |
|
365 | 365 | { |
366 | - $msg = sprintf( 'Invalid catalog lines in "%1$s": %2$d/%3$d', $path, $errors, $total ); |
|
367 | - throw new \Aimeos\Controller\Jobs\Exception( $msg ); |
|
366 | + $msg = sprintf('Invalid catalog lines in "%1$s": %2$d/%3$d', $path, $errors, $total); |
|
367 | + throw new \Aimeos\Controller\Jobs\Exception($msg); |
|
368 | 368 | } |
369 | 369 | |
370 | - if( !empty( $backup ) && @rename( $path, strftime( $backup ) ) === false ) { |
|
371 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Unable to move imported file' ) ); |
|
370 | + if (!empty($backup) && @rename($path, strftime($backup)) === false) { |
|
371 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Unable to move imported file')); |
|
372 | 372 | } |
373 | 373 | } |
374 | 374 | |
@@ -380,16 +380,16 @@ discard block |
||
380 | 380 | * @return integer Position of the "catalog.code" column |
381 | 381 | * @throws \Aimeos\Controller\Jobs\Exception If no mapping for "catalog.code" is found |
382 | 382 | */ |
383 | - protected function getCodePosition( array $mapping ) |
|
383 | + protected function getCodePosition(array $mapping) |
|
384 | 384 | { |
385 | - foreach( $mapping as $pos => $key ) |
|
385 | + foreach ($mapping as $pos => $key) |
|
386 | 386 | { |
387 | - if( $key === 'catalog.code' ) { |
|
387 | + if ($key === 'catalog.code') { |
|
388 | 388 | return $pos; |
389 | 389 | } |
390 | 390 | } |
391 | 391 | |
392 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No "catalog.code" column in CSV mapping found' ) ); |
|
392 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('No "catalog.code" column in CSV mapping found')); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @see controller/jobs/catalog/import/csv/container/content |
425 | 425 | * @see controller/jobs/catalog/import/csv/container/options |
426 | 426 | */ |
427 | - $location = $config->get( 'controller/jobs/catalog/import/csv/location' ); |
|
427 | + $location = $config->get('controller/jobs/catalog/import/csv/location'); |
|
428 | 428 | |
429 | 429 | /** controller/jobs/catalog/import/csv/container/type |
430 | 430 | * Nave of the container type to read the data from |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | * @see controller/jobs/catalog/import/csv/container/content |
448 | 448 | * @see controller/jobs/catalog/import/csv/container/options |
449 | 449 | */ |
450 | - $container = $config->get( 'controller/jobs/catalog/import/csv/container/type', 'Directory' ); |
|
450 | + $container = $config->get('controller/jobs/catalog/import/csv/container/type', 'Directory'); |
|
451 | 451 | |
452 | 452 | /** controller/jobs/catalog/import/csv/container/content |
453 | 453 | * Name of the content type inside the container to read the data from |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | * @see controller/jobs/catalog/import/csv/container/type |
469 | 469 | * @see controller/jobs/catalog/import/csv/container/options |
470 | 470 | */ |
471 | - $content = $config->get( 'controller/jobs/catalog/import/csv/container/content', 'CSV' ); |
|
471 | + $content = $config->get('controller/jobs/catalog/import/csv/container/content', 'CSV'); |
|
472 | 472 | |
473 | 473 | /** controller/jobs/catalog/import/csv/container/options |
474 | 474 | * List of file container options for the catalog import files |
@@ -486,15 +486,15 @@ discard block |
||
486 | 486 | * @see controller/jobs/catalog/import/csv/container/content |
487 | 487 | * @see controller/jobs/catalog/import/csv/container/type |
488 | 488 | */ |
489 | - $options = $config->get( 'controller/jobs/catalog/import/csv/container/options', [] ); |
|
489 | + $options = $config->get('controller/jobs/catalog/import/csv/container/options', []); |
|
490 | 490 | |
491 | - if( $location === null ) |
|
491 | + if ($location === null) |
|
492 | 492 | { |
493 | - $msg = sprintf( 'Required configuration for "%1$s" is missing', 'controller/jobs/catalog/import/csv/location' ); |
|
494 | - throw new \Aimeos\Controller\Jobs\Exception( $msg ); |
|
493 | + $msg = sprintf('Required configuration for "%1$s" is missing', 'controller/jobs/catalog/import/csv/location'); |
|
494 | + throw new \Aimeos\Controller\Jobs\Exception($msg); |
|
495 | 495 | } |
496 | 496 | |
497 | - return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options ); |
|
497 | + return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | |
@@ -504,13 +504,13 @@ discard block |
||
504 | 504 | * @param array $domains List of domain names whose items should be fetched too |
505 | 505 | * @return array Associative list of catalog codes as keys and items implementing \Aimeos\MShop\Catalog\Item\Iface as values |
506 | 506 | */ |
507 | - protected function getCatalogMap( array $domains ) |
|
507 | + protected function getCatalogMap(array $domains) |
|
508 | 508 | { |
509 | 509 | $map = []; |
510 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'catalog' ); |
|
511 | - $search = $manager->createSearch()->setSlice( 0, 0x7fffffff ); |
|
510 | + $manager = \Aimeos\MShop::create($this->getContext(), 'catalog'); |
|
511 | + $search = $manager->createSearch()->setSlice(0, 0x7fffffff); |
|
512 | 512 | |
513 | - foreach( $manager->searchItems( $search, $domains ) as $item ) { |
|
513 | + foreach ($manager->searchItems($search, $domains) as $item) { |
|
514 | 514 | $map[$item->getCode()] = $item; |
515 | 515 | } |
516 | 516 | |
@@ -526,23 +526,23 @@ discard block |
||
526 | 526 | * @param string $code Catalog item code of the parent category |
527 | 527 | * @return string|null ID of the parent category or null for top level nodes |
528 | 528 | */ |
529 | - protected function getParentId( array $catalogMap, array $map, $code ) |
|
529 | + protected function getParentId(array $catalogMap, array $map, $code) |
|
530 | 530 | { |
531 | - if( !isset( $map['catalog.parent'] ) ) |
|
531 | + if (!isset($map['catalog.parent'])) |
|
532 | 532 | { |
533 | - $msg = sprintf( 'Required column "%1$s" not found for code "%2$s"', 'catalog.parent', $code ); |
|
534 | - throw new \Aimeos\Controller\Jobs\Exception( $msg ); |
|
533 | + $msg = sprintf('Required column "%1$s" not found for code "%2$s"', 'catalog.parent', $code); |
|
534 | + throw new \Aimeos\Controller\Jobs\Exception($msg); |
|
535 | 535 | } |
536 | 536 | |
537 | - $parent = trim( $map['catalog.parent'] ); |
|
537 | + $parent = trim($map['catalog.parent']); |
|
538 | 538 | |
539 | - if( $parent != '' && !isset( $catalogMap[$parent] ) ) |
|
539 | + if ($parent != '' && !isset($catalogMap[$parent])) |
|
540 | 540 | { |
541 | - $msg = sprintf( 'Parent node for code "%1$s" not found', $parent ); |
|
542 | - throw new \Aimeos\Controller\Jobs\Exception( $msg ); |
|
541 | + $msg = sprintf('Parent node for code "%1$s" not found', $parent); |
|
542 | + throw new \Aimeos\Controller\Jobs\Exception($msg); |
|
543 | 543 | } |
544 | 544 | |
545 | - return ( $parent != '' ? $catalogMap[$parent]->getId() : null ); |
|
545 | + return ($parent != '' ? $catalogMap[$parent]->getId() : null); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | |
@@ -557,65 +557,65 @@ discard block |
||
557 | 557 | * @return integer Number of catalogs that couldn't be imported |
558 | 558 | * @throws \Aimeos\Controller\Jobs\Exception |
559 | 559 | */ |
560 | - protected function import( array &$catalogMap, array $data, array $mapping, |
|
561 | - \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $processor, $strict ) |
|
560 | + protected function import(array &$catalogMap, array $data, array $mapping, |
|
561 | + \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $processor, $strict) |
|
562 | 562 | { |
563 | 563 | $errors = 0; |
564 | 564 | $context = $this->getContext(); |
565 | - $manager = \Aimeos\MShop::create( $context, 'catalog' ); |
|
565 | + $manager = \Aimeos\MShop::create($context, 'catalog'); |
|
566 | 566 | |
567 | - foreach( $data as $code => $list ) |
|
567 | + foreach ($data as $code => $list) |
|
568 | 568 | { |
569 | 569 | $manager->begin(); |
570 | 570 | |
571 | 571 | try |
572 | 572 | { |
573 | - $code = trim( $code ); |
|
573 | + $code = trim($code); |
|
574 | 574 | |
575 | - if( isset( $catalogMap[$code] ) ) { |
|
575 | + if (isset($catalogMap[$code])) { |
|
576 | 576 | $item = $catalogMap[$code]; |
577 | 577 | } else { |
578 | 578 | $item = $manager->createItem(); |
579 | 579 | } |
580 | 580 | |
581 | - $map = $this->getMappedChunk( $list, $mapping ); |
|
581 | + $map = $this->getMappedChunk($list, $mapping); |
|
582 | 582 | |
583 | - if( isset( $map[0] ) ) |
|
583 | + if (isset($map[0])) |
|
584 | 584 | { |
585 | 585 | $map = $map[0]; // there can only be one chunk for the base catalog data |
586 | - $parentid = $this->getParentId( $catalogMap, $map, $code ); |
|
587 | - $item->fromArray( $map ); |
|
586 | + $parentid = $this->getParentId($catalogMap, $map, $code); |
|
587 | + $item->fromArray($map); |
|
588 | 588 | |
589 | - if( isset( $catalogMap[$code] ) ) |
|
589 | + if (isset($catalogMap[$code])) |
|
590 | 590 | { |
591 | - $manager->moveItem( $item->getId(), $item->getParentId(), $parentid ); |
|
592 | - $item = $manager->saveItem( $item ); |
|
591 | + $manager->moveItem($item->getId(), $item->getParentId(), $parentid); |
|
592 | + $item = $manager->saveItem($item); |
|
593 | 593 | } |
594 | 594 | else |
595 | 595 | { |
596 | - $item = $manager->insertItem( $item, $parentid ); |
|
596 | + $item = $manager->insertItem($item, $parentid); |
|
597 | 597 | } |
598 | 598 | |
599 | - $list = $processor->process( $item, $list ); |
|
599 | + $list = $processor->process($item, $list); |
|
600 | 600 | $catalogMap[$code] = $item; |
601 | 601 | |
602 | - $manager->saveItem( $item ); |
|
602 | + $manager->saveItem($item); |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | $manager->commit(); |
606 | 606 | } |
607 | - catch( \Exception $e ) |
|
607 | + catch (\Exception $e) |
|
608 | 608 | { |
609 | 609 | $manager->rollback(); |
610 | 610 | |
611 | - $msg = sprintf( 'Unable to import catalog with code "%1$s": %2$s', $code, $e->getMessage() ); |
|
612 | - $context->getLogger()->log( $msg ); |
|
611 | + $msg = sprintf('Unable to import catalog with code "%1$s": %2$s', $code, $e->getMessage()); |
|
612 | + $context->getLogger()->log($msg); |
|
613 | 613 | |
614 | 614 | $errors++; |
615 | 615 | } |
616 | 616 | |
617 | - if( $strict && !empty( $list ) ) { |
|
618 | - $context->getLogger()->log( 'Not imported: ' . print_r( $list, true ) ); |
|
617 | + if ($strict && !empty($list)) { |
|
618 | + $context->getLogger()->log('Not imported: ' . print_r($list, true)); |
|
619 | 619 | } |
620 | 620 | } |
621 | 621 |