@@ -33,11 +33,11 @@ discard block |
||
| 33 | 33 | * @param \Aimeos\MShop\Context\Item\Iface $context Object storing the required instances for manaing databases |
| 34 | 34 | * connections, logger, session, etc. |
| 35 | 35 | */ |
| 36 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 36 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 37 | 37 | { |
| 38 | - parent::__construct( $context ); |
|
| 38 | + parent::__construct($context); |
|
| 39 | 39 | |
| 40 | - $this->domainManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
| 40 | + $this->domainManager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | public function clear() |
| 50 | 50 | { |
| 51 | 51 | $this->baskets[$this->type] = $this->domainManager->createItem(); |
| 52 | - $this->domainManager->setSession( $this->baskets[$this->type], $this->type ); |
|
| 52 | + $this->domainManager->setSession($this->baskets[$this->type], $this->type); |
|
| 53 | 53 | |
| 54 | 54 | return $this; |
| 55 | 55 | } |
@@ -62,10 +62,10 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function get() |
| 64 | 64 | { |
| 65 | - if( !isset( $this->baskets[$this->type] ) ) |
|
| 65 | + if (!isset($this->baskets[$this->type])) |
|
| 66 | 66 | { |
| 67 | - $this->baskets[$this->type] = $this->domainManager->getSession( $this->type ); |
|
| 68 | - $this->checkLocale( $this->type ); |
|
| 67 | + $this->baskets[$this->type] = $this->domainManager->getSession($this->type); |
|
| 68 | + $this->checkLocale($this->type); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | return $this->baskets[$this->type]; |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public function save() |
| 81 | 81 | { |
| 82 | - if( isset( $this->baskets[$this->type] ) && $this->baskets[$this->type]->isModified() ) { |
|
| 83 | - $this->domainManager->setSession( $this->baskets[$this->type], $this->type ); |
|
| 82 | + if (isset($this->baskets[$this->type]) && $this->baskets[$this->type]->isModified()) { |
|
| 83 | + $this->domainManager->setSession($this->baskets[$this->type], $this->type); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | return $this; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @param string $type Basket type |
| 94 | 94 | * @return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object |
| 95 | 95 | */ |
| 96 | - public function setType( $type ) |
|
| 96 | + public function setType($type) |
|
| 97 | 97 | { |
| 98 | 98 | $this->type = $type; |
| 99 | 99 | return $this; |
@@ -120,36 +120,36 @@ discard block |
||
| 120 | 120 | * @param string $stocktype Unique code of the stock type to deliver the products from |
| 121 | 121 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
| 122 | 122 | */ |
| 123 | - public function addProduct( $prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
| 123 | + public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
| 124 | 124 | array $configAttributeIds = array(), array $hiddenAttributeIds = array(), array $customAttributeValues = array(), |
| 125 | - $stocktype = 'default' ) |
|
| 125 | + $stocktype = 'default') |
|
| 126 | 126 | { |
| 127 | 127 | $context = $this->getContext(); |
| 128 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
| 129 | - $productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ) ); |
|
| 128 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
| 129 | + $productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text')); |
|
| 130 | 130 | |
| 131 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
| 132 | - $orderBaseProductItem->copyFrom( $productItem ); |
|
| 133 | - $orderBaseProductItem->setQuantity( $quantity ); |
|
| 134 | - $orderBaseProductItem->setStockType( $stocktype ); |
|
| 131 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
| 132 | + $orderBaseProductItem->copyFrom($productItem); |
|
| 133 | + $orderBaseProductItem->setQuantity($quantity); |
|
| 134 | + $orderBaseProductItem->setStockType($stocktype); |
|
| 135 | 135 | |
| 136 | 136 | $attr = array(); |
| 137 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
| 137 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
| 138 | 138 | |
| 139 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
| 140 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
| 139 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
| 140 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
| 141 | 141 | |
| 142 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $configAttributeIds, 'config' ) ); |
|
| 143 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $hiddenAttributeIds, 'hidden' ) ); |
|
| 144 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, array_keys( $customAttributeValues ), 'custom', $customAttributeValues ) ); |
|
| 142 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $configAttributeIds, 'config')); |
|
| 143 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $hiddenAttributeIds, 'hidden')); |
|
| 144 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, array_keys($customAttributeValues), 'custom', $customAttributeValues)); |
|
| 145 | 145 | |
| 146 | 146 | // remove product rebate of original price in favor to rebates granted for the order |
| 147 | - $price->setRebate( '0.00' ); |
|
| 147 | + $price->setRebate('0.00'); |
|
| 148 | 148 | |
| 149 | - $orderBaseProductItem->setPrice( $price ); |
|
| 150 | - $orderBaseProductItem->setAttributes( $attr ); |
|
| 149 | + $orderBaseProductItem->setPrice($price); |
|
| 150 | + $orderBaseProductItem->setAttributes($attr); |
|
| 151 | 151 | |
| 152 | - $this->get()->addProduct( $orderBaseProductItem ); |
|
| 152 | + $this->get()->addProduct($orderBaseProductItem); |
|
| 153 | 153 | $this->save(); |
| 154 | 154 | } |
| 155 | 155 | |
@@ -159,17 +159,17 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @param integer $position Position number (key) of the order product item |
| 161 | 161 | */ |
| 162 | - public function deleteProduct( $position ) |
|
| 162 | + public function deleteProduct($position) |
|
| 163 | 163 | { |
| 164 | - $product = $this->get()->getProduct( $position ); |
|
| 164 | + $product = $this->get()->getProduct($position); |
|
| 165 | 165 | |
| 166 | - if( $product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
| 166 | + if ($product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
| 167 | 167 | { |
| 168 | - $msg = sprintf( 'Basket item at position "%1$d" cannot be deleted manually', $position ); |
|
| 169 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 168 | + $msg = sprintf('Basket item at position "%1$d" cannot be deleted manually', $position); |
|
| 169 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - $this->get()->deleteProduct( $position ); |
|
| 172 | + $this->get()->deleteProduct($position); |
|
| 173 | 173 | $this->save(); |
| 174 | 174 | } |
| 175 | 175 | |
@@ -183,34 +183,34 @@ discard block |
||
| 183 | 183 | * The 'stock'=>false option allows adding products without being in stock. |
| 184 | 184 | * @param string[] $configAttributeCodes Codes of the product config attributes that should be REMOVED |
| 185 | 185 | */ |
| 186 | - public function editProduct( $position, $quantity, array $options = array(), |
|
| 187 | - array $configAttributeCodes = array() ) |
|
| 186 | + public function editProduct($position, $quantity, array $options = array(), |
|
| 187 | + array $configAttributeCodes = array()) |
|
| 188 | 188 | { |
| 189 | - $product = $this->get()->getProduct( $position ); |
|
| 189 | + $product = $this->get()->getProduct($position); |
|
| 190 | 190 | |
| 191 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
| 191 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
| 192 | 192 | { |
| 193 | - $msg = sprintf( 'Basket item at position "%1$d" cannot be changed', $position ); |
|
| 194 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 193 | + $msg = sprintf('Basket item at position "%1$d" cannot be changed', $position); |
|
| 194 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - $product->setQuantity( $quantity ); |
|
| 197 | + $product->setQuantity($quantity); |
|
| 198 | 198 | |
| 199 | 199 | $attributes = $product->getAttributes(); |
| 200 | - foreach( $attributes as $key => $attribute ) |
|
| 200 | + foreach ($attributes as $key => $attribute) |
|
| 201 | 201 | { |
| 202 | - if( in_array( $attribute->getCode(), $configAttributeCodes ) ) { |
|
| 203 | - unset( $attributes[$key] ); |
|
| 202 | + if (in_array($attribute->getCode(), $configAttributeCodes)) { |
|
| 203 | + unset($attributes[$key]); |
|
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | - $product->setAttributes( $attributes ); |
|
| 206 | + $product->setAttributes($attributes); |
|
| 207 | 207 | |
| 208 | - $productItem = $this->getDomainItem( 'product', 'product.code', $product->getProductCode(), array( 'price', 'text' ) ); |
|
| 209 | - $prices = $productItem->getRefItems( 'price', 'default' ); |
|
| 210 | - $product->setPrice( $this->calcPrice( $product, $prices, $quantity ) ); |
|
| 208 | + $productItem = $this->getDomainItem('product', 'product.code', $product->getProductCode(), array('price', 'text')); |
|
| 209 | + $prices = $productItem->getRefItems('price', 'default'); |
|
| 210 | + $product->setPrice($this->calcPrice($product, $prices, $quantity)); |
|
| 211 | 211 | |
| 212 | - $this->get()->deleteProduct( $position ); |
|
| 213 | - $this->get()->addProduct( $product, $position ); |
|
| 212 | + $this->get()->deleteProduct($position); |
|
| 213 | + $this->get()->addProduct($product, $position); |
|
| 214 | 214 | |
| 215 | 215 | $this->save(); |
| 216 | 216 | } |
@@ -222,49 +222,49 @@ discard block |
||
| 222 | 222 | * @param string $code Coupon code entered by the user |
| 223 | 223 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
| 224 | 224 | */ |
| 225 | - public function addCoupon( $code ) |
|
| 225 | + public function addCoupon($code) |
|
| 226 | 226 | { |
| 227 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
| 228 | - $codeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon/code' ); |
|
| 227 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
| 228 | + $codeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon/code'); |
|
| 229 | 229 | |
| 230 | 230 | |
| 231 | - $search = $codeManager->createSearch( true ); |
|
| 231 | + $search = $codeManager->createSearch(true); |
|
| 232 | 232 | $expr = array( |
| 233 | - $search->compare( '==', 'coupon.code.code', $code ), |
|
| 233 | + $search->compare('==', 'coupon.code.code', $code), |
|
| 234 | 234 | $search->getConditions(), |
| 235 | 235 | ); |
| 236 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 237 | - $search->setSlice( 0, 1 ); |
|
| 236 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 237 | + $search->setSlice(0, 1); |
|
| 238 | 238 | |
| 239 | - $result = $codeManager->searchItems( $search ); |
|
| 239 | + $result = $codeManager->searchItems($search); |
|
| 240 | 240 | |
| 241 | - if( ( $codeItem = reset( $result ) ) === false ) { |
|
| 242 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid or not available any more', $code ) ); |
|
| 241 | + if (($codeItem = reset($result)) === false) { |
|
| 242 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid or not available any more', $code)); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | |
| 246 | - $search = $manager->createSearch( true ); |
|
| 246 | + $search = $manager->createSearch(true); |
|
| 247 | 247 | $expr = array( |
| 248 | - $search->compare( '==', 'coupon.id', $codeItem->getParentId() ), |
|
| 248 | + $search->compare('==', 'coupon.id', $codeItem->getParentId()), |
|
| 249 | 249 | $search->getConditions(), |
| 250 | 250 | ); |
| 251 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 252 | - $search->setSlice( 0, 1 ); |
|
| 251 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 252 | + $search->setSlice(0, 1); |
|
| 253 | 253 | |
| 254 | - $result = $manager->searchItems( $search ); |
|
| 254 | + $result = $manager->searchItems($search); |
|
| 255 | 255 | |
| 256 | - if( ( $item = reset( $result ) ) === false ) { |
|
| 257 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon for code "%1$s" is not available any more', $code ) ); |
|
| 256 | + if (($item = reset($result)) === false) { |
|
| 257 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon for code "%1$s" is not available any more', $code)); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | |
| 261 | - $provider = $manager->getProvider( $item, $code ); |
|
| 261 | + $provider = $manager->getProvider($item, $code); |
|
| 262 | 262 | |
| 263 | - if( $provider->isAvailable( $this->get() ) !== true ) { |
|
| 264 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Requirements for coupon code "%1$s" aren\'t met', $code ) ); |
|
| 263 | + if ($provider->isAvailable($this->get()) !== true) { |
|
| 264 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Requirements for coupon code "%1$s" aren\'t met', $code)); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - $provider->addCoupon( $this->get() ); |
|
| 267 | + $provider->addCoupon($this->get()); |
|
| 268 | 268 | $this->save(); |
| 269 | 269 | } |
| 270 | 270 | |
@@ -275,21 +275,21 @@ discard block |
||
| 275 | 275 | * @param string $code Coupon code entered by the user |
| 276 | 276 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
| 277 | 277 | */ |
| 278 | - public function deleteCoupon( $code ) |
|
| 278 | + public function deleteCoupon($code) |
|
| 279 | 279 | { |
| 280 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
| 280 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
| 281 | 281 | |
| 282 | 282 | $search = $manager->createSearch(); |
| 283 | - $search->setConditions( $search->compare( '==', 'coupon.code.code', $code ) ); |
|
| 284 | - $search->setSlice( 0, 1 ); |
|
| 283 | + $search->setConditions($search->compare('==', 'coupon.code.code', $code)); |
|
| 284 | + $search->setSlice(0, 1); |
|
| 285 | 285 | |
| 286 | - $result = $manager->searchItems( $search ); |
|
| 286 | + $result = $manager->searchItems($search); |
|
| 287 | 287 | |
| 288 | - if( ( $item = reset( $result ) ) === false ) { |
|
| 289 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid', $code ) ); |
|
| 288 | + if (($item = reset($result)) === false) { |
|
| 289 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid', $code)); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - $manager->getProvider( $item, $code )->deleteCoupon( $this->get() ); |
|
| 292 | + $manager->getProvider($item, $code)->deleteCoupon($this->get()); |
|
| 293 | 293 | $this->save(); |
| 294 | 294 | } |
| 295 | 295 | |
@@ -302,28 +302,28 @@ discard block |
||
| 302 | 302 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the billing or delivery address is not of any required type of |
| 303 | 303 | * if one of the keys is invalid when using an array with key/value pairs |
| 304 | 304 | */ |
| 305 | - public function setAddress( $type, $value ) |
|
| 305 | + public function setAddress($type, $value) |
|
| 306 | 306 | { |
| 307 | - $address = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/address' )->createItem(); |
|
| 308 | - $address->setType( $type ); |
|
| 307 | + $address = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/address')->createItem(); |
|
| 308 | + $address->setType($type); |
|
| 309 | 309 | |
| 310 | - if( $value instanceof \Aimeos\MShop\Common\Item\Address\Iface ) |
|
| 310 | + if ($value instanceof \Aimeos\MShop\Common\Item\Address\Iface) |
|
| 311 | 311 | { |
| 312 | - $address->copyFrom( $value ); |
|
| 313 | - $this->get()->setAddress( $address, $type ); |
|
| 312 | + $address->copyFrom($value); |
|
| 313 | + $this->get()->setAddress($address, $type); |
|
| 314 | 314 | } |
| 315 | - else if( is_array( $value ) ) |
|
| 315 | + else if (is_array($value)) |
|
| 316 | 316 | { |
| 317 | - $this->setAddressFromArray( $address, $value ); |
|
| 318 | - $this->get()->setAddress( $address, $type ); |
|
| 317 | + $this->setAddressFromArray($address, $value); |
|
| 318 | + $this->get()->setAddress($address, $type); |
|
| 319 | 319 | } |
| 320 | - else if( $value === null ) |
|
| 320 | + else if ($value === null) |
|
| 321 | 321 | { |
| 322 | - $this->get()->deleteAddress( $type ); |
|
| 322 | + $this->get()->deleteAddress($type); |
|
| 323 | 323 | } |
| 324 | 324 | else |
| 325 | 325 | { |
| 326 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid value for address type "%1$s"', $type ) ); |
|
| 326 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Invalid value for address type "%1$s"', $type)); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | $this->save(); |
@@ -339,42 +339,42 @@ discard block |
||
| 339 | 339 | * entered by the customer when choosing one of the delivery or payment options |
| 340 | 340 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
| 341 | 341 | */ |
| 342 | - public function setService( $type, $id, array $attributes = array() ) |
|
| 342 | + public function setService($type, $id, array $attributes = array()) |
|
| 343 | 343 | { |
| 344 | 344 | $context = $this->getContext(); |
| 345 | 345 | |
| 346 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' ); |
|
| 347 | - $serviceItem = $this->getDomainItem( 'service', 'service.id', $id, array( 'media', 'price', 'text' ) ); |
|
| 346 | + $serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service'); |
|
| 347 | + $serviceItem = $this->getDomainItem('service', 'service.id', $id, array('media', 'price', 'text')); |
|
| 348 | 348 | |
| 349 | - $provider = $serviceManager->getProvider( $serviceItem ); |
|
| 350 | - $result = $provider->checkConfigFE( $attributes ); |
|
| 351 | - $unknown = array_diff_key( $attributes, $result ); |
|
| 349 | + $provider = $serviceManager->getProvider($serviceItem); |
|
| 350 | + $result = $provider->checkConfigFE($attributes); |
|
| 351 | + $unknown = array_diff_key($attributes, $result); |
|
| 352 | 352 | |
| 353 | - if( count( $unknown ) > 0 ) |
|
| 353 | + if (count($unknown) > 0) |
|
| 354 | 354 | { |
| 355 | - $msg = sprintf( 'Unknown attributes "%1$s"', implode( '","', array_keys( $unknown ) ) ); |
|
| 356 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 355 | + $msg = sprintf('Unknown attributes "%1$s"', implode('","', array_keys($unknown))); |
|
| 356 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | - foreach( $result as $key => $value ) |
|
| 359 | + foreach ($result as $key => $value) |
|
| 360 | 360 | { |
| 361 | - if( $value !== null ) { |
|
| 362 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $value ); |
|
| 361 | + if ($value !== null) { |
|
| 362 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($value); |
|
| 363 | 363 | } |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/service' ); |
|
| 366 | + $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/service'); |
|
| 367 | 367 | $orderServiceItem = $orderBaseServiceManager->createItem(); |
| 368 | - $orderServiceItem->copyFrom( $serviceItem ); |
|
| 368 | + $orderServiceItem->copyFrom($serviceItem); |
|
| 369 | 369 | |
| 370 | - $price = $provider->calcPrice( $this->get() ); |
|
| 370 | + $price = $provider->calcPrice($this->get()); |
|
| 371 | 371 | // remove service rebate of original price |
| 372 | - $price->setRebate( '0.00' ); |
|
| 373 | - $orderServiceItem->setPrice( $price ); |
|
| 372 | + $price->setRebate('0.00'); |
|
| 373 | + $orderServiceItem->setPrice($price); |
|
| 374 | 374 | |
| 375 | - $provider->setConfigFE( $orderServiceItem, $attributes ); |
|
| 375 | + $provider->setConfigFE($orderServiceItem, $attributes); |
|
| 376 | 376 | |
| 377 | - $this->get()->setService( $orderServiceItem, $type ); |
|
| 377 | + $this->get()->setService($orderServiceItem, $type); |
|
| 378 | 378 | $this->save(); |
| 379 | 379 | } |
| 380 | 380 | |
@@ -387,18 +387,18 @@ discard block |
||
| 387 | 387 | * an address item. |
| 388 | 388 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
| 389 | 389 | */ |
| 390 | - protected function setAddressFromArray( \Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map ) |
|
| 390 | + protected function setAddressFromArray(\Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map) |
|
| 391 | 391 | { |
| 392 | - foreach( $map as $key => $value ) { |
|
| 393 | - $map[$key] = strip_tags( $value ); // prevent XSS |
|
| 392 | + foreach ($map as $key => $value) { |
|
| 393 | + $map[$key] = strip_tags($value); // prevent XSS |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - $errors = $address->fromArray( $map ); |
|
| 396 | + $errors = $address->fromArray($map); |
|
| 397 | 397 | |
| 398 | - if( count( $errors ) > 0 ) |
|
| 398 | + if (count($errors) > 0) |
|
| 399 | 399 | { |
| 400 | - $msg = sprintf( 'Invalid address properties, please check your input' ); |
|
| 401 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg, 0, null, $errors ); |
|
| 400 | + $msg = sprintf('Invalid address properties, please check your input'); |
|
| 401 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg, 0, null, $errors); |
|
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | } |
@@ -311,17 +311,14 @@ |
||
| 311 | 311 | { |
| 312 | 312 | $address->copyFrom( $value ); |
| 313 | 313 | $this->get()->setAddress( $address, $type ); |
| 314 | - } |
|
| 315 | - else if( is_array( $value ) ) |
|
| 314 | + } else if( is_array( $value ) ) |
|
| 316 | 315 | { |
| 317 | 316 | $this->setAddressFromArray( $address, $value ); |
| 318 | 317 | $this->get()->setAddress( $address, $type ); |
| 319 | - } |
|
| 320 | - else if( $value === null ) |
|
| 318 | + } else if( $value === null ) |
|
| 321 | 319 | { |
| 322 | 320 | $this->get()->deleteAddress( $type ); |
| 323 | - } |
|
| 324 | - else |
|
| 321 | + } else |
|
| 325 | 322 | { |
| 326 | 323 | throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid value for address type "%1$s"', $type ) ); |
| 327 | 324 | } |
@@ -31,32 +31,32 @@ discard block |
||
| 31 | 31 | * @param integer $quantity New product quantity |
| 32 | 32 | * @return \Aimeos\MShop\Price\Item\Iface Price item with calculated price |
| 33 | 33 | */ |
| 34 | - protected function calcPrice( \Aimeos\MShop\Order\Item\Base\Product\Iface $product, array $prices, $quantity ) |
|
| 34 | + protected function calcPrice(\Aimeos\MShop\Order\Item\Base\Product\Iface $product, array $prices, $quantity) |
|
| 35 | 35 | { |
| 36 | 36 | $context = $this->getContext(); |
| 37 | 37 | |
| 38 | - if( empty( $prices ) ) |
|
| 38 | + if (empty($prices)) |
|
| 39 | 39 | { |
| 40 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
| 41 | - $prices = $manager->getItem( $product->getProductId(), array( 'price' ) )->getRefItems( 'price', 'default' ); |
|
| 40 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
| 41 | + $prices = $manager->getItem($product->getProductId(), array('price'))->getRefItems('price', 'default'); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
| 45 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
| 44 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
| 45 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
| 46 | 46 | |
| 47 | - foreach( $this->getAttributeItems( $product->getAttributes() ) as $attrItem ) |
|
| 47 | + foreach ($this->getAttributeItems($product->getAttributes()) as $attrItem) |
|
| 48 | 48 | { |
| 49 | - $prices = $attrItem->getRefItems( 'price', 'default' ); |
|
| 49 | + $prices = $attrItem->getRefItems('price', 'default'); |
|
| 50 | 50 | |
| 51 | - if( count( $prices ) > 0 ) |
|
| 51 | + if (count($prices) > 0) |
|
| 52 | 52 | { |
| 53 | - $attrPrice = $priceManager->getLowestPrice( $prices, $quantity ); |
|
| 54 | - $price->addItem( $attrPrice ); |
|
| 53 | + $attrPrice = $priceManager->getLowestPrice($prices, $quantity); |
|
| 54 | + $price->addItem($attrPrice); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // remove product rebate of original price in favor to rebates granted for the order |
| 59 | - $price->setRebate( '0.00' ); |
|
| 59 | + $price->setRebate('0.00'); |
|
| 60 | 60 | |
| 61 | 61 | return $price; |
| 62 | 62 | } |
@@ -71,34 +71,34 @@ discard block |
||
| 71 | 71 | * @param array $refIds List of IDs that must be associated to the product |
| 72 | 72 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated |
| 73 | 73 | */ |
| 74 | - protected function checkReferences( $prodId, $domain, $listTypeId, array $refIds ) |
|
| 74 | + protected function checkReferences($prodId, $domain, $listTypeId, array $refIds) |
|
| 75 | 75 | { |
| 76 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
| 77 | - $search = $productManager->createSearch( true ); |
|
| 76 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
| 77 | + $search = $productManager->createSearch(true); |
|
| 78 | 78 | |
| 79 | 79 | $expr = array( |
| 80 | - $search->compare( '==', 'product.id', $prodId ), |
|
| 80 | + $search->compare('==', 'product.id', $prodId), |
|
| 81 | 81 | $search->getConditions(), |
| 82 | 82 | ); |
| 83 | 83 | |
| 84 | - if( count( $refIds ) > 0 ) |
|
| 84 | + if (count($refIds) > 0) |
|
| 85 | 85 | { |
| 86 | - foreach( $refIds as $key => $refId ) { |
|
| 86 | + foreach ($refIds as $key => $refId) { |
|
| 87 | 87 | $refIds[$key] = (string) $refId; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $param = array( $domain, $listTypeId, $refIds ); |
|
| 91 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
| 90 | + $param = array($domain, $listTypeId, $refIds); |
|
| 91 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
| 92 | 92 | |
| 93 | - $expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) ); |
|
| 93 | + $expr[] = $search->compare('==', $cmpfunc, count($refIds)); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 96 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 97 | 97 | |
| 98 | - if( count( $productManager->searchItems( $search, array() ) ) === 0 ) |
|
| 98 | + if (count($productManager->searchItems($search, array())) === 0) |
|
| 99 | 99 | { |
| 100 | - $msg = sprintf( 'Invalid "%1$s" references for product with ID %2$s', $domain, json_encode( $prodId ) ); |
|
| 101 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 100 | + $msg = sprintf('Invalid "%1$s" references for product with ID %2$s', $domain, json_encode($prodId)); |
|
| 101 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
@@ -108,41 +108,41 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @param string $type Basket type |
| 110 | 110 | */ |
| 111 | - protected function checkLocale( $type ) |
|
| 111 | + protected function checkLocale($type) |
|
| 112 | 112 | { |
| 113 | 113 | $errors = array(); |
| 114 | 114 | $context = $this->getContext(); |
| 115 | 115 | $session = $context->getSession(); |
| 116 | 116 | $locale = $this->get()->getLocale(); |
| 117 | 117 | |
| 118 | - $localeStr = $session->get( 'aimeos/basket/locale' ); |
|
| 118 | + $localeStr = $session->get('aimeos/basket/locale'); |
|
| 119 | 119 | $localeKey = $locale->getSite()->getCode() . '|' . $locale->getLanguageId() . '|' . $locale->getCurrencyId(); |
| 120 | 120 | |
| 121 | - if( $localeStr !== null && $localeStr !== $localeKey ) |
|
| 121 | + if ($localeStr !== null && $localeStr !== $localeKey) |
|
| 122 | 122 | { |
| 123 | - $locParts = explode( '|', $localeStr ); |
|
| 124 | - $locSite = ( isset( $locParts[0] ) ? $locParts[0] : '' ); |
|
| 125 | - $locLanguage = ( isset( $locParts[1] ) ? $locParts[1] : '' ); |
|
| 126 | - $locCurrency = ( isset( $locParts[2] ) ? $locParts[2] : '' ); |
|
| 123 | + $locParts = explode('|', $localeStr); |
|
| 124 | + $locSite = (isset($locParts[0]) ? $locParts[0] : ''); |
|
| 125 | + $locLanguage = (isset($locParts[1]) ? $locParts[1] : ''); |
|
| 126 | + $locCurrency = (isset($locParts[2]) ? $locParts[2] : ''); |
|
| 127 | 127 | |
| 128 | - $localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' ); |
|
| 129 | - $locale = $localeManager->bootstrap( $locSite, $locLanguage, $locCurrency, false ); |
|
| 128 | + $localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale'); |
|
| 129 | + $locale = $localeManager->bootstrap($locSite, $locLanguage, $locCurrency, false); |
|
| 130 | 130 | |
| 131 | 131 | $context = clone $context; |
| 132 | - $context->setLocale( $locale ); |
|
| 132 | + $context->setLocale($locale); |
|
| 133 | 133 | |
| 134 | - $manager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context )->getSubManager( 'base' ); |
|
| 135 | - $basket = $manager->getSession( $type ); |
|
| 134 | + $manager = \Aimeos\MShop\Order\Manager\Factory::createManager($context)->getSubManager('base'); |
|
| 135 | + $basket = $manager->getSession($type); |
|
| 136 | 136 | |
| 137 | - $this->copyAddresses( $basket, $errors, $localeKey ); |
|
| 138 | - $this->copyServices( $basket, $errors ); |
|
| 139 | - $this->copyProducts( $basket, $errors, $localeKey ); |
|
| 140 | - $this->copyCoupons( $basket, $errors, $localeKey ); |
|
| 137 | + $this->copyAddresses($basket, $errors, $localeKey); |
|
| 138 | + $this->copyServices($basket, $errors); |
|
| 139 | + $this->copyProducts($basket, $errors, $localeKey); |
|
| 140 | + $this->copyCoupons($basket, $errors, $localeKey); |
|
| 141 | 141 | |
| 142 | - $manager->setSession( $basket, $type ); |
|
| 142 | + $manager->setSession($basket, $type); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - $session->set( 'aimeos/basket/locale', $localeKey ); |
|
| 145 | + $session->set('aimeos/basket/locale', $localeKey); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | |
@@ -154,20 +154,20 @@ discard block |
||
| 154 | 154 | * @param string $localeKey Unique identifier of the site, language and currency |
| 155 | 155 | * @return array Associative list of errors occured |
| 156 | 156 | */ |
| 157 | - protected function copyAddresses( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
| 157 | + protected function copyAddresses(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
| 158 | 158 | { |
| 159 | - foreach( $basket->getAddresses() as $type => $item ) |
|
| 159 | + foreach ($basket->getAddresses() as $type => $item) |
|
| 160 | 160 | { |
| 161 | 161 | try |
| 162 | 162 | { |
| 163 | - $this->setAddress( $type, $item->toArray() ); |
|
| 164 | - $basket->deleteAddress( $type ); |
|
| 163 | + $this->setAddress($type, $item->toArray()); |
|
| 164 | + $basket->deleteAddress($type); |
|
| 165 | 165 | } |
| 166 | - catch( \Exception $e ) |
|
| 166 | + catch (\Exception $e) |
|
| 167 | 167 | { |
| 168 | 168 | $logger = $this->getContext()->getLogger(); |
| 169 | 169 | $str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s'; |
| 170 | - $logger->log( sprintf( $str, $type, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
| 170 | + $logger->log(sprintf($str, $type, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
| 171 | 171 | $errors['address'][$type] = $e->getMessage(); |
| 172 | 172 | } |
| 173 | 173 | } |
@@ -184,20 +184,20 @@ discard block |
||
| 184 | 184 | * @param string $localeKey Unique identifier of the site, language and currency |
| 185 | 185 | * @return array Associative list of errors occured |
| 186 | 186 | */ |
| 187 | - protected function copyCoupons( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
| 187 | + protected function copyCoupons(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
| 188 | 188 | { |
| 189 | - foreach( $basket->getCoupons() as $code => $list ) |
|
| 189 | + foreach ($basket->getCoupons() as $code => $list) |
|
| 190 | 190 | { |
| 191 | 191 | try |
| 192 | 192 | { |
| 193 | - $this->addCoupon( $code ); |
|
| 194 | - $basket->deleteCoupon( $code, true ); |
|
| 193 | + $this->addCoupon($code); |
|
| 194 | + $basket->deleteCoupon($code, true); |
|
| 195 | 195 | } |
| 196 | - catch( \Exception $e ) |
|
| 196 | + catch (\Exception $e) |
|
| 197 | 197 | { |
| 198 | 198 | $logger = $this->getContext()->getLogger(); |
| 199 | 199 | $str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s'; |
| 200 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
| 200 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
| 201 | 201 | $errors['coupon'][$code] = $e->getMessage(); |
| 202 | 202 | } |
| 203 | 203 | } |
@@ -214,11 +214,11 @@ discard block |
||
| 214 | 214 | * @param string $localeKey Unique identifier of the site, language and currency |
| 215 | 215 | * @return array Associative list of errors occured |
| 216 | 216 | */ |
| 217 | - protected function copyProducts( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
| 217 | + protected function copyProducts(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
| 218 | 218 | { |
| 219 | - foreach( $basket->getProducts() as $pos => $product ) |
|
| 219 | + foreach ($basket->getProducts() as $pos => $product) |
|
| 220 | 220 | { |
| 221 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) { |
|
| 221 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) { |
|
| 222 | 222 | continue; |
| 223 | 223 | } |
| 224 | 224 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | { |
| 227 | 227 | $attrIds = array(); |
| 228 | 228 | |
| 229 | - foreach( $product->getAttributes() as $attrItem ) { |
|
| 229 | + foreach ($product->getAttributes() as $attrItem) { |
|
| 230 | 230 | $attrIds[$attrItem->getType()][] = $attrItem->getAttributeId(); |
| 231 | 231 | } |
| 232 | 232 | |
@@ -234,21 +234,21 @@ discard block |
||
| 234 | 234 | $product->getProductId(), |
| 235 | 235 | $product->getQuantity(), |
| 236 | 236 | array(), |
| 237 | - $this->getValue( $attrIds, 'variant', array() ), |
|
| 238 | - $this->getValue( $attrIds, 'config', array() ), |
|
| 239 | - $this->getValue( $attrIds, 'hidden', array() ), |
|
| 240 | - $this->getValue( $attrIds, 'custom', array() ), |
|
| 237 | + $this->getValue($attrIds, 'variant', array()), |
|
| 238 | + $this->getValue($attrIds, 'config', array()), |
|
| 239 | + $this->getValue($attrIds, 'hidden', array()), |
|
| 240 | + $this->getValue($attrIds, 'custom', array()), |
|
| 241 | 241 | $product->getStockType() |
| 242 | 242 | ); |
| 243 | 243 | |
| 244 | - $basket->deleteProduct( $pos ); |
|
| 244 | + $basket->deleteProduct($pos); |
|
| 245 | 245 | } |
| 246 | - catch( \Exception $e ) |
|
| 246 | + catch (\Exception $e) |
|
| 247 | 247 | { |
| 248 | 248 | $code = $product->getProductCode(); |
| 249 | 249 | $logger = $this->getContext()->getLogger(); |
| 250 | 250 | $str = 'Error migrating product with code "%1$s" in basket to locale "%2$s": %3$s'; |
| 251 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
| 251 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
| 252 | 252 | $errors['product'][$pos] = $e->getMessage(); |
| 253 | 253 | } |
| 254 | 254 | } |
@@ -264,22 +264,22 @@ discard block |
||
| 264 | 264 | * @param array $errors Associative list of previous errors |
| 265 | 265 | * @return array Associative list of errors occured |
| 266 | 266 | */ |
| 267 | - protected function copyServices( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors ) |
|
| 267 | + protected function copyServices(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors) |
|
| 268 | 268 | { |
| 269 | - foreach( $basket->getServices() as $type => $item ) |
|
| 269 | + foreach ($basket->getServices() as $type => $item) |
|
| 270 | 270 | { |
| 271 | 271 | try |
| 272 | 272 | { |
| 273 | 273 | $attributes = array(); |
| 274 | 274 | |
| 275 | - foreach( $item->getAttributes() as $attrItem ) { |
|
| 275 | + foreach ($item->getAttributes() as $attrItem) { |
|
| 276 | 276 | $attributes[$attrItem->getCode()] = $attrItem->getValue(); |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - $this->setService( $type, $item->getServiceId(), $attributes ); |
|
| 280 | - $basket->deleteService( $type ); |
|
| 279 | + $this->setService($type, $item->getServiceId(), $attributes); |
|
| 280 | + $basket->deleteService($type); |
|
| 281 | 281 | } |
| 282 | - catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically |
|
| 282 | + catch (\Exception $e) {; } // Don't notify the user as appropriate services can be added automatically |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | return $errors; |
@@ -297,36 +297,36 @@ discard block |
||
| 297 | 297 | * @param array $attributeValues Associative list of attribute IDs as keys and their codes as values |
| 298 | 298 | * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface |
| 299 | 299 | */ |
| 300 | - protected function createOrderProductAttributes( \Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
| 301 | - array $attributeIds, $type, array $attributeValues = array() ) |
|
| 300 | + protected function createOrderProductAttributes(\Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
| 301 | + array $attributeIds, $type, array $attributeValues = array()) |
|
| 302 | 302 | { |
| 303 | - if( empty( $attributeIds ) ) { |
|
| 303 | + if (empty($attributeIds)) { |
|
| 304 | 304 | return array(); |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - $attrTypeId = $this->getProductListTypeItem( 'attribute', $type )->getId(); |
|
| 308 | - $this->checkReferences( $prodid, 'attribute', $attrTypeId, $attributeIds ); |
|
| 307 | + $attrTypeId = $this->getProductListTypeItem('attribute', $type)->getId(); |
|
| 308 | + $this->checkReferences($prodid, 'attribute', $attrTypeId, $attributeIds); |
|
| 309 | 309 | |
| 310 | 310 | $list = array(); |
| 311 | 311 | $context = $this->getContext(); |
| 312 | 312 | |
| 313 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
| 314 | - $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product/attribute' ); |
|
| 313 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
| 314 | + $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product/attribute'); |
|
| 315 | 315 | |
| 316 | - foreach( $this->getAttributes( $attributeIds ) as $id => $attrItem ) |
|
| 316 | + foreach ($this->getAttributes($attributeIds) as $id => $attrItem) |
|
| 317 | 317 | { |
| 318 | - $prices = $attrItem->getRefItems( 'price', 'default', 'default' ); |
|
| 318 | + $prices = $attrItem->getRefItems('price', 'default', 'default'); |
|
| 319 | 319 | |
| 320 | - if( !empty( $prices ) ) { |
|
| 321 | - $price->addItem( $priceManager->getLowestPrice( $prices, $quantity ) ); |
|
| 320 | + if (!empty($prices)) { |
|
| 321 | + $price->addItem($priceManager->getLowestPrice($prices, $quantity)); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | $item = $orderProductAttributeManager->createItem(); |
| 325 | - $item->copyFrom( $attrItem ); |
|
| 326 | - $item->setType( $type ); |
|
| 325 | + $item->copyFrom($attrItem); |
|
| 326 | + $item->setType($type); |
|
| 327 | 327 | |
| 328 | - if( isset( $attributeValues[$id] ) ) { |
|
| 329 | - $item->setValue( $attributeValues[$id] ); |
|
| 328 | + if (isset($attributeValues[$id])) { |
|
| 329 | + $item->setValue($attributeValues[$id]); |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | $list[] = $item; |
@@ -344,31 +344,31 @@ discard block |
||
| 344 | 344 | * @return array List of items implementing \Aimeos\MShop\Attribute\Item\Iface |
| 345 | 345 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the actual attribute number doesn't match the expected one |
| 346 | 346 | */ |
| 347 | - protected function getAttributes( array $attributeIds, array $domains = array( 'price', 'text' ) ) |
|
| 347 | + protected function getAttributes(array $attributeIds, array $domains = array('price', 'text')) |
|
| 348 | 348 | { |
| 349 | - if( empty( $attributeIds ) ) { |
|
| 349 | + if (empty($attributeIds)) { |
|
| 350 | 350 | return array(); |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
| 353 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
| 354 | 354 | |
| 355 | - $search = $attributeManager->createSearch( true ); |
|
| 355 | + $search = $attributeManager->createSearch(true); |
|
| 356 | 356 | $expr = array( |
| 357 | - $search->compare( '==', 'attribute.id', $attributeIds ), |
|
| 357 | + $search->compare('==', 'attribute.id', $attributeIds), |
|
| 358 | 358 | $search->getConditions(), |
| 359 | 359 | ); |
| 360 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 361 | - $search->setSlice( 0, 0x7fffffff ); |
|
| 360 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 361 | + $search->setSlice(0, 0x7fffffff); |
|
| 362 | 362 | |
| 363 | - $attrItems = $attributeManager->searchItems( $search, $domains ); |
|
| 363 | + $attrItems = $attributeManager->searchItems($search, $domains); |
|
| 364 | 364 | |
| 365 | - if( count( $attrItems ) !== count( $attributeIds ) ) |
|
| 365 | + if (count($attrItems) !== count($attributeIds)) |
|
| 366 | 366 | { |
| 367 | - $expected = implode( ',', $attributeIds ); |
|
| 368 | - $actual = implode( ',', array_keys( $attrItems ) ); |
|
| 369 | - $msg = sprintf( 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected ); |
|
| 367 | + $expected = implode(',', $attributeIds); |
|
| 368 | + $actual = implode(',', array_keys($attrItems)); |
|
| 369 | + $msg = sprintf('Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected); |
|
| 370 | 370 | |
| 371 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 371 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | return $attrItems; |
@@ -381,31 +381,31 @@ discard block |
||
| 381 | 381 | * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Item[] $orderAttributes List of order product attribute items |
| 382 | 382 | * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as key and attribute items as values |
| 383 | 383 | */ |
| 384 | - protected function getAttributeItems( array $orderAttributes ) |
|
| 384 | + protected function getAttributeItems(array $orderAttributes) |
|
| 385 | 385 | { |
| 386 | - if( empty( $orderAttributes ) ) { |
|
| 386 | + if (empty($orderAttributes)) { |
|
| 387 | 387 | return array(); |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
| 391 | - $search = $attributeManager->createSearch( true ); |
|
| 390 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
| 391 | + $search = $attributeManager->createSearch(true); |
|
| 392 | 392 | $expr = array(); |
| 393 | 393 | |
| 394 | - foreach( $orderAttributes as $item ) |
|
| 394 | + foreach ($orderAttributes as $item) |
|
| 395 | 395 | { |
| 396 | 396 | $tmp = array( |
| 397 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
| 398 | - $search->compare( '==', 'attribute.code', $item->getValue() ), |
|
| 399 | - $search->compare( '==', 'attribute.type.domain', 'product' ), |
|
| 400 | - $search->compare( '==', 'attribute.type.code', $item->getCode() ), |
|
| 401 | - $search->compare( '>', 'attribute.type.status', 0 ), |
|
| 397 | + $search->compare('==', 'attribute.domain', 'product'), |
|
| 398 | + $search->compare('==', 'attribute.code', $item->getValue()), |
|
| 399 | + $search->compare('==', 'attribute.type.domain', 'product'), |
|
| 400 | + $search->compare('==', 'attribute.type.code', $item->getCode()), |
|
| 401 | + $search->compare('>', 'attribute.type.status', 0), |
|
| 402 | 402 | $search->getConditions(), |
| 403 | 403 | ); |
| 404 | - $expr[] = $search->combine( '&&', $tmp ); |
|
| 404 | + $expr[] = $search->combine('&&', $tmp); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - $search->setConditions( $search->combine( '||', $expr ) ); |
|
| 408 | - return $attributeManager->searchItems( $search, array( 'price' ) ); |
|
| 407 | + $search->setConditions($search->combine('||', $expr)); |
|
| 408 | + return $attributeManager->searchItems($search, array('price')); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | |
@@ -419,23 +419,23 @@ discard block |
||
| 419 | 419 | * @return \Aimeos\MShop\Common\Item\Iface Domain item object |
| 420 | 420 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
| 421 | 421 | */ |
| 422 | - protected function getDomainItem( $domain, $key, $value, array $ref ) |
|
| 422 | + protected function getDomainItem($domain, $key, $value, array $ref) |
|
| 423 | 423 | { |
| 424 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $domain ); |
|
| 424 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $domain); |
|
| 425 | 425 | |
| 426 | - $search = $manager->createSearch( true ); |
|
| 426 | + $search = $manager->createSearch(true); |
|
| 427 | 427 | $expr = array( |
| 428 | - $search->compare( '==', $key, $value ), |
|
| 428 | + $search->compare('==', $key, $value), |
|
| 429 | 429 | $search->getConditions(), |
| 430 | 430 | ); |
| 431 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 431 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 432 | 432 | |
| 433 | - $result = $manager->searchItems( $search, $ref ); |
|
| 433 | + $result = $manager->searchItems($search, $ref); |
|
| 434 | 434 | |
| 435 | - if( ( $item = reset( $result ) ) === false ) |
|
| 435 | + if (($item = reset($result)) === false) |
|
| 436 | 436 | { |
| 437 | - $msg = sprintf( 'No item for "%1$s" (%2$s) found', $value, $key ); |
|
| 438 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 437 | + $msg = sprintf('No item for "%1$s" (%2$s) found', $value, $key); |
|
| 438 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | return $item; |
@@ -449,26 +449,26 @@ discard block |
||
| 449 | 449 | * @param string $code Code of the list type |
| 450 | 450 | * @return \Aimeos\MShop\Common\Item\Type\Iface List type item |
| 451 | 451 | */ |
| 452 | - protected function getProductListTypeItem( $domain, $code ) |
|
| 452 | + protected function getProductListTypeItem($domain, $code) |
|
| 453 | 453 | { |
| 454 | - if( !isset( $this->listTypeAttributes[$domain][$code] ) ) |
|
| 454 | + if (!isset($this->listTypeAttributes[$domain][$code])) |
|
| 455 | 455 | { |
| 456 | - $listTypeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists/type' ); |
|
| 456 | + $listTypeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists/type'); |
|
| 457 | 457 | |
| 458 | - $listTypeSearch = $listTypeManager->createSearch( true ); |
|
| 458 | + $listTypeSearch = $listTypeManager->createSearch(true); |
|
| 459 | 459 | $expr = array( |
| 460 | - $listTypeSearch->compare( '==', 'product.lists.type.domain', $domain ), |
|
| 461 | - $listTypeSearch->compare( '==', 'product.lists.type.code', $code ), |
|
| 460 | + $listTypeSearch->compare('==', 'product.lists.type.domain', $domain), |
|
| 461 | + $listTypeSearch->compare('==', 'product.lists.type.code', $code), |
|
| 462 | 462 | $listTypeSearch->getConditions(), |
| 463 | 463 | ); |
| 464 | - $listTypeSearch->setConditions( $listTypeSearch->combine( '&&', $expr ) ); |
|
| 464 | + $listTypeSearch->setConditions($listTypeSearch->combine('&&', $expr)); |
|
| 465 | 465 | |
| 466 | - $listTypeItems = $listTypeManager->searchItems( $listTypeSearch ); |
|
| 466 | + $listTypeItems = $listTypeManager->searchItems($listTypeSearch); |
|
| 467 | 467 | |
| 468 | - if( ( $listTypeItem = reset( $listTypeItems ) ) === false ) |
|
| 468 | + if (($listTypeItem = reset($listTypeItems)) === false) |
|
| 469 | 469 | { |
| 470 | - $msg = sprintf( 'List type for domain "%1$s" and code "%2$s" not found', $domain, $code ); |
|
| 471 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 470 | + $msg = sprintf('List type for domain "%1$s" and code "%2$s" not found', $domain, $code); |
|
| 471 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | $this->listTypeAttributes[$domain][$code] = $listTypeItem; |
@@ -486,43 +486,43 @@ discard block |
||
| 486 | 486 | * @param array $domains Names of the domain items that should be fetched too |
| 487 | 487 | * @return array List of products matching the given attributes |
| 488 | 488 | */ |
| 489 | - protected function getProductVariants( \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
| 490 | - array $domains = array( 'attribute', 'media', 'price', 'text' ) ) |
|
| 489 | + protected function getProductVariants(\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
| 490 | + array $domains = array('attribute', 'media', 'price', 'text')) |
|
| 491 | 491 | { |
| 492 | 492 | $subProductIds = array(); |
| 493 | - foreach( $productItem->getRefItems( 'product', 'default', 'default' ) as $item ) { |
|
| 493 | + foreach ($productItem->getRefItems('product', 'default', 'default') as $item) { |
|
| 494 | 494 | $subProductIds[] = $item->getId(); |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | - if( count( $subProductIds ) === 0 ) { |
|
| 497 | + if (count($subProductIds) === 0) { |
|
| 498 | 498 | return array(); |
| 499 | 499 | } |
| 500 | 500 | |
| 501 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
| 502 | - $search = $productManager->createSearch( true ); |
|
| 501 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
| 502 | + $search = $productManager->createSearch(true); |
|
| 503 | 503 | |
| 504 | 504 | $expr = array( |
| 505 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
| 505 | + $search->compare('==', 'product.id', $subProductIds), |
|
| 506 | 506 | $search->getConditions(), |
| 507 | 507 | ); |
| 508 | 508 | |
| 509 | - if( count( $variantAttributeIds ) > 0 ) |
|
| 509 | + if (count($variantAttributeIds) > 0) |
|
| 510 | 510 | { |
| 511 | - foreach( $variantAttributeIds as $key => $id ) { |
|
| 511 | + foreach ($variantAttributeIds as $key => $id) { |
|
| 512 | 512 | $variantAttributeIds[$key] = (string) $id; |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | - $listTypeItem = $this->getProductListTypeItem( 'attribute', 'variant' ); |
|
| 515 | + $listTypeItem = $this->getProductListTypeItem('attribute', 'variant'); |
|
| 516 | 516 | |
| 517 | - $param = array( 'attribute', $listTypeItem->getId(), $variantAttributeIds ); |
|
| 518 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
| 517 | + $param = array('attribute', $listTypeItem->getId(), $variantAttributeIds); |
|
| 518 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
| 519 | 519 | |
| 520 | - $expr[] = $search->compare( '==', $cmpfunc, count( $variantAttributeIds ) ); |
|
| 520 | + $expr[] = $search->compare('==', $cmpfunc, count($variantAttributeIds)); |
|
| 521 | 521 | } |
| 522 | 522 | |
| 523 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 523 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 524 | 524 | |
| 525 | - return $productManager->searchItems( $search, $domains ); |
|
| 525 | + return $productManager->searchItems($search, $domains); |
|
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | |
@@ -534,9 +534,9 @@ discard block |
||
| 534 | 534 | * @param mixed $default Default value if no value is available for the given name |
| 535 | 535 | * @return mixed Value from the array or default value |
| 536 | 536 | */ |
| 537 | - protected function getValue( array $values, $name, $default = null ) |
|
| 537 | + protected function getValue(array $values, $name, $default = null) |
|
| 538 | 538 | { |
| 539 | - if( isset( $values[$name] ) ) { |
|
| 539 | + if (isset($values[$name])) { |
|
| 540 | 540 | return $values[$name]; |
| 541 | 541 | } |
| 542 | 542 | |