@@ -41,14 +41,14 @@ discard block |
||
| 41 | 41 | * @param string $stocktype Unique code of the stock type to deliver the products from |
| 42 | 42 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
| 43 | 43 | */ |
| 44 | - public function addProduct( $prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
| 44 | + public function addProduct($prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
| 45 | 45 | array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [], |
| 46 | - $stocktype = 'default' ) |
|
| 46 | + $stocktype = 'default') |
|
| 47 | 47 | { |
| 48 | 48 | $context = $this->getContext(); |
| 49 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
| 49 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
| 50 | 50 | |
| 51 | - if( $productManager->getItem( $prodid, [], true )->getType() !== 'bundle' ) |
|
| 51 | + if ($productManager->getItem($prodid, [], true)->getType() !== 'bundle') |
|
| 52 | 52 | { |
| 53 | 53 | return $this->getController()->addProduct( |
| 54 | 54 | $prodid, $quantity, $options, $variantAttributeIds, $configAttributeIds, |
@@ -57,29 +57,29 @@ discard block |
||
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $attributeMap = [ |
| 60 | - 'custom' => array_keys( $customAttributeValues ), |
|
| 60 | + 'custom' => array_keys($customAttributeValues), |
|
| 61 | 61 | 'config' => $configAttributeIds, |
| 62 | 62 | 'hidden' => $hiddenAttributeIds, |
| 63 | 63 | ]; |
| 64 | - $this->checkListRef( $prodid, 'attribute', $attributeMap ); |
|
| 64 | + $this->checkListRef($prodid, 'attribute', $attributeMap); |
|
| 65 | 65 | |
| 66 | 66 | |
| 67 | - $productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true ); |
|
| 68 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
| 67 | + $productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true); |
|
| 68 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
| 69 | 69 | |
| 70 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
| 71 | - $orderBaseProductItem->copyFrom( $productItem )->setQuantity( $quantity )->setStockType( $stocktype ); |
|
| 70 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
| 71 | + $orderBaseProductItem->copyFrom($productItem)->setQuantity($quantity)->setStockType($stocktype); |
|
| 72 | 72 | |
| 73 | - $this->addBundleProducts( $orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype ); |
|
| 73 | + $this->addBundleProducts($orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype); |
|
| 74 | 74 | |
| 75 | - $attr = $this->getOrderProductAttributes( 'custom', array_keys( $customAttributeValues ), $customAttributeValues ); |
|
| 76 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'config', $configAttributeIds ) ); |
|
| 77 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'hidden', $hiddenAttributeIds ) ); |
|
| 75 | + $attr = $this->getOrderProductAttributes('custom', array_keys($customAttributeValues), $customAttributeValues); |
|
| 76 | + $attr = array_merge($attr, $this->getOrderProductAttributes('config', $configAttributeIds)); |
|
| 77 | + $attr = array_merge($attr, $this->getOrderProductAttributes('hidden', $hiddenAttributeIds)); |
|
| 78 | 78 | |
| 79 | - $orderBaseProductItem->setAttributes( $attr ); |
|
| 80 | - $orderBaseProductItem->setPrice( $this->calcPrice( $orderBaseProductItem, $prices, $quantity ) ); |
|
| 79 | + $orderBaseProductItem->setAttributes($attr); |
|
| 80 | + $orderBaseProductItem->setPrice($this->calcPrice($orderBaseProductItem, $prices, $quantity)); |
|
| 81 | 81 | |
| 82 | - $this->getController()->get()->addProduct( $orderBaseProductItem ); |
|
| 82 | + $this->getController()->get()->addProduct($orderBaseProductItem); |
|
| 83 | 83 | $this->getController()->save(); |
| 84 | 84 | } |
| 85 | 85 | |
@@ -92,43 +92,43 @@ discard block |
||
| 92 | 92 | * @param array $variantAttributeIds List of product variant attribute IDs |
| 93 | 93 | * @param string $stocktype |
| 94 | 94 | */ |
| 95 | - protected function addBundleProducts( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
| 96 | - \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype ) |
|
| 95 | + protected function addBundleProducts(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
| 96 | + \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype) |
|
| 97 | 97 | { |
| 98 | 98 | $quantity = $orderBaseProductItem->getQuantity(); |
| 99 | 99 | $products = $subProductIds = $orderProducts = []; |
| 100 | - $orderProductManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product' ); |
|
| 100 | + $orderProductManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product'); |
|
| 101 | 101 | |
| 102 | - foreach( $productItem->getRefItems( 'product', null, 'default' ) as $item ) { |
|
| 102 | + foreach ($productItem->getRefItems('product', null, 'default') as $item) { |
|
| 103 | 103 | $subProductIds[] = $item->getId(); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - if( count( $subProductIds ) > 0 ) |
|
| 106 | + if (count($subProductIds) > 0) |
|
| 107 | 107 | { |
| 108 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
| 108 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
| 109 | 109 | |
| 110 | - $search = $productManager->createSearch( true ); |
|
| 110 | + $search = $productManager->createSearch(true); |
|
| 111 | 111 | $expr = array( |
| 112 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
| 112 | + $search->compare('==', 'product.id', $subProductIds), |
|
| 113 | 113 | $search->getConditions(), |
| 114 | 114 | ); |
| 115 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 115 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 116 | 116 | |
| 117 | - $products = $productManager->searchItems( $search, array( 'attribute', 'media', 'price', 'text' ) ); |
|
| 117 | + $products = $productManager->searchItems($search, array('attribute', 'media', 'price', 'text')); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - foreach( $products as $product ) |
|
| 120 | + foreach ($products as $product) |
|
| 121 | 121 | { |
| 122 | - $prices = $product->getRefItems( 'price', 'default', 'default' ); |
|
| 122 | + $prices = $product->getRefItems('price', 'default', 'default'); |
|
| 123 | 123 | |
| 124 | 124 | $orderProduct = $orderProductManager->createItem(); |
| 125 | - $orderProduct->copyFrom( $product ); |
|
| 126 | - $orderProduct->setStockType( $stocktype ); |
|
| 127 | - $orderProduct->setPrice( $this->calcPrice( $orderProduct, $prices, $quantity ) ); |
|
| 125 | + $orderProduct->copyFrom($product); |
|
| 126 | + $orderProduct->setStockType($stocktype); |
|
| 127 | + $orderProduct->setPrice($this->calcPrice($orderProduct, $prices, $quantity)); |
|
| 128 | 128 | |
| 129 | 129 | $orderProducts[] = $orderProduct; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - $orderBaseProductItem->setProducts( $orderProducts ); |
|
| 132 | + $orderBaseProductItem->setProducts($orderProducts); |
|
| 133 | 133 | } |
| 134 | 134 | } |
@@ -41,15 +41,15 @@ discard block |
||
| 41 | 41 | * @param string $stocktype Unique code of the stock type to deliver the products from |
| 42 | 42 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
| 43 | 43 | */ |
| 44 | - public function addProduct( $prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
| 44 | + public function addProduct($prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
| 45 | 45 | array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [], |
| 46 | - $stocktype = 'default' ) |
|
| 46 | + $stocktype = 'default') |
|
| 47 | 47 | { |
| 48 | 48 | $context = $this->getContext(); |
| 49 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
| 50 | - $productItem = $productManager->getItem( $prodid, [], true ); |
|
| 49 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
| 50 | + $productItem = $productManager->getItem($prodid, [], true); |
|
| 51 | 51 | |
| 52 | - if( $productManager->getItem( $prodid, [], true )->getType() !== 'select' ) |
|
| 52 | + if ($productManager->getItem($prodid, [], true)->getType() !== 'select') |
|
| 53 | 53 | { |
| 54 | 54 | return $this->getController()->addProduct( |
| 55 | 55 | $prodid, $quantity, $options, $variantAttributeIds, $configAttributeIds, |
@@ -57,29 +57,29 @@ discard block |
||
| 57 | 57 | ); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true ); |
|
| 61 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
| 60 | + $productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true); |
|
| 61 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
| 62 | 62 | |
| 63 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
| 64 | - $orderBaseProductItem->copyFrom( $productItem )->setQuantity( $quantity )->setStockType( $stocktype ); |
|
| 63 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
| 64 | + $orderBaseProductItem->copyFrom($productItem)->setQuantity($quantity)->setStockType($stocktype); |
|
| 65 | 65 | |
| 66 | - $attr = $this->getVariantDetails( $orderBaseProductItem, $productItem, $prices, $variantAttributeIds, $options ); |
|
| 66 | + $attr = $this->getVariantDetails($orderBaseProductItem, $productItem, $prices, $variantAttributeIds, $options); |
|
| 67 | 67 | |
| 68 | 68 | $attributeMap = [ |
| 69 | - 'custom' => array_keys( $customAttributeValues ), |
|
| 69 | + 'custom' => array_keys($customAttributeValues), |
|
| 70 | 70 | 'config' => $configAttributeIds, |
| 71 | 71 | 'hidden' => $hiddenAttributeIds, |
| 72 | 72 | ]; |
| 73 | - $this->checkListRef( array( $prodid, $productItem->getId() ), 'attribute', $attributeMap ); |
|
| 73 | + $this->checkListRef(array($prodid, $productItem->getId()), 'attribute', $attributeMap); |
|
| 74 | 74 | |
| 75 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'custom', array_keys( $customAttributeValues ), $customAttributeValues ) ); |
|
| 76 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'config', $configAttributeIds ) ); |
|
| 77 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'hidden', $hiddenAttributeIds ) ); |
|
| 75 | + $attr = array_merge($attr, $this->getOrderProductAttributes('custom', array_keys($customAttributeValues), $customAttributeValues)); |
|
| 76 | + $attr = array_merge($attr, $this->getOrderProductAttributes('config', $configAttributeIds)); |
|
| 77 | + $attr = array_merge($attr, $this->getOrderProductAttributes('hidden', $hiddenAttributeIds)); |
|
| 78 | 78 | |
| 79 | - $orderBaseProductItem->setAttributes( $attr ); |
|
| 80 | - $orderBaseProductItem->setPrice( $this->calcPrice( $orderBaseProductItem, $prices, $quantity ) ); |
|
| 79 | + $orderBaseProductItem->setAttributes($attr); |
|
| 80 | + $orderBaseProductItem->setPrice($this->calcPrice($orderBaseProductItem, $prices, $quantity)); |
|
| 81 | 81 | |
| 82 | - $this->getController()->get()->addProduct( $orderBaseProductItem ); |
|
| 82 | + $this->getController()->get()->addProduct($orderBaseProductItem); |
|
| 83 | 83 | $this->getController()->save(); |
| 84 | 84 | } |
| 85 | 85 | |
@@ -95,50 +95,50 @@ discard block |
||
| 95 | 95 | * @return \Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface[] List of order product attributes |
| 96 | 96 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If no product variant is found |
| 97 | 97 | */ |
| 98 | - protected function getVariantDetails( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
| 99 | - \Aimeos\MShop\Product\Item\Iface &$productItem, array &$prices, array $variantAttributeIds, array $options ) |
|
| 98 | + protected function getVariantDetails(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
| 99 | + \Aimeos\MShop\Product\Item\Iface & $productItem, array &$prices, array $variantAttributeIds, array $options) |
|
| 100 | 100 | { |
| 101 | 101 | $attr = []; |
| 102 | - $productItems = $this->getProductVariants( $productItem, $variantAttributeIds ); |
|
| 102 | + $productItems = $this->getProductVariants($productItem, $variantAttributeIds); |
|
| 103 | 103 | |
| 104 | - if( count( $productItems ) > 1 ) |
|
| 104 | + if (count($productItems) > 1) |
|
| 105 | 105 | { |
| 106 | - $msg = sprintf( 'No unique article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
|
| 107 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 106 | + $msg = sprintf('No unique article found for selected attributes and product ID "%1$s"', $productItem->getId()); |
|
| 107 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 108 | 108 | } |
| 109 | - else if( ( $result = reset( $productItems ) ) !== false ) // count == 1 |
|
| 109 | + else if (($result = reset($productItems)) !== false) // count == 1 |
|
| 110 | 110 | { |
| 111 | 111 | $productItem = $result; |
| 112 | - $orderBaseProductItem->setProductCode( $productItem->getCode() ); |
|
| 112 | + $orderBaseProductItem->setProductCode($productItem->getCode()); |
|
| 113 | 113 | |
| 114 | - $subprices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
| 114 | + $subprices = $productItem->getRefItems('price', 'default', 'default'); |
|
| 115 | 115 | |
| 116 | - if( !empty( $subprices ) ) { |
|
| 116 | + if (!empty($subprices)) { |
|
| 117 | 117 | $prices = $subprices; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $submedia = $productItem->getRefItems( 'media', 'default', 'default' ); |
|
| 120 | + $submedia = $productItem->getRefItems('media', 'default', 'default'); |
|
| 121 | 121 | |
| 122 | - if( ( $mediaItem = reset( $submedia ) ) !== false ) { |
|
| 123 | - $orderBaseProductItem->setMediaUrl( $mediaItem->getPreview() ); |
|
| 122 | + if (($mediaItem = reset($submedia)) !== false) { |
|
| 123 | + $orderBaseProductItem->setMediaUrl($mediaItem->getPreview()); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - $orderProductAttrManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' ); |
|
| 127 | - $variantAttributes = $productItem->getRefItems( 'attribute', null, 'variant' ); |
|
| 126 | + $orderProductAttrManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute'); |
|
| 127 | + $variantAttributes = $productItem->getRefItems('attribute', null, 'variant'); |
|
| 128 | 128 | |
| 129 | - foreach( $this->getAttributes( array_keys( $variantAttributes ), array( 'text' ) ) as $attrItem ) |
|
| 129 | + foreach ($this->getAttributes(array_keys($variantAttributes), array('text')) as $attrItem) |
|
| 130 | 130 | { |
| 131 | 131 | $orderAttributeItem = $orderProductAttrManager->createItem(); |
| 132 | - $orderAttributeItem->copyFrom( $attrItem ); |
|
| 133 | - $orderAttributeItem->setType( 'variant' ); |
|
| 132 | + $orderAttributeItem->copyFrom($attrItem); |
|
| 133 | + $orderAttributeItem->setType('variant'); |
|
| 134 | 134 | |
| 135 | 135 | $attr[] = $orderAttributeItem; |
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | - else if( !isset( $options['variant'] ) || $options['variant'] != false ) // count == 0 |
|
| 138 | + else if (!isset($options['variant']) || $options['variant'] != false) // count == 0 |
|
| 139 | 139 | { |
| 140 | - $msg = sprintf( 'No article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
|
| 141 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 140 | + $msg = sprintf('No article found for selected attributes and product ID "%1$s"', $productItem->getId()); |
|
| 141 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | return $attr; |
@@ -31,46 +31,46 @@ 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 | 44 | |
| 45 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
| 46 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
| 45 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
| 46 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
| 47 | 47 | |
| 48 | 48 | // customers can pay what they would like to pay |
| 49 | - if( ( $attr = $product->getAttributeItem( 'price', 'custom' ) ) !== null ) |
|
| 49 | + if (($attr = $product->getAttributeItem('price', 'custom')) !== null) |
|
| 50 | 50 | { |
| 51 | 51 | $amount = $attr->getValue(); |
| 52 | 52 | |
| 53 | - if( preg_match( '/^[0-9]*(\.[0-9]+)?$/', $amount ) !== 1 || ((double) $amount) < 0.01 ) { |
|
| 54 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid price value "%1$s"', $amount ) ); |
|
| 53 | + if (preg_match('/^[0-9]*(\.[0-9]+)?$/', $amount) !== 1 || ((double) $amount) < 0.01) { |
|
| 54 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Invalid price value "%1$s"', $amount)); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - $price->setValue( $amount ); |
|
| 57 | + $price->setValue($amount); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // add prices of (optional) attributes |
| 61 | - foreach( $this->getAttributeItems( $product->getAttributes() ) as $attrItem ) |
|
| 61 | + foreach ($this->getAttributeItems($product->getAttributes()) as $attrItem) |
|
| 62 | 62 | { |
| 63 | - $prices = $attrItem->getRefItems( 'price', 'default' ); |
|
| 63 | + $prices = $attrItem->getRefItems('price', 'default'); |
|
| 64 | 64 | |
| 65 | - if( count( $prices ) > 0 ) |
|
| 65 | + if (count($prices) > 0) |
|
| 66 | 66 | { |
| 67 | - $attrPrice = $priceManager->getLowestPrice( $prices, $quantity ); |
|
| 68 | - $price->addItem( $attrPrice ); |
|
| 67 | + $attrPrice = $priceManager->getLowestPrice($prices, $quantity); |
|
| 68 | + $price->addItem($attrPrice); |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // remove product rebate of original price in favor to rebates granted for the order |
| 73 | - $price->setRebate( '0.00' ); |
|
| 73 | + $price->setRebate('0.00'); |
|
| 74 | 74 | |
| 75 | 75 | return $price; |
| 76 | 76 | } |
@@ -84,42 +84,42 @@ discard block |
||
| 84 | 84 | * @param array $refMap Associative list of list type codes as keys and lists of reference IDs as values |
| 85 | 85 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated |
| 86 | 86 | */ |
| 87 | - protected function checkListRef( $prodId, $domain, array $refMap ) |
|
| 87 | + protected function checkListRef($prodId, $domain, array $refMap) |
|
| 88 | 88 | { |
| 89 | - if( empty( $refMap ) ) { |
|
| 89 | + if (empty($refMap)) { |
|
| 90 | 90 | return; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
| 94 | - $search = $productManager->createSearch( true ); |
|
| 93 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
| 94 | + $search = $productManager->createSearch(true); |
|
| 95 | 95 | |
| 96 | 96 | $expr = array( |
| 97 | - $search->compare( '==', 'product.id', $prodId ), |
|
| 97 | + $search->compare('==', 'product.id', $prodId), |
|
| 98 | 98 | $search->getConditions(), |
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | - foreach( $refMap as $listType => $refIds ) |
|
| 101 | + foreach ($refMap as $listType => $refIds) |
|
| 102 | 102 | { |
| 103 | - if( empty( $refIds ) ) { |
|
| 103 | + if (empty($refIds)) { |
|
| 104 | 104 | continue; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - foreach( $refIds as $key => $refId ) { |
|
| 107 | + foreach ($refIds as $key => $refId) { |
|
| 108 | 108 | $refIds[$key] = (string) $refId; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - $param = array( $domain, $this->getProductListTypeItem( $domain, $listType )->getId(), $refIds ); |
|
| 112 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
| 111 | + $param = array($domain, $this->getProductListTypeItem($domain, $listType)->getId(), $refIds); |
|
| 112 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
| 113 | 113 | |
| 114 | - $expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) ); |
|
| 114 | + $expr[] = $search->compare('==', $cmpfunc, count($refIds)); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 117 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 118 | 118 | |
| 119 | - if( count( $productManager->searchItems( $search, [] ) ) === 0 ) |
|
| 119 | + if (count($productManager->searchItems($search, [])) === 0) |
|
| 120 | 120 | { |
| 121 | - $msg = sprintf( 'Invalid "%1$s" references for product with ID %2$s', $domain, json_encode( $prodId ) ); |
|
| 122 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 121 | + $msg = sprintf('Invalid "%1$s" references for product with ID %2$s', $domain, json_encode($prodId)); |
|
| 122 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | |
@@ -134,34 +134,34 @@ discard block |
||
| 134 | 134 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated |
| 135 | 135 | * @deprecated Use checkListRef() instead |
| 136 | 136 | */ |
| 137 | - protected function checkReferences( $prodId, $domain, $listTypeId, array $refIds ) |
|
| 137 | + protected function checkReferences($prodId, $domain, $listTypeId, array $refIds) |
|
| 138 | 138 | { |
| 139 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
| 140 | - $search = $productManager->createSearch( true ); |
|
| 139 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
| 140 | + $search = $productManager->createSearch(true); |
|
| 141 | 141 | |
| 142 | 142 | $expr = array( |
| 143 | - $search->compare( '==', 'product.id', $prodId ), |
|
| 143 | + $search->compare('==', 'product.id', $prodId), |
|
| 144 | 144 | $search->getConditions(), |
| 145 | 145 | ); |
| 146 | 146 | |
| 147 | - if( count( $refIds ) > 0 ) |
|
| 147 | + if (count($refIds) > 0) |
|
| 148 | 148 | { |
| 149 | - foreach( $refIds as $key => $refId ) { |
|
| 149 | + foreach ($refIds as $key => $refId) { |
|
| 150 | 150 | $refIds[$key] = (string) $refId; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - $param = array( $domain, $listTypeId, $refIds ); |
|
| 154 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
| 153 | + $param = array($domain, $listTypeId, $refIds); |
|
| 154 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
| 155 | 155 | |
| 156 | - $expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) ); |
|
| 156 | + $expr[] = $search->compare('==', $cmpfunc, count($refIds)); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 159 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 160 | 160 | |
| 161 | - if( count( $productManager->searchItems( $search, [] ) ) === 0 ) |
|
| 161 | + if (count($productManager->searchItems($search, [])) === 0) |
|
| 162 | 162 | { |
| 163 | - $msg = sprintf( 'Invalid "%1$s" references for product with ID %2$s', $domain, json_encode( $prodId ) ); |
|
| 164 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 163 | + $msg = sprintf('Invalid "%1$s" references for product with ID %2$s', $domain, json_encode($prodId)); |
|
| 164 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
@@ -171,41 +171,41 @@ discard block |
||
| 171 | 171 | * |
| 172 | 172 | * @param string $type Basket type |
| 173 | 173 | */ |
| 174 | - protected function checkLocale( $type ) |
|
| 174 | + protected function checkLocale($type) |
|
| 175 | 175 | { |
| 176 | 176 | $errors = []; |
| 177 | 177 | $context = $this->getContext(); |
| 178 | 178 | $session = $context->getSession(); |
| 179 | 179 | $locale = $this->get()->getLocale(); |
| 180 | 180 | |
| 181 | - $localeStr = $session->get( 'aimeos/basket/locale' ); |
|
| 181 | + $localeStr = $session->get('aimeos/basket/locale'); |
|
| 182 | 182 | $localeKey = $locale->getSite()->getCode() . '|' . $locale->getLanguageId() . '|' . $locale->getCurrencyId(); |
| 183 | 183 | |
| 184 | - if( $localeStr !== null && $localeStr !== $localeKey ) |
|
| 184 | + if ($localeStr !== null && $localeStr !== $localeKey) |
|
| 185 | 185 | { |
| 186 | - $locParts = explode( '|', $localeStr ); |
|
| 187 | - $locSite = ( isset( $locParts[0] ) ? $locParts[0] : '' ); |
|
| 188 | - $locLanguage = ( isset( $locParts[1] ) ? $locParts[1] : '' ); |
|
| 189 | - $locCurrency = ( isset( $locParts[2] ) ? $locParts[2] : '' ); |
|
| 186 | + $locParts = explode('|', $localeStr); |
|
| 187 | + $locSite = (isset($locParts[0]) ? $locParts[0] : ''); |
|
| 188 | + $locLanguage = (isset($locParts[1]) ? $locParts[1] : ''); |
|
| 189 | + $locCurrency = (isset($locParts[2]) ? $locParts[2] : ''); |
|
| 190 | 190 | |
| 191 | - $localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' ); |
|
| 192 | - $locale = $localeManager->bootstrap( $locSite, $locLanguage, $locCurrency, false ); |
|
| 191 | + $localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale'); |
|
| 192 | + $locale = $localeManager->bootstrap($locSite, $locLanguage, $locCurrency, false); |
|
| 193 | 193 | |
| 194 | 194 | $context = clone $context; |
| 195 | - $context->setLocale( $locale ); |
|
| 195 | + $context->setLocale($locale); |
|
| 196 | 196 | |
| 197 | - $manager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context )->getSubManager( 'base' ); |
|
| 198 | - $basket = $manager->getSession( $type ); |
|
| 197 | + $manager = \Aimeos\MShop\Order\Manager\Factory::createManager($context)->getSubManager('base'); |
|
| 198 | + $basket = $manager->getSession($type); |
|
| 199 | 199 | |
| 200 | - $this->copyAddresses( $basket, $errors, $localeKey ); |
|
| 201 | - $this->copyServices( $basket, $errors ); |
|
| 202 | - $this->copyProducts( $basket, $errors, $localeKey ); |
|
| 203 | - $this->copyCoupons( $basket, $errors, $localeKey ); |
|
| 200 | + $this->copyAddresses($basket, $errors, $localeKey); |
|
| 201 | + $this->copyServices($basket, $errors); |
|
| 202 | + $this->copyProducts($basket, $errors, $localeKey); |
|
| 203 | + $this->copyCoupons($basket, $errors, $localeKey); |
|
| 204 | 204 | |
| 205 | - $manager->setSession( $basket, $type ); |
|
| 205 | + $manager->setSession($basket, $type); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - $session->set( 'aimeos/basket/locale', $localeKey ); |
|
| 208 | + $session->set('aimeos/basket/locale', $localeKey); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | |
@@ -217,20 +217,20 @@ discard block |
||
| 217 | 217 | * @param string $localeKey Unique identifier of the site, language and currency |
| 218 | 218 | * @return array Associative list of errors occured |
| 219 | 219 | */ |
| 220 | - protected function copyAddresses( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
| 220 | + protected function copyAddresses(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
| 221 | 221 | { |
| 222 | - foreach( $basket->getAddresses() as $type => $item ) |
|
| 222 | + foreach ($basket->getAddresses() as $type => $item) |
|
| 223 | 223 | { |
| 224 | 224 | try |
| 225 | 225 | { |
| 226 | - $this->setAddress( $type, $item->toArray() ); |
|
| 227 | - $basket->deleteAddress( $type ); |
|
| 226 | + $this->setAddress($type, $item->toArray()); |
|
| 227 | + $basket->deleteAddress($type); |
|
| 228 | 228 | } |
| 229 | - catch( \Exception $e ) |
|
| 229 | + catch (\Exception $e) |
|
| 230 | 230 | { |
| 231 | 231 | $logger = $this->getContext()->getLogger(); |
| 232 | 232 | $str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s'; |
| 233 | - $logger->log( sprintf( $str, $type, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
| 233 | + $logger->log(sprintf($str, $type, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
| 234 | 234 | $errors['address'][$type] = $e->getMessage(); |
| 235 | 235 | } |
| 236 | 236 | } |
@@ -247,20 +247,20 @@ discard block |
||
| 247 | 247 | * @param string $localeKey Unique identifier of the site, language and currency |
| 248 | 248 | * @return array Associative list of errors occured |
| 249 | 249 | */ |
| 250 | - protected function copyCoupons( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
| 250 | + protected function copyCoupons(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
| 251 | 251 | { |
| 252 | - foreach( $basket->getCoupons() as $code => $list ) |
|
| 252 | + foreach ($basket->getCoupons() as $code => $list) |
|
| 253 | 253 | { |
| 254 | 254 | try |
| 255 | 255 | { |
| 256 | - $this->addCoupon( $code ); |
|
| 257 | - $basket->deleteCoupon( $code, true ); |
|
| 256 | + $this->addCoupon($code); |
|
| 257 | + $basket->deleteCoupon($code, true); |
|
| 258 | 258 | } |
| 259 | - catch( \Exception $e ) |
|
| 259 | + catch (\Exception $e) |
|
| 260 | 260 | { |
| 261 | 261 | $logger = $this->getContext()->getLogger(); |
| 262 | 262 | $str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s'; |
| 263 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
| 263 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
| 264 | 264 | $errors['coupon'][$code] = $e->getMessage(); |
| 265 | 265 | } |
| 266 | 266 | } |
@@ -277,11 +277,11 @@ discard block |
||
| 277 | 277 | * @param string $localeKey Unique identifier of the site, language and currency |
| 278 | 278 | * @return array Associative list of errors occured |
| 279 | 279 | */ |
| 280 | - protected function copyProducts( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
| 280 | + protected function copyProducts(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
| 281 | 281 | { |
| 282 | - foreach( $basket->getProducts() as $pos => $product ) |
|
| 282 | + foreach ($basket->getProducts() as $pos => $product) |
|
| 283 | 283 | { |
| 284 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) { |
|
| 284 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) { |
|
| 285 | 285 | continue; |
| 286 | 286 | } |
| 287 | 287 | |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | { |
| 290 | 290 | $attrIds = []; |
| 291 | 291 | |
| 292 | - foreach( $product->getAttributes() as $attrItem ) { |
|
| 292 | + foreach ($product->getAttributes() as $attrItem) { |
|
| 293 | 293 | $attrIds[$attrItem->getType()][] = $attrItem->getAttributeId(); |
| 294 | 294 | } |
| 295 | 295 | |
@@ -297,23 +297,23 @@ discard block |
||
| 297 | 297 | $product->getProductId(), |
| 298 | 298 | $product->getQuantity(), |
| 299 | 299 | [], |
| 300 | - $this->getValue( $attrIds, 'variant', [] ), |
|
| 301 | - $this->getValue( $attrIds, 'config', [] ), |
|
| 302 | - $this->getValue( $attrIds, 'hidden', [] ), |
|
| 303 | - $this->getValue( $attrIds, 'custom', [] ), |
|
| 300 | + $this->getValue($attrIds, 'variant', []), |
|
| 301 | + $this->getValue($attrIds, 'config', []), |
|
| 302 | + $this->getValue($attrIds, 'hidden', []), |
|
| 303 | + $this->getValue($attrIds, 'custom', []), |
|
| 304 | 304 | $product->getStockType() |
| 305 | 305 | ); |
| 306 | 306 | |
| 307 | - $basket->deleteProduct( $pos ); |
|
| 307 | + $basket->deleteProduct($pos); |
|
| 308 | 308 | } |
| 309 | - catch( \Exception $e ) |
|
| 309 | + catch (\Exception $e) |
|
| 310 | 310 | { |
| 311 | 311 | $code = $product->getProductCode(); |
| 312 | 312 | $logger = $this->getContext()->getLogger(); |
| 313 | 313 | $errors['product'][$pos] = $e->getMessage(); |
| 314 | 314 | |
| 315 | 315 | $str = 'Error migrating product with code "%1$s" in basket to locale "%2$s": %3$s'; |
| 316 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
| 316 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
| 317 | 317 | } |
| 318 | 318 | } |
| 319 | 319 | |
@@ -328,22 +328,22 @@ discard block |
||
| 328 | 328 | * @param array $errors Associative list of previous errors |
| 329 | 329 | * @return array Associative list of errors occured |
| 330 | 330 | */ |
| 331 | - protected function copyServices( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors ) |
|
| 331 | + protected function copyServices(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors) |
|
| 332 | 332 | { |
| 333 | - foreach( $basket->getServices() as $type => $item ) |
|
| 333 | + foreach ($basket->getServices() as $type => $item) |
|
| 334 | 334 | { |
| 335 | 335 | try |
| 336 | 336 | { |
| 337 | 337 | $attributes = []; |
| 338 | 338 | |
| 339 | - foreach( $item->getAttributes() as $attrItem ) { |
|
| 339 | + foreach ($item->getAttributes() as $attrItem) { |
|
| 340 | 340 | $attributes[$attrItem->getCode()] = $attrItem->getValue(); |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - $this->setService( $type, $item->getServiceId(), $attributes ); |
|
| 344 | - $basket->deleteService( $type ); |
|
| 343 | + $this->setService($type, $item->getServiceId(), $attributes); |
|
| 344 | + $basket->deleteService($type); |
|
| 345 | 345 | } |
| 346 | - catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically |
|
| 346 | + catch (\Exception $e) {; } // Don't notify the user as appropriate services can be added automatically |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | return $errors; |
@@ -362,36 +362,36 @@ discard block |
||
| 362 | 362 | * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface |
| 363 | 363 | * @deprecated Use getOrderProductAttributes(), checkReferences() and calcPrice() instead |
| 364 | 364 | */ |
| 365 | - protected function createOrderProductAttributes( \Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
| 366 | - array $attributeIds, $type, array $attributeValues = [] ) |
|
| 365 | + protected function createOrderProductAttributes(\Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
| 366 | + array $attributeIds, $type, array $attributeValues = []) |
|
| 367 | 367 | { |
| 368 | - if( empty( $attributeIds ) ) { |
|
| 368 | + if (empty($attributeIds)) { |
|
| 369 | 369 | return []; |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - $attrTypeId = $this->getProductListTypeItem( 'attribute', $type )->getId(); |
|
| 373 | - $this->checkReferences( $prodid, 'attribute', $attrTypeId, $attributeIds ); |
|
| 372 | + $attrTypeId = $this->getProductListTypeItem('attribute', $type)->getId(); |
|
| 373 | + $this->checkReferences($prodid, 'attribute', $attrTypeId, $attributeIds); |
|
| 374 | 374 | |
| 375 | 375 | $list = []; |
| 376 | 376 | $context = $this->getContext(); |
| 377 | 377 | |
| 378 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
| 379 | - $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product/attribute' ); |
|
| 378 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
| 379 | + $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product/attribute'); |
|
| 380 | 380 | |
| 381 | - foreach( $this->getAttributes( $attributeIds ) as $id => $attrItem ) |
|
| 381 | + foreach ($this->getAttributes($attributeIds) as $id => $attrItem) |
|
| 382 | 382 | { |
| 383 | - $prices = $attrItem->getRefItems( 'price', 'default', 'default' ); |
|
| 383 | + $prices = $attrItem->getRefItems('price', 'default', 'default'); |
|
| 384 | 384 | |
| 385 | - if( !empty( $prices ) ) { |
|
| 386 | - $price->addItem( $priceManager->getLowestPrice( $prices, $quantity ) ); |
|
| 385 | + if (!empty($prices)) { |
|
| 386 | + $price->addItem($priceManager->getLowestPrice($prices, $quantity)); |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | $item = $orderProductAttributeManager->createItem(); |
| 390 | - $item->copyFrom( $attrItem ); |
|
| 391 | - $item->setType( $type ); |
|
| 390 | + $item->copyFrom($attrItem); |
|
| 391 | + $item->setType($type); |
|
| 392 | 392 | |
| 393 | - if( isset( $attributeValues[$id] ) ) { |
|
| 394 | - $item->setValue( $attributeValues[$id] ); |
|
| 393 | + if (isset($attributeValues[$id])) { |
|
| 394 | + $item->setValue($attributeValues[$id]); |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | $list[] = $item; |
@@ -409,31 +409,31 @@ discard block |
||
| 409 | 409 | * @return array List of items implementing \Aimeos\MShop\Attribute\Item\Iface |
| 410 | 410 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the actual attribute number doesn't match the expected one |
| 411 | 411 | */ |
| 412 | - protected function getAttributes( array $attributeIds, array $domains = array( 'price', 'text' ) ) |
|
| 412 | + protected function getAttributes(array $attributeIds, array $domains = array('price', 'text')) |
|
| 413 | 413 | { |
| 414 | - if( empty( $attributeIds ) ) { |
|
| 414 | + if (empty($attributeIds)) { |
|
| 415 | 415 | return []; |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
| 418 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
| 419 | 419 | |
| 420 | - $search = $attributeManager->createSearch( true ); |
|
| 420 | + $search = $attributeManager->createSearch(true); |
|
| 421 | 421 | $expr = array( |
| 422 | - $search->compare( '==', 'attribute.id', $attributeIds ), |
|
| 422 | + $search->compare('==', 'attribute.id', $attributeIds), |
|
| 423 | 423 | $search->getConditions(), |
| 424 | 424 | ); |
| 425 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 426 | - $search->setSlice( 0, 0x7fffffff ); |
|
| 425 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 426 | + $search->setSlice(0, 0x7fffffff); |
|
| 427 | 427 | |
| 428 | - $attrItems = $attributeManager->searchItems( $search, $domains ); |
|
| 428 | + $attrItems = $attributeManager->searchItems($search, $domains); |
|
| 429 | 429 | |
| 430 | - if( count( $attrItems ) !== count( $attributeIds ) ) |
|
| 430 | + if (count($attrItems) !== count($attributeIds)) |
|
| 431 | 431 | { |
| 432 | - $expected = implode( ',', $attributeIds ); |
|
| 433 | - $actual = implode( ',', array_keys( $attrItems ) ); |
|
| 434 | - $msg = sprintf( 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected ); |
|
| 432 | + $expected = implode(',', $attributeIds); |
|
| 433 | + $actual = implode(',', array_keys($attrItems)); |
|
| 434 | + $msg = sprintf('Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected); |
|
| 435 | 435 | |
| 436 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 436 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | return $attrItems; |
@@ -446,31 +446,31 @@ discard block |
||
| 446 | 446 | * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Item[] $orderAttributes List of order product attribute items |
| 447 | 447 | * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as key and attribute items as values |
| 448 | 448 | */ |
| 449 | - protected function getAttributeItems( array $orderAttributes ) |
|
| 449 | + protected function getAttributeItems(array $orderAttributes) |
|
| 450 | 450 | { |
| 451 | - if( empty( $orderAttributes ) ) { |
|
| 451 | + if (empty($orderAttributes)) { |
|
| 452 | 452 | return []; |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
| 456 | - $search = $attributeManager->createSearch( true ); |
|
| 455 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
| 456 | + $search = $attributeManager->createSearch(true); |
|
| 457 | 457 | $expr = []; |
| 458 | 458 | |
| 459 | - foreach( $orderAttributes as $item ) |
|
| 459 | + foreach ($orderAttributes as $item) |
|
| 460 | 460 | { |
| 461 | 461 | $tmp = array( |
| 462 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
| 463 | - $search->compare( '==', 'attribute.code', $item->getValue() ), |
|
| 464 | - $search->compare( '==', 'attribute.type.domain', 'product' ), |
|
| 465 | - $search->compare( '==', 'attribute.type.code', $item->getCode() ), |
|
| 466 | - $search->compare( '>', 'attribute.type.status', 0 ), |
|
| 462 | + $search->compare('==', 'attribute.domain', 'product'), |
|
| 463 | + $search->compare('==', 'attribute.code', $item->getValue()), |
|
| 464 | + $search->compare('==', 'attribute.type.domain', 'product'), |
|
| 465 | + $search->compare('==', 'attribute.type.code', $item->getCode()), |
|
| 466 | + $search->compare('>', 'attribute.type.status', 0), |
|
| 467 | 467 | $search->getConditions(), |
| 468 | 468 | ); |
| 469 | - $expr[] = $search->combine( '&&', $tmp ); |
|
| 469 | + $expr[] = $search->combine('&&', $tmp); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | - $search->setConditions( $search->combine( '||', $expr ) ); |
|
| 473 | - return $attributeManager->searchItems( $search, array( 'price' ) ); |
|
| 472 | + $search->setConditions($search->combine('||', $expr)); |
|
| 473 | + return $attributeManager->searchItems($search, array('price')); |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | |
@@ -485,23 +485,23 @@ discard block |
||
| 485 | 485 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
| 486 | 486 | * @deprecated Use getItem() or findItem() instead |
| 487 | 487 | */ |
| 488 | - protected function getDomainItem( $domain, $key, $value, array $ref ) |
|
| 488 | + protected function getDomainItem($domain, $key, $value, array $ref) |
|
| 489 | 489 | { |
| 490 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $domain ); |
|
| 490 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $domain); |
|
| 491 | 491 | |
| 492 | - $search = $manager->createSearch( true ); |
|
| 492 | + $search = $manager->createSearch(true); |
|
| 493 | 493 | $expr = array( |
| 494 | - $search->compare( '==', $key, $value ), |
|
| 494 | + $search->compare('==', $key, $value), |
|
| 495 | 495 | $search->getConditions(), |
| 496 | 496 | ); |
| 497 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 497 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 498 | 498 | |
| 499 | - $result = $manager->searchItems( $search, $ref ); |
|
| 499 | + $result = $manager->searchItems($search, $ref); |
|
| 500 | 500 | |
| 501 | - if( ( $item = reset( $result ) ) === false ) |
|
| 501 | + if (($item = reset($result)) === false) |
|
| 502 | 502 | { |
| 503 | - $msg = sprintf( 'No item for "%1$s" (%2$s) found', $value, $key ); |
|
| 504 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 503 | + $msg = sprintf('No item for "%1$s" (%2$s) found', $value, $key); |
|
| 504 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | return $item; |
@@ -516,23 +516,23 @@ discard block |
||
| 516 | 516 | * @param array $attributeValues Associative list of attribute IDs as keys and their codes as values |
| 517 | 517 | * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface |
| 518 | 518 | */ |
| 519 | - protected function getOrderProductAttributes( $type, array $attributeIds, array $attributeValues = [] ) |
|
| 519 | + protected function getOrderProductAttributes($type, array $attributeIds, array $attributeValues = []) |
|
| 520 | 520 | { |
| 521 | - if( empty( $attributeIds ) ) { |
|
| 521 | + if (empty($attributeIds)) { |
|
| 522 | 522 | return []; |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | $list = []; |
| 526 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' ); |
|
| 526 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute'); |
|
| 527 | 527 | |
| 528 | - foreach( $this->getAttributes( $attributeIds ) as $id => $attrItem ) |
|
| 528 | + foreach ($this->getAttributes($attributeIds) as $id => $attrItem) |
|
| 529 | 529 | { |
| 530 | 530 | $item = $manager->createItem(); |
| 531 | - $item->copyFrom( $attrItem ); |
|
| 532 | - $item->setType( $type ); |
|
| 531 | + $item->copyFrom($attrItem); |
|
| 532 | + $item->setType($type); |
|
| 533 | 533 | |
| 534 | - if( isset( $attributeValues[$id] ) ) { |
|
| 535 | - $item->setValue( $attributeValues[$id] ); |
|
| 534 | + if (isset($attributeValues[$id])) { |
|
| 535 | + $item->setValue($attributeValues[$id]); |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | $list[] = $item; |
@@ -549,21 +549,21 @@ discard block |
||
| 549 | 549 | * @param string $code Code of the list type |
| 550 | 550 | * @return \Aimeos\MShop\Common\Item\Type\Iface List type item |
| 551 | 551 | */ |
| 552 | - protected function getProductListTypeItem( $domain, $code ) |
|
| 552 | + protected function getProductListTypeItem($domain, $code) |
|
| 553 | 553 | { |
| 554 | - if( empty( $this->listTypeItems ) ) |
|
| 554 | + if (empty($this->listTypeItems)) |
|
| 555 | 555 | { |
| 556 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists/type' ); |
|
| 556 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists/type'); |
|
| 557 | 557 | |
| 558 | - foreach( $manager->searchItems( $manager->createSearch( true ) ) as $item ) { |
|
| 559 | - $this->listTypeItems[ $item->getDomain() ][ $item->getCode() ] = $item; |
|
| 558 | + foreach ($manager->searchItems($manager->createSearch(true)) as $item) { |
|
| 559 | + $this->listTypeItems[$item->getDomain()][$item->getCode()] = $item; |
|
| 560 | 560 | } |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | - if( !isset( $this->listTypeItems[$domain][$code] ) ) |
|
| 563 | + if (!isset($this->listTypeItems[$domain][$code])) |
|
| 564 | 564 | { |
| 565 | - $msg = sprintf( 'List type for domain "%1$s" and code "%2$s" not found', $domain, $code ); |
|
| 566 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 565 | + $msg = sprintf('List type for domain "%1$s" and code "%2$s" not found', $domain, $code); |
|
| 566 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 567 | 567 | } |
| 568 | 568 | |
| 569 | 569 | return $this->listTypeItems[$domain][$code]; |
@@ -578,43 +578,43 @@ discard block |
||
| 578 | 578 | * @param array $domains Names of the domain items that should be fetched too |
| 579 | 579 | * @return array List of products matching the given attributes |
| 580 | 580 | */ |
| 581 | - protected function getProductVariants( \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
| 582 | - array $domains = array( 'attribute', 'media', 'price', 'text' ) ) |
|
| 581 | + protected function getProductVariants(\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
| 582 | + array $domains = array('attribute', 'media', 'price', 'text')) |
|
| 583 | 583 | { |
| 584 | 584 | $subProductIds = []; |
| 585 | - foreach( $productItem->getRefItems( 'product', 'default', 'default' ) as $item ) { |
|
| 585 | + foreach ($productItem->getRefItems('product', 'default', 'default') as $item) { |
|
| 586 | 586 | $subProductIds[] = $item->getId(); |
| 587 | 587 | } |
| 588 | 588 | |
| 589 | - if( count( $subProductIds ) === 0 ) { |
|
| 589 | + if (count($subProductIds) === 0) { |
|
| 590 | 590 | return []; |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
| 594 | - $search = $productManager->createSearch( true ); |
|
| 593 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
| 594 | + $search = $productManager->createSearch(true); |
|
| 595 | 595 | |
| 596 | 596 | $expr = array( |
| 597 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
| 597 | + $search->compare('==', 'product.id', $subProductIds), |
|
| 598 | 598 | $search->getConditions(), |
| 599 | 599 | ); |
| 600 | 600 | |
| 601 | - if( count( $variantAttributeIds ) > 0 ) |
|
| 601 | + if (count($variantAttributeIds) > 0) |
|
| 602 | 602 | { |
| 603 | - foreach( $variantAttributeIds as $key => $id ) { |
|
| 603 | + foreach ($variantAttributeIds as $key => $id) { |
|
| 604 | 604 | $variantAttributeIds[$key] = (string) $id; |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | - $listTypeItem = $this->getProductListTypeItem( 'attribute', 'variant' ); |
|
| 607 | + $listTypeItem = $this->getProductListTypeItem('attribute', 'variant'); |
|
| 608 | 608 | |
| 609 | - $param = array( 'attribute', $listTypeItem->getId(), $variantAttributeIds ); |
|
| 610 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
| 609 | + $param = array('attribute', $listTypeItem->getId(), $variantAttributeIds); |
|
| 610 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
| 611 | 611 | |
| 612 | - $expr[] = $search->compare( '==', $cmpfunc, count( $variantAttributeIds ) ); |
|
| 612 | + $expr[] = $search->compare('==', $cmpfunc, count($variantAttributeIds)); |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 615 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 616 | 616 | |
| 617 | - return $productManager->searchItems( $search, $domains ); |
|
| 617 | + return $productManager->searchItems($search, $domains); |
|
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | |
@@ -626,9 +626,9 @@ discard block |
||
| 626 | 626 | * @param mixed $default Default value if no value is available for the given name |
| 627 | 627 | * @return mixed Value from the array or default value |
| 628 | 628 | */ |
| 629 | - protected function getValue( array $values, $name, $default = null ) |
|
| 629 | + protected function getValue(array $values, $name, $default = null) |
|
| 630 | 630 | { |
| 631 | - if( isset( $values[$name] ) ) { |
|
| 631 | + if (isset($values[$name])) { |
|
| 632 | 632 | return $values[$name]; |
| 633 | 633 | } |
| 634 | 634 | |
@@ -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; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @category Developer |
| 127 | 127 | * @see controller/frontend/basket/limit-seconds |
| 128 | 128 | */ |
| 129 | - $count = $config->get( 'controller/frontend/basket/limit-count', 5 ); |
|
| 129 | + $count = $config->get('controller/frontend/basket/limit-count', 5); |
|
| 130 | 130 | |
| 131 | 131 | /** controller/frontend/basket/limit-seconds |
| 132 | 132 | * Order limitation time frame in seconds |
@@ -144,27 +144,27 @@ discard block |
||
| 144 | 144 | * @category Developer |
| 145 | 145 | * @see controller/frontend/basket/limit-count |
| 146 | 146 | */ |
| 147 | - $seconds = $config->get( 'controller/frontend/basket/limit-seconds', 300 ); |
|
| 147 | + $seconds = $config->get('controller/frontend/basket/limit-seconds', 300); |
|
| 148 | 148 | |
| 149 | 149 | $search = $this->domainManager->createSearch(); |
| 150 | 150 | $expr = [ |
| 151 | - $search->compare( '==', 'order.base.editor', $this->getContext()->getEditor() ), |
|
| 152 | - $search->compare( '>=', 'order.base.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ), |
|
| 151 | + $search->compare('==', 'order.base.editor', $this->getContext()->getEditor()), |
|
| 152 | + $search->compare('>=', 'order.base.ctime', date('Y-m-d H:i:s', time() - $seconds)), |
|
| 153 | 153 | ]; |
| 154 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 155 | - $search->setSlice( 0, 0 ); |
|
| 154 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 155 | + $search->setSlice(0, 0); |
|
| 156 | 156 | |
| 157 | - $this->domainManager->searchItems( $search, [], $total ); |
|
| 157 | + $this->domainManager->searchItems($search, [], $total); |
|
| 158 | 158 | |
| 159 | - if( $total > $count ) { |
|
| 160 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Temporary order limit reached' ) ); |
|
| 159 | + if ($total > $count) { |
|
| 160 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Temporary order limit reached')); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | |
| 164 | 164 | $basket = $this->get()->finish(); |
| 165 | 165 | |
| 166 | 166 | $this->domainManager->begin(); |
| 167 | - $this->domainManager->store( $basket ); |
|
| 167 | + $this->domainManager->store($basket); |
|
| 168 | 168 | $this->domainManager->commit(); |
| 169 | 169 | |
| 170 | 170 | return $basket; |
@@ -179,9 +179,9 @@ discard block |
||
| 179 | 179 | * @param boolean $default True to add default criteria (user logged in), false if not |
| 180 | 180 | * @return \Aimeos\MShop\Order\Item\Base\Iface Order base object including the given parts |
| 181 | 181 | */ |
| 182 | - public function load( $id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true ) |
|
| 182 | + public function load($id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true) |
|
| 183 | 183 | { |
| 184 | - return $this->domainManager->load( $id, $parts, false, $default ); |
|
| 184 | + return $this->domainManager->load($id, $parts, false, $default); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | |
@@ -201,34 +201,34 @@ discard block |
||
| 201 | 201 | * @param string $stocktype Unique code of the stock type to deliver the products from |
| 202 | 202 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
| 203 | 203 | */ |
| 204 | - public function addProduct( $prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
| 204 | + public function addProduct($prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
| 205 | 205 | array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [], |
| 206 | - $stocktype = 'default' ) |
|
| 206 | + $stocktype = 'default') |
|
| 207 | 207 | { |
| 208 | 208 | $attributeMap = [ |
| 209 | - 'custom' => array_keys( $customAttributeValues ), |
|
| 209 | + 'custom' => array_keys($customAttributeValues), |
|
| 210 | 210 | 'config' => $configAttributeIds, |
| 211 | 211 | 'hidden' => $hiddenAttributeIds, |
| 212 | 212 | ]; |
| 213 | - $this->checkListRef( $prodid, 'attribute', $attributeMap ); |
|
| 213 | + $this->checkListRef($prodid, 'attribute', $attributeMap); |
|
| 214 | 214 | |
| 215 | 215 | |
| 216 | 216 | $context = $this->getContext(); |
| 217 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
| 218 | - $productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true ); |
|
| 219 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
| 217 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
| 218 | + $productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true); |
|
| 219 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
| 220 | 220 | |
| 221 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
| 222 | - $orderBaseProductItem->copyFrom( $productItem )->setQuantity( $quantity )->setStockType( $stocktype ); |
|
| 221 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
| 222 | + $orderBaseProductItem->copyFrom($productItem)->setQuantity($quantity)->setStockType($stocktype); |
|
| 223 | 223 | |
| 224 | - $attr = $this->getOrderProductAttributes( 'custom', array_keys( $customAttributeValues ), $customAttributeValues ); |
|
| 225 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'config', $configAttributeIds ) ); |
|
| 226 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'hidden', $hiddenAttributeIds ) ); |
|
| 224 | + $attr = $this->getOrderProductAttributes('custom', array_keys($customAttributeValues), $customAttributeValues); |
|
| 225 | + $attr = array_merge($attr, $this->getOrderProductAttributes('config', $configAttributeIds)); |
|
| 226 | + $attr = array_merge($attr, $this->getOrderProductAttributes('hidden', $hiddenAttributeIds)); |
|
| 227 | 227 | |
| 228 | - $orderBaseProductItem->setAttributes( $attr ); |
|
| 229 | - $orderBaseProductItem->setPrice( $this->calcPrice( $orderBaseProductItem, $prices, $quantity ) ); |
|
| 228 | + $orderBaseProductItem->setAttributes($attr); |
|
| 229 | + $orderBaseProductItem->setPrice($this->calcPrice($orderBaseProductItem, $prices, $quantity)); |
|
| 230 | 230 | |
| 231 | - $this->get()->addProduct( $orderBaseProductItem ); |
|
| 231 | + $this->get()->addProduct($orderBaseProductItem); |
|
| 232 | 232 | $this->save(); |
| 233 | 233 | } |
| 234 | 234 | |
@@ -238,17 +238,17 @@ discard block |
||
| 238 | 238 | * |
| 239 | 239 | * @param integer $position Position number (key) of the order product item |
| 240 | 240 | */ |
| 241 | - public function deleteProduct( $position ) |
|
| 241 | + public function deleteProduct($position) |
|
| 242 | 242 | { |
| 243 | - $product = $this->get()->getProduct( $position ); |
|
| 243 | + $product = $this->get()->getProduct($position); |
|
| 244 | 244 | |
| 245 | - if( $product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
| 245 | + if ($product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
| 246 | 246 | { |
| 247 | - $msg = sprintf( 'Basket item at position "%1$d" cannot be deleted manually', $position ); |
|
| 248 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 247 | + $msg = sprintf('Basket item at position "%1$d" cannot be deleted manually', $position); |
|
| 248 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - $this->get()->deleteProduct( $position ); |
|
| 251 | + $this->get()->deleteProduct($position); |
|
| 252 | 252 | $this->save(); |
| 253 | 253 | } |
| 254 | 254 | |
@@ -262,33 +262,33 @@ discard block |
||
| 262 | 262 | * The 'stock'=>false option allows adding products without being in stock. |
| 263 | 263 | * @param string[] $configAttributeCodes Codes of the product config attributes that should be REMOVED |
| 264 | 264 | */ |
| 265 | - public function editProduct( $position, $quantity, array $options = [], |
|
| 266 | - array $configAttributeCodes = [] ) |
|
| 265 | + public function editProduct($position, $quantity, array $options = [], |
|
| 266 | + array $configAttributeCodes = []) |
|
| 267 | 267 | { |
| 268 | - $product = $this->get()->getProduct( $position ); |
|
| 268 | + $product = $this->get()->getProduct($position); |
|
| 269 | 269 | |
| 270 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
| 270 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
| 271 | 271 | { |
| 272 | - $msg = sprintf( 'Basket item at position "%1$d" cannot be changed', $position ); |
|
| 273 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 272 | + $msg = sprintf('Basket item at position "%1$d" cannot be changed', $position); |
|
| 273 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - $product->setQuantity( $quantity ); |
|
| 276 | + $product->setQuantity($quantity); |
|
| 277 | 277 | |
| 278 | 278 | $attributes = $product->getAttributes(); |
| 279 | - foreach( $attributes as $key => $attribute ) |
|
| 279 | + foreach ($attributes as $key => $attribute) |
|
| 280 | 280 | { |
| 281 | - if( in_array( $attribute->getCode(), $configAttributeCodes ) ) { |
|
| 282 | - unset( $attributes[$key] ); |
|
| 281 | + if (in_array($attribute->getCode(), $configAttributeCodes)) { |
|
| 282 | + unset($attributes[$key]); |
|
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | - $product->setAttributes( $attributes ); |
|
| 285 | + $product->setAttributes($attributes); |
|
| 286 | 286 | |
| 287 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
| 288 | - $productItem = $manager->findItem( $product->getProductCode(), array( 'price', 'text' ) ); |
|
| 289 | - $product->setPrice( $this->calcPrice( $product, $productItem->getRefItems( 'price', 'default' ), $quantity ) ); |
|
| 287 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
| 288 | + $productItem = $manager->findItem($product->getProductCode(), array('price', 'text')); |
|
| 289 | + $product->setPrice($this->calcPrice($product, $productItem->getRefItems('price', 'default'), $quantity)); |
|
| 290 | 290 | |
| 291 | - $this->get()->editProduct( $product, $position ); |
|
| 291 | + $this->get()->editProduct($product, $position); |
|
| 292 | 292 | |
| 293 | 293 | $this->save(); |
| 294 | 294 | } |
@@ -300,49 +300,49 @@ discard block |
||
| 300 | 300 | * @param string $code Coupon code entered by the user |
| 301 | 301 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
| 302 | 302 | */ |
| 303 | - public function addCoupon( $code ) |
|
| 303 | + public function addCoupon($code) |
|
| 304 | 304 | { |
| 305 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
| 306 | - $codeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon/code' ); |
|
| 305 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
| 306 | + $codeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon/code'); |
|
| 307 | 307 | |
| 308 | 308 | |
| 309 | - $search = $codeManager->createSearch( true ); |
|
| 309 | + $search = $codeManager->createSearch(true); |
|
| 310 | 310 | $expr = array( |
| 311 | - $search->compare( '==', 'coupon.code.code', $code ), |
|
| 311 | + $search->compare('==', 'coupon.code.code', $code), |
|
| 312 | 312 | $search->getConditions(), |
| 313 | 313 | ); |
| 314 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 315 | - $search->setSlice( 0, 1 ); |
|
| 314 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 315 | + $search->setSlice(0, 1); |
|
| 316 | 316 | |
| 317 | - $result = $codeManager->searchItems( $search ); |
|
| 317 | + $result = $codeManager->searchItems($search); |
|
| 318 | 318 | |
| 319 | - if( ( $codeItem = reset( $result ) ) === false ) { |
|
| 320 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid or not available any more', $code ) ); |
|
| 319 | + if (($codeItem = reset($result)) === false) { |
|
| 320 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid or not available any more', $code)); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | |
| 324 | - $search = $manager->createSearch( true ); |
|
| 324 | + $search = $manager->createSearch(true); |
|
| 325 | 325 | $expr = array( |
| 326 | - $search->compare( '==', 'coupon.id', $codeItem->getParentId() ), |
|
| 326 | + $search->compare('==', 'coupon.id', $codeItem->getParentId()), |
|
| 327 | 327 | $search->getConditions(), |
| 328 | 328 | ); |
| 329 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 330 | - $search->setSlice( 0, 1 ); |
|
| 329 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 330 | + $search->setSlice(0, 1); |
|
| 331 | 331 | |
| 332 | - $result = $manager->searchItems( $search ); |
|
| 332 | + $result = $manager->searchItems($search); |
|
| 333 | 333 | |
| 334 | - if( ( $item = reset( $result ) ) === false ) { |
|
| 335 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon for code "%1$s" is not available any more', $code ) ); |
|
| 334 | + if (($item = reset($result)) === false) { |
|
| 335 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon for code "%1$s" is not available any more', $code)); |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | |
| 339 | - $provider = $manager->getProvider( $item, $code ); |
|
| 339 | + $provider = $manager->getProvider($item, $code); |
|
| 340 | 340 | |
| 341 | - if( $provider->isAvailable( $this->get() ) !== true ) { |
|
| 342 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Requirements for coupon code "%1$s" aren\'t met', $code ) ); |
|
| 341 | + if ($provider->isAvailable($this->get()) !== true) { |
|
| 342 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Requirements for coupon code "%1$s" aren\'t met', $code)); |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - $provider->addCoupon( $this->get() ); |
|
| 345 | + $provider->addCoupon($this->get()); |
|
| 346 | 346 | $this->save(); |
| 347 | 347 | } |
| 348 | 348 | |
@@ -353,21 +353,21 @@ discard block |
||
| 353 | 353 | * @param string $code Coupon code entered by the user |
| 354 | 354 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
| 355 | 355 | */ |
| 356 | - public function deleteCoupon( $code ) |
|
| 356 | + public function deleteCoupon($code) |
|
| 357 | 357 | { |
| 358 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
| 358 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
| 359 | 359 | |
| 360 | 360 | $search = $manager->createSearch(); |
| 361 | - $search->setConditions( $search->compare( '==', 'coupon.code.code', $code ) ); |
|
| 362 | - $search->setSlice( 0, 1 ); |
|
| 361 | + $search->setConditions($search->compare('==', 'coupon.code.code', $code)); |
|
| 362 | + $search->setSlice(0, 1); |
|
| 363 | 363 | |
| 364 | - $result = $manager->searchItems( $search ); |
|
| 364 | + $result = $manager->searchItems($search); |
|
| 365 | 365 | |
| 366 | - if( ( $item = reset( $result ) ) === false ) { |
|
| 367 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid', $code ) ); |
|
| 366 | + if (($item = reset($result)) === false) { |
|
| 367 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid', $code)); |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | - $manager->getProvider( $item, $code )->deleteCoupon( $this->get() ); |
|
| 370 | + $manager->getProvider($item, $code)->deleteCoupon($this->get()); |
|
| 371 | 371 | $this->save(); |
| 372 | 372 | } |
| 373 | 373 | |
@@ -380,28 +380,28 @@ discard block |
||
| 380 | 380 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the billing or delivery address is not of any required type of |
| 381 | 381 | * if one of the keys is invalid when using an array with key/value pairs |
| 382 | 382 | */ |
| 383 | - public function setAddress( $type, $value ) |
|
| 383 | + public function setAddress($type, $value) |
|
| 384 | 384 | { |
| 385 | - $address = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/address' )->createItem(); |
|
| 386 | - $address->setType( $type ); |
|
| 385 | + $address = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/address')->createItem(); |
|
| 386 | + $address->setType($type); |
|
| 387 | 387 | |
| 388 | - if( $value instanceof \Aimeos\MShop\Common\Item\Address\Iface ) |
|
| 388 | + if ($value instanceof \Aimeos\MShop\Common\Item\Address\Iface) |
|
| 389 | 389 | { |
| 390 | - $address->copyFrom( $value ); |
|
| 391 | - $this->get()->setAddress( $address, $type ); |
|
| 390 | + $address->copyFrom($value); |
|
| 391 | + $this->get()->setAddress($address, $type); |
|
| 392 | 392 | } |
| 393 | - else if( is_array( $value ) ) |
|
| 393 | + else if (is_array($value)) |
|
| 394 | 394 | { |
| 395 | - $this->setAddressFromArray( $address, $value ); |
|
| 396 | - $this->get()->setAddress( $address, $type ); |
|
| 395 | + $this->setAddressFromArray($address, $value); |
|
| 396 | + $this->get()->setAddress($address, $type); |
|
| 397 | 397 | } |
| 398 | - else if( $value === null ) |
|
| 398 | + else if ($value === null) |
|
| 399 | 399 | { |
| 400 | - $this->get()->deleteAddress( $type ); |
|
| 400 | + $this->get()->deleteAddress($type); |
|
| 401 | 401 | } |
| 402 | 402 | else |
| 403 | 403 | { |
| 404 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid value for address type "%1$s"', $type ) ); |
|
| 404 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Invalid value for address type "%1$s"', $type)); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | $this->save(); |
@@ -417,48 +417,48 @@ discard block |
||
| 417 | 417 | * entered by the customer when choosing one of the delivery or payment options |
| 418 | 418 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
| 419 | 419 | */ |
| 420 | - public function setService( $type, $id, array $attributes = [] ) |
|
| 420 | + public function setService($type, $id, array $attributes = []) |
|
| 421 | 421 | { |
| 422 | - if( $id === null ) |
|
| 422 | + if ($id === null) |
|
| 423 | 423 | { |
| 424 | - $this->get()->deleteService( $type ); |
|
| 424 | + $this->get()->deleteService($type); |
|
| 425 | 425 | $this->save(); |
| 426 | 426 | return; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | $context = $this->getContext(); |
| 430 | 430 | |
| 431 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' ); |
|
| 432 | - $serviceItem = $serviceManager->getItem( $id, array( 'media', 'price', 'text' ) ); |
|
| 431 | + $serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service'); |
|
| 432 | + $serviceItem = $serviceManager->getItem($id, array('media', 'price', 'text')); |
|
| 433 | 433 | |
| 434 | - $provider = $serviceManager->getProvider( $serviceItem ); |
|
| 435 | - $result = $provider->checkConfigFE( $attributes ); |
|
| 436 | - $unknown = array_diff_key( $attributes, $result ); |
|
| 434 | + $provider = $serviceManager->getProvider($serviceItem); |
|
| 435 | + $result = $provider->checkConfigFE($attributes); |
|
| 436 | + $unknown = array_diff_key($attributes, $result); |
|
| 437 | 437 | |
| 438 | - if( count( $unknown ) > 0 ) |
|
| 438 | + if (count($unknown) > 0) |
|
| 439 | 439 | { |
| 440 | - $msg = sprintf( 'Unknown attributes "%1$s"', implode( '","', array_keys( $unknown ) ) ); |
|
| 441 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 440 | + $msg = sprintf('Unknown attributes "%1$s"', implode('","', array_keys($unknown))); |
|
| 441 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - foreach( $result as $key => $value ) |
|
| 444 | + foreach ($result as $key => $value) |
|
| 445 | 445 | { |
| 446 | - if( $value !== null ) { |
|
| 447 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $value ); |
|
| 446 | + if ($value !== null) { |
|
| 447 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($value); |
|
| 448 | 448 | } |
| 449 | 449 | } |
| 450 | 450 | |
| 451 | - $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/service' ); |
|
| 451 | + $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/service'); |
|
| 452 | 452 | $orderServiceItem = $orderBaseServiceManager->createItem(); |
| 453 | - $orderServiceItem->copyFrom( $serviceItem ); |
|
| 453 | + $orderServiceItem->copyFrom($serviceItem); |
|
| 454 | 454 | |
| 455 | 455 | // remove service rebate of original price |
| 456 | - $price = $provider->calcPrice( $this->get() )->setRebate( '0.00' ); |
|
| 457 | - $orderServiceItem->setPrice( $price ); |
|
| 456 | + $price = $provider->calcPrice($this->get())->setRebate('0.00'); |
|
| 457 | + $orderServiceItem->setPrice($price); |
|
| 458 | 458 | |
| 459 | - $provider->setConfigFE( $orderServiceItem, $attributes ); |
|
| 459 | + $provider->setConfigFE($orderServiceItem, $attributes); |
|
| 460 | 460 | |
| 461 | - $this->get()->setService( $orderServiceItem, $type ); |
|
| 461 | + $this->get()->setService($orderServiceItem, $type); |
|
| 462 | 462 | $this->save(); |
| 463 | 463 | } |
| 464 | 464 | |
@@ -471,18 +471,18 @@ discard block |
||
| 471 | 471 | * an address item. |
| 472 | 472 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
| 473 | 473 | */ |
| 474 | - protected function setAddressFromArray( \Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map ) |
|
| 474 | + protected function setAddressFromArray(\Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map) |
|
| 475 | 475 | { |
| 476 | - foreach( $map as $key => $value ) { |
|
| 477 | - $map[$key] = strip_tags( $value ); // prevent XSS |
|
| 476 | + foreach ($map as $key => $value) { |
|
| 477 | + $map[$key] = strip_tags($value); // prevent XSS |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | - $errors = $address->fromArray( $map ); |
|
| 480 | + $errors = $address->fromArray($map); |
|
| 481 | 481 | |
| 482 | - if( count( $errors ) > 0 ) |
|
| 482 | + if (count($errors) > 0) |
|
| 483 | 483 | { |
| 484 | - $msg = sprintf( 'Invalid address properties, please check your input' ); |
|
| 485 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg, 0, null, $errors ); |
|
| 484 | + $msg = sprintf('Invalid address properties, please check your input'); |
|
| 485 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg, 0, null, $errors); |
|
| 486 | 486 | } |
| 487 | 487 | } |
| 488 | 488 | } |
@@ -19,112 +19,112 @@ discard block |
||
| 19 | 19 | public static function setUpBeforeClass() |
| 20 | 20 | { |
| 21 | 21 | $context = \TestHelperFrontend::getContext(); |
| 22 | - self::$testItem = \Aimeos\MShop\Factory::createManager( $context, 'product' )->findItem( 'U:TESTP' ); |
|
| 22 | + self::$testItem = \Aimeos\MShop\Factory::createManager($context, 'product')->findItem('U:TESTP'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | protected function setUp() |
| 27 | 27 | { |
| 28 | - \Aimeos\MShop\Factory::setCache( true ); |
|
| 28 | + \Aimeos\MShop\Factory::setCache(true); |
|
| 29 | 29 | |
| 30 | 30 | $this->context = \TestHelperFrontend::getContext(); |
| 31 | - $this->object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 31 | + $this->object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | |
| 35 | 35 | protected function tearDown() |
| 36 | 36 | { |
| 37 | - \Aimeos\MShop\Factory::setCache( false ); |
|
| 37 | + \Aimeos\MShop\Factory::setCache(false); |
|
| 38 | 38 | \Aimeos\MShop\Factory::clear(); |
| 39 | 39 | |
| 40 | 40 | $this->object->clear(); |
| 41 | - $this->context->getSession()->set( 'aimeos', [] ); |
|
| 41 | + $this->context->getSession()->set('aimeos', []); |
|
| 42 | 42 | |
| 43 | - unset( $this->context, $this->object ); |
|
| 43 | + unset($this->context, $this->object); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | |
| 47 | 47 | public function testClear() |
| 48 | 48 | { |
| 49 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
| 49 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
| 50 | 50 | $this->object->clear(); |
| 51 | 51 | |
| 52 | - $this->assertEquals( 0, count( $this->object->get()->getProducts() ) ); |
|
| 52 | + $this->assertEquals(0, count($this->object->get()->getProducts())); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | public function testGet() |
| 57 | 57 | { |
| 58 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Iface', $this->object->get() ); |
|
| 58 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Base\Iface', $this->object->get()); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | |
| 62 | 62 | public function testSave() |
| 63 | 63 | { |
| 64 | - $stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' ) |
|
| 65 | - ->setConstructorArgs( [$this->context] ) |
|
| 66 | - ->setMethods( ['setSession'] ) |
|
| 64 | + $stub = $this->getMockBuilder('\Aimeos\MShop\Order\Manager\Base\Standard') |
|
| 65 | + ->setConstructorArgs([$this->context]) |
|
| 66 | + ->setMethods(['setSession']) |
|
| 67 | 67 | ->getMock(); |
| 68 | 68 | |
| 69 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub ); |
|
| 69 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $stub); |
|
| 70 | 70 | |
| 71 | - $stub->expects( $this->exactly( 2 ) )->method( 'setSession' ); |
|
| 71 | + $stub->expects($this->exactly(2))->method('setSession'); |
|
| 72 | 72 | |
| 73 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 74 | - $object->addProduct( self::$testItem->getId(), 2 ); |
|
| 73 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 74 | + $object->addProduct(self::$testItem->getId(), 2); |
|
| 75 | 75 | $object->save(); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | |
| 79 | 79 | public function testSetType() |
| 80 | 80 | { |
| 81 | - $this->assertInstanceOf( '\Aimeos\Controller\Frontend\Basket\Iface', $this->object->setType( 'test' ) ); |
|
| 81 | + $this->assertInstanceOf('\Aimeos\Controller\Frontend\Basket\Iface', $this->object->setType('test')); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | |
| 85 | 85 | public function testStore() |
| 86 | 86 | { |
| 87 | - $stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' ) |
|
| 88 | - ->setConstructorArgs( [$this->context] ) |
|
| 89 | - ->setMethods( ['store'] ) |
|
| 87 | + $stub = $this->getMockBuilder('\Aimeos\MShop\Order\Manager\Base\Standard') |
|
| 88 | + ->setConstructorArgs([$this->context]) |
|
| 89 | + ->setMethods(['store']) |
|
| 90 | 90 | ->getMock(); |
| 91 | 91 | |
| 92 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub ); |
|
| 92 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $stub); |
|
| 93 | 93 | |
| 94 | - $stub->expects( $this->once() )->method( 'store' ); |
|
| 94 | + $stub->expects($this->once())->method('store'); |
|
| 95 | 95 | |
| 96 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 96 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 97 | 97 | $object->store(); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
| 101 | 101 | public function testStoreLimit() |
| 102 | 102 | { |
| 103 | - $this->context->setEditor( 'core:unittest' ); |
|
| 103 | + $this->context->setEditor('core:unittest'); |
|
| 104 | 104 | $config = $this->context->getConfig(); |
| 105 | - $config->set( 'controller/frontend/basket/limit-count', 0 ); |
|
| 106 | - $config->set( 'controller/frontend/basket/limit-seconds', 86400 * 365 ); |
|
| 105 | + $config->set('controller/frontend/basket/limit-count', 0); |
|
| 106 | + $config->set('controller/frontend/basket/limit-seconds', 86400 * 365); |
|
| 107 | 107 | |
| 108 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 108 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 109 | 109 | |
| 110 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Basket\Exception' ); |
|
| 110 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Basket\Exception'); |
|
| 111 | 111 | $object->store(); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | |
| 115 | 115 | public function testLoad() |
| 116 | 116 | { |
| 117 | - $stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' ) |
|
| 118 | - ->setConstructorArgs( [$this->context] ) |
|
| 119 | - ->setMethods( ['load'] ) |
|
| 117 | + $stub = $this->getMockBuilder('\Aimeos\MShop\Order\Manager\Base\Standard') |
|
| 118 | + ->setConstructorArgs([$this->context]) |
|
| 119 | + ->setMethods(['load']) |
|
| 120 | 120 | ->getMock(); |
| 121 | 121 | |
| 122 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub ); |
|
| 122 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $stub); |
|
| 123 | 123 | |
| 124 | - $stub->expects( $this->once() )->method( 'load' ) |
|
| 125 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
| 124 | + $stub->expects($this->once())->method('load') |
|
| 125 | + ->will($this->returnValue($stub->createItem())); |
|
| 126 | 126 | |
| 127 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 127 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 128 | 128 | $object->load( -1 ); |
| 129 | 129 | } |
| 130 | 130 | |
@@ -132,301 +132,301 @@ discard block |
||
| 132 | 132 | public function testAddDeleteProduct() |
| 133 | 133 | { |
| 134 | 134 | $basket = $this->object->get(); |
| 135 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' ); |
|
| 135 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC'); |
|
| 136 | 136 | |
| 137 | - $this->object->addProduct( $item->getId(), 2, [], [], [], [], [], 'default' ); |
|
| 138 | - $item2 = $this->object->get()->getProduct( 0 ); |
|
| 139 | - $this->object->deleteProduct( 0 ); |
|
| 137 | + $this->object->addProduct($item->getId(), 2, [], [], [], [], [], 'default'); |
|
| 138 | + $item2 = $this->object->get()->getProduct(0); |
|
| 139 | + $this->object->deleteProduct(0); |
|
| 140 | 140 | |
| 141 | - $this->assertEquals( 0, count( $basket->getProducts() ) ); |
|
| 142 | - $this->assertEquals( 'CNC', $item2->getProductCode() ); |
|
| 141 | + $this->assertEquals(0, count($basket->getProducts())); |
|
| 142 | + $this->assertEquals('CNC', $item2->getProductCode()); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | |
| 146 | 146 | public function testAddProductCustomAttribute() |
| 147 | 147 | { |
| 148 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 148 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 149 | 149 | |
| 150 | 150 | $search = $attributeManager->createSearch(); |
| 151 | 151 | $expr = array( |
| 152 | - $search->compare( '==', 'attribute.code', 'custom' ), |
|
| 153 | - $search->compare( '==', 'attribute.type.code', 'date' ), |
|
| 152 | + $search->compare('==', 'attribute.code', 'custom'), |
|
| 153 | + $search->compare('==', 'attribute.type.code', 'date'), |
|
| 154 | 154 | ); |
| 155 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 155 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 156 | 156 | |
| 157 | - $attributes = $attributeManager->searchItems( $search ); |
|
| 157 | + $attributes = $attributeManager->searchItems($search); |
|
| 158 | 158 | |
| 159 | - if( ( $attrItem = reset( $attributes ) ) === false ) { |
|
| 160 | - throw new \RuntimeException( 'Attribute not found' ); |
|
| 159 | + if (($attrItem = reset($attributes)) === false) { |
|
| 160 | + throw new \RuntimeException('Attribute not found'); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - $attrValues = array( $attrItem->getId() => '2000-01-01' ); |
|
| 163 | + $attrValues = array($attrItem->getId() => '2000-01-01'); |
|
| 164 | 164 | |
| 165 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], [], [], $attrValues ); |
|
| 165 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], [], [], $attrValues); |
|
| 166 | 166 | $basket = $this->object->get(); |
| 167 | 167 | |
| 168 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
| 169 | - $this->assertEquals( '2000-01-01', $basket->getProduct( 0 )->getAttribute( 'date', 'custom' ) ); |
|
| 168 | + $this->assertEquals(1, count($basket->getProducts())); |
|
| 169 | + $this->assertEquals('2000-01-01', $basket->getProduct(0)->getAttribute('date', 'custom')); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | |
| 173 | 173 | public function testAddProductCustomPrice() |
| 174 | 174 | { |
| 175 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 175 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 176 | 176 | |
| 177 | 177 | $search = $attributeManager->createSearch(); |
| 178 | 178 | $expr = array( |
| 179 | - $search->compare( '==', 'attribute.code', 'custom' ), |
|
| 180 | - $search->compare( '==', 'attribute.type.code', 'price' ), |
|
| 179 | + $search->compare('==', 'attribute.code', 'custom'), |
|
| 180 | + $search->compare('==', 'attribute.type.code', 'price'), |
|
| 181 | 181 | ); |
| 182 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 182 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 183 | 183 | |
| 184 | - $attributes = $attributeManager->searchItems( $search ); |
|
| 184 | + $attributes = $attributeManager->searchItems($search); |
|
| 185 | 185 | |
| 186 | - if( ( $attrItem = reset( $attributes ) ) === false ) { |
|
| 187 | - throw new \RuntimeException( 'Attribute not found' ); |
|
| 186 | + if (($attrItem = reset($attributes)) === false) { |
|
| 187 | + throw new \RuntimeException('Attribute not found'); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - $attrValues = array( $attrItem->getId() => '0.01' ); |
|
| 190 | + $attrValues = array($attrItem->getId() => '0.01'); |
|
| 191 | 191 | |
| 192 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], [], [], $attrValues ); |
|
| 192 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], [], [], $attrValues); |
|
| 193 | 193 | $basket = $this->object->get(); |
| 194 | 194 | |
| 195 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
| 196 | - $this->assertEquals( '0.01', $basket->getProduct( 0 )->getPrice()->getValue() ); |
|
| 195 | + $this->assertEquals(1, count($basket->getProducts())); |
|
| 196 | + $this->assertEquals('0.01', $basket->getProduct(0)->getPrice()->getValue()); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | |
| 200 | 200 | public function testAddProductCustomPriceException() |
| 201 | 201 | { |
| 202 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 202 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 203 | 203 | |
| 204 | 204 | $search = $attributeManager->createSearch(); |
| 205 | 205 | $expr = array( |
| 206 | - $search->compare( '==', 'attribute.code', 'custom' ), |
|
| 207 | - $search->compare( '==', 'attribute.type.code', 'price' ), |
|
| 206 | + $search->compare('==', 'attribute.code', 'custom'), |
|
| 207 | + $search->compare('==', 'attribute.type.code', 'price'), |
|
| 208 | 208 | ); |
| 209 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 209 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 210 | 210 | |
| 211 | - $attributes = $attributeManager->searchItems( $search ); |
|
| 211 | + $attributes = $attributeManager->searchItems($search); |
|
| 212 | 212 | |
| 213 | - if( ( $attrItem = reset( $attributes ) ) === false ) { |
|
| 214 | - throw new \RuntimeException( 'Attribute not found' ); |
|
| 213 | + if (($attrItem = reset($attributes)) === false) { |
|
| 214 | + throw new \RuntimeException('Attribute not found'); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - $attrValues = array( $attrItem->getId() => ',' ); |
|
| 217 | + $attrValues = array($attrItem->getId() => ','); |
|
| 218 | 218 | |
| 219 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Basket\Exception' ); |
|
| 220 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], [], [], $attrValues ); |
|
| 219 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Basket\Exception'); |
|
| 220 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], [], [], $attrValues); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | |
| 224 | 224 | public function testAddProductAttributeNotAssigned() |
| 225 | 225 | { |
| 226 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 226 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 227 | 227 | |
| 228 | 228 | $search = $attributeManager->createSearch(); |
| 229 | 229 | $expr = array( |
| 230 | - $search->compare( '==', 'attribute.code', '30' ), |
|
| 231 | - $search->compare( '==', 'attribute.type.code', 'width' ), |
|
| 230 | + $search->compare('==', 'attribute.code', '30'), |
|
| 231 | + $search->compare('==', 'attribute.type.code', 'width'), |
|
| 232 | 232 | ); |
| 233 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 233 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 234 | 234 | |
| 235 | - $attribute = $attributeManager->searchItems( $search ); |
|
| 235 | + $attribute = $attributeManager->searchItems($search); |
|
| 236 | 236 | |
| 237 | - if( empty( $attribute ) ) { |
|
| 238 | - throw new \RuntimeException( 'Attribute not found' ); |
|
| 237 | + if (empty($attribute)) { |
|
| 238 | + throw new \RuntimeException('Attribute not found'); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - $hiddenAttrIds = array_keys( $attribute ); |
|
| 242 | - $configAttrIds = array_keys( $attribute ); |
|
| 241 | + $hiddenAttrIds = array_keys($attribute); |
|
| 242 | + $configAttrIds = array_keys($attribute); |
|
| 243 | 243 | |
| 244 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 245 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], $configAttrIds, $hiddenAttrIds ); |
|
| 244 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 245 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], $configAttrIds, $hiddenAttrIds); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
| 249 | 249 | public function testAddProductNegativeQuantityException() |
| 250 | 250 | { |
| 251 | - $this->setExpectedException( '\\Aimeos\\MShop\\Order\\Exception' ); |
|
| 252 | - $this->object->addProduct( self::$testItem->getId(), -1 ); |
|
| 251 | + $this->setExpectedException('\\Aimeos\\MShop\\Order\\Exception'); |
|
| 252 | + $this->object->addProduct(self::$testItem->getId(), -1); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | |
| 256 | 256 | public function testAddProductNoPriceException() |
| 257 | 257 | { |
| 258 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'MNOP' ); |
|
| 258 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('MNOP'); |
|
| 259 | 259 | |
| 260 | - $this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
| 261 | - $this->object->addProduct( $item->getId(), 1 ); |
|
| 260 | + $this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception'); |
|
| 261 | + $this->object->addProduct($item->getId(), 1); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | |
| 265 | 265 | public function testAddProductConfigAttributeException() |
| 266 | 266 | { |
| 267 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 268 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], array( -1 ) ); |
|
| 267 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 268 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], array( -1 )); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | |
| 272 | 272 | public function testAddProductLowQuantityPriceException() |
| 273 | 273 | { |
| 274 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' ); |
|
| 274 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL'); |
|
| 275 | 275 | |
| 276 | - $this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
| 277 | - $this->object->addProduct( $item->getId(), 1 ); |
|
| 276 | + $this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception'); |
|
| 277 | + $this->object->addProduct($item->getId(), 1); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | |
| 281 | 281 | public function testAddProductHigherQuantities() |
| 282 | 282 | { |
| 283 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' ); |
|
| 283 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL'); |
|
| 284 | 284 | |
| 285 | - $this->object->addProduct( $item->getId(), 2, [], [], [], [], [], 'unit_type3' ); |
|
| 285 | + $this->object->addProduct($item->getId(), 2, [], [], [], [], [], 'unit_type3'); |
|
| 286 | 286 | |
| 287 | - $this->assertEquals( 2, $this->object->get()->getProduct( 0 )->getQuantity() ); |
|
| 288 | - $this->assertEquals( 'IJKL', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
| 287 | + $this->assertEquals(2, $this->object->get()->getProduct(0)->getQuantity()); |
|
| 288 | + $this->assertEquals('IJKL', $this->object->get()->getProduct(0)->getProductCode()); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | |
| 292 | 292 | public function testDeleteProductFlagError() |
| 293 | 293 | { |
| 294 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
| 294 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
| 295 | 295 | |
| 296 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 297 | - $item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
| 296 | + $item = $this->object->get()->getProduct(0); |
|
| 297 | + $item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE); |
|
| 298 | 298 | |
| 299 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 300 | - $this->object->deleteProduct( 0 ); |
|
| 299 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 300 | + $this->object->deleteProduct(0); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | |
| 304 | 304 | public function testEditProduct() |
| 305 | 305 | { |
| 306 | - $this->object->addProduct( self::$testItem->getId(), 1 ); |
|
| 306 | + $this->object->addProduct(self::$testItem->getId(), 1); |
|
| 307 | 307 | |
| 308 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 309 | - $this->assertEquals( 1, $item->getQuantity() ); |
|
| 308 | + $item = $this->object->get()->getProduct(0); |
|
| 309 | + $this->assertEquals(1, $item->getQuantity()); |
|
| 310 | 310 | |
| 311 | - $this->object->editProduct( 0, 4 ); |
|
| 311 | + $this->object->editProduct(0, 4); |
|
| 312 | 312 | |
| 313 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 314 | - $this->assertEquals( 4, $item->getQuantity() ); |
|
| 315 | - $this->assertEquals( 'U:TESTP', $item->getProductCode() ); |
|
| 313 | + $item = $this->object->get()->getProduct(0); |
|
| 314 | + $this->assertEquals(4, $item->getQuantity()); |
|
| 315 | + $this->assertEquals('U:TESTP', $item->getProductCode()); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | |
| 319 | 319 | public function testEditProductAttributes() |
| 320 | 320 | { |
| 321 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 321 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 322 | 322 | |
| 323 | 323 | $search = $attributeManager->createSearch(); |
| 324 | 324 | $conditions = array( |
| 325 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
| 326 | - $search->combine( '||', array( |
|
| 327 | - $search->combine( '&&', array( |
|
| 328 | - $search->compare( '==', 'attribute.code', 'xs' ), |
|
| 329 | - $search->compare( '==', 'attribute.type.code', 'size' ), |
|
| 330 | - ) ), |
|
| 331 | - $search->combine( '&&', array( |
|
| 332 | - $search->compare( '==', 'attribute.code', 'white' ), |
|
| 333 | - $search->compare( '==', 'attribute.type.code', 'color' ), |
|
| 334 | - ) ), |
|
| 335 | - ) ) |
|
| 325 | + $search->compare('==', 'attribute.domain', 'product'), |
|
| 326 | + $search->combine('||', array( |
|
| 327 | + $search->combine('&&', array( |
|
| 328 | + $search->compare('==', 'attribute.code', 'xs'), |
|
| 329 | + $search->compare('==', 'attribute.type.code', 'size'), |
|
| 330 | + )), |
|
| 331 | + $search->combine('&&', array( |
|
| 332 | + $search->compare('==', 'attribute.code', 'white'), |
|
| 333 | + $search->compare('==', 'attribute.type.code', 'color'), |
|
| 334 | + )), |
|
| 335 | + )) |
|
| 336 | 336 | ); |
| 337 | - $search->setConditions( $search->combine( '&&', $conditions ) ); |
|
| 338 | - $attributes = $attributeManager->searchItems( $search ); |
|
| 337 | + $search->setConditions($search->combine('&&', $conditions)); |
|
| 338 | + $attributes = $attributeManager->searchItems($search); |
|
| 339 | 339 | |
| 340 | - if( ( $attribute = reset( $attributes ) ) === false ) { |
|
| 341 | - throw new \RuntimeException( 'No attributes available' ); |
|
| 340 | + if (($attribute = reset($attributes)) === false) { |
|
| 341 | + throw new \RuntimeException('No attributes available'); |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | |
| 345 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TESTP' ); |
|
| 345 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TESTP'); |
|
| 346 | 346 | |
| 347 | - $this->object->addProduct( $item->getId(), 1, [], [], array_keys( $attributes ) ); |
|
| 348 | - $this->object->editProduct( 0, 4 ); |
|
| 347 | + $this->object->addProduct($item->getId(), 1, [], [], array_keys($attributes)); |
|
| 348 | + $this->object->editProduct(0, 4); |
|
| 349 | 349 | |
| 350 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 351 | - $this->assertEquals( 2, count( $item->getAttributes() ) ); |
|
| 352 | - $this->assertEquals( 4, $item->getQuantity() ); |
|
| 350 | + $item = $this->object->get()->getProduct(0); |
|
| 351 | + $this->assertEquals(2, count($item->getAttributes())); |
|
| 352 | + $this->assertEquals(4, $item->getQuantity()); |
|
| 353 | 353 | |
| 354 | 354 | |
| 355 | - $this->object->editProduct( 0, 3, [], array( $attribute->getType() ) ); |
|
| 355 | + $this->object->editProduct(0, 3, [], array($attribute->getType())); |
|
| 356 | 356 | |
| 357 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 358 | - $this->assertEquals( 3, $item->getQuantity() ); |
|
| 359 | - $this->assertEquals( 1, count( $item->getAttributes() ) ); |
|
| 360 | - $this->assertEquals( 'U:TESTP', $item->getProductCode() ); |
|
| 357 | + $item = $this->object->get()->getProduct(0); |
|
| 358 | + $this->assertEquals(3, $item->getQuantity()); |
|
| 359 | + $this->assertEquals(1, count($item->getAttributes())); |
|
| 360 | + $this->assertEquals('U:TESTP', $item->getProductCode()); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | |
| 364 | 364 | public function testEditProductFlagError() |
| 365 | 365 | { |
| 366 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
| 366 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
| 367 | 367 | |
| 368 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 369 | - $item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
| 368 | + $item = $this->object->get()->getProduct(0); |
|
| 369 | + $item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE); |
|
| 370 | 370 | |
| 371 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 372 | - $this->object->editProduct( 0, 4 ); |
|
| 371 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 372 | + $this->object->editProduct(0, 4); |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | |
| 376 | 376 | public function testAddCoupon() |
| 377 | 377 | { |
| 378 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
| 379 | - $this->object->addCoupon( 'GHIJ' ); |
|
| 378 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
| 379 | + $this->object->addCoupon('GHIJ'); |
|
| 380 | 380 | |
| 381 | 381 | $basket = $this->object->get(); |
| 382 | 382 | |
| 383 | - $this->assertEquals( 1, count( $basket->getCoupons() ) ); |
|
| 383 | + $this->assertEquals(1, count($basket->getCoupons())); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | |
| 387 | 387 | public function testAddCouponInvalidCode() |
| 388 | 388 | { |
| 389 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 390 | - $this->object->addCoupon( 'invalid' ); |
|
| 389 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 390 | + $this->object->addCoupon('invalid'); |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | |
| 394 | 394 | public function testAddCouponMissingRequirements() |
| 395 | 395 | { |
| 396 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 397 | - $this->object->addCoupon( 'OPQR' ); |
|
| 396 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 397 | + $this->object->addCoupon('OPQR'); |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | |
| 401 | 401 | public function testDeleteCoupon() |
| 402 | 402 | { |
| 403 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
| 404 | - $this->object->addCoupon( '90AB' ); |
|
| 405 | - $this->object->deleteCoupon( '90AB' ); |
|
| 403 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
| 404 | + $this->object->addCoupon('90AB'); |
|
| 405 | + $this->object->deleteCoupon('90AB'); |
|
| 406 | 406 | |
| 407 | 407 | $basket = $this->object->get(); |
| 408 | 408 | |
| 409 | - $this->assertEquals( 0, count( $basket->getCoupons() ) ); |
|
| 409 | + $this->assertEquals(0, count($basket->getCoupons())); |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | |
| 413 | 413 | public function testSetAddressDelete() |
| 414 | 414 | { |
| 415 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null ); |
|
| 415 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null); |
|
| 416 | 416 | |
| 417 | - $this->setExpectedException( '\Aimeos\MShop\Order\Exception' ); |
|
| 418 | - $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 417 | + $this->setExpectedException('\Aimeos\MShop\Order\Exception'); |
|
| 418 | + $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | |
| 422 | 422 | public function testSetBillingAddressByItem() |
| 423 | 423 | { |
| 424 | - $item = $this->getAddress( 'Example company' ); |
|
| 424 | + $item = $this->getAddress('Example company'); |
|
| 425 | 425 | |
| 426 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item ); |
|
| 426 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item); |
|
| 427 | 427 | |
| 428 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 429 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
| 428 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
| 429 | + $this->assertEquals('Example company', $address->getCompany()); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | |
@@ -454,37 +454,37 @@ discard block |
||
| 454 | 454 | 'order.base.address.flag' => 0, |
| 455 | 455 | ); |
| 456 | 456 | |
| 457 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture ); |
|
| 457 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture); |
|
| 458 | 458 | |
| 459 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 460 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
| 461 | - $this->assertEquals( 'Dr.', $address->getTitle() ); |
|
| 462 | - $this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
| 459 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
| 460 | + $this->assertEquals('Example company', $address->getCompany()); |
|
| 461 | + $this->assertEquals('Dr.', $address->getTitle()); |
|
| 462 | + $this->assertEquals('firstunit', $address->getFirstname()); |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | |
| 466 | 466 | public function testSetBillingAddressByArrayError() |
| 467 | 467 | { |
| 468 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 469 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array( 'error' => false ) ); |
|
| 468 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 469 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array('error' => false)); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | |
| 473 | 473 | public function testSetBillingAddressParameterError() |
| 474 | 474 | { |
| 475 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 476 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error' ); |
|
| 475 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 476 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error'); |
|
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | |
| 480 | 480 | public function testSetDeliveryAddressByItem() |
| 481 | 481 | { |
| 482 | - $item = $this->getAddress( 'Example company' ); |
|
| 482 | + $item = $this->getAddress('Example company'); |
|
| 483 | 483 | |
| 484 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item ); |
|
| 484 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item); |
|
| 485 | 485 | |
| 486 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
| 487 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
| 486 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); |
|
| 487 | + $this->assertEquals('Example company', $address->getCompany()); |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | |
@@ -511,119 +511,119 @@ discard block |
||
| 511 | 511 | 'order.base.address.website' => 'www.example.com', |
| 512 | 512 | 'order.base.address.flag' => 0, |
| 513 | 513 | ); |
| 514 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture ); |
|
| 514 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture); |
|
| 515 | 515 | |
| 516 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
| 517 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
| 518 | - $this->assertEquals( 'Dr.', $address->getTitle() ); |
|
| 519 | - $this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
| 516 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); |
|
| 517 | + $this->assertEquals('Example company', $address->getCompany()); |
|
| 518 | + $this->assertEquals('Dr.', $address->getTitle()); |
|
| 519 | + $this->assertEquals('firstunit', $address->getFirstname()); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | |
| 523 | 523 | public function testSetDeliveryAddressByArrayError() |
| 524 | 524 | { |
| 525 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 526 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array( 'error' => false ) ); |
|
| 525 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 526 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array('error' => false)); |
|
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | |
| 530 | 530 | public function testSetDeliveryAddressTypeError() |
| 531 | 531 | { |
| 532 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 533 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error' ); |
|
| 532 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 533 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error'); |
|
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | |
| 537 | 537 | public function testSetServicePayment() |
| 538 | 538 | { |
| 539 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
| 540 | - $service = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' ); |
|
| 539 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
| 540 | + $service = $manager->findItem('unitpaymentcode', [], 'service', 'payment'); |
|
| 541 | 541 | |
| 542 | - $this->object->setService( 'payment', $service->getId(), [] ); |
|
| 543 | - $this->assertEquals( 'unitpaymentcode', $this->object->get()->getService( 'payment' )->getCode() ); |
|
| 542 | + $this->object->setService('payment', $service->getId(), []); |
|
| 543 | + $this->assertEquals('unitpaymentcode', $this->object->get()->getService('payment')->getCode()); |
|
| 544 | 544 | |
| 545 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 546 | - $this->object->setService( 'payment', $service->getId(), array( 'prepay' => true ) ); |
|
| 545 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 546 | + $this->object->setService('payment', $service->getId(), array('prepay' => true)); |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | |
| 550 | 550 | public function testSetDeliveryOption() |
| 551 | 551 | { |
| 552 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
| 553 | - $service = $manager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
| 552 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
| 553 | + $service = $manager->findItem('unitcode', [], 'service', 'delivery'); |
|
| 554 | 554 | |
| 555 | - $this->object->setService( 'delivery', $service->getId(), [] ); |
|
| 556 | - $this->assertEquals( 'unitcode', $this->object->get()->getService( 'delivery' )->getCode() ); |
|
| 555 | + $this->object->setService('delivery', $service->getId(), []); |
|
| 556 | + $this->assertEquals('unitcode', $this->object->get()->getService('delivery')->getCode()); |
|
| 557 | 557 | |
| 558 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 559 | - $this->object->setService( 'delivery', $service->getId(), array( 'fast shipping' => true, 'air shipping' => false ) ); |
|
| 558 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 559 | + $this->object->setService('delivery', $service->getId(), array('fast shipping' => true, 'air shipping' => false)); |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | |
| 563 | 563 | public function testCheckLocale() |
| 564 | 564 | { |
| 565 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
| 566 | - $payment = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' ); |
|
| 567 | - $delivery = $manager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
| 565 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
| 566 | + $payment = $manager->findItem('unitpaymentcode', [], 'service', 'payment'); |
|
| 567 | + $delivery = $manager->findItem('unitcode', [], 'service', 'delivery'); |
|
| 568 | 568 | |
| 569 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
| 570 | - $this->object->addCoupon( 'OPQR' ); |
|
| 569 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
| 570 | + $this->object->addCoupon('OPQR'); |
|
| 571 | 571 | |
| 572 | - $this->object->setService( 'payment', $payment->getId() ); |
|
| 573 | - $this->object->setService( 'delivery', $delivery->getId() ); |
|
| 572 | + $this->object->setService('payment', $payment->getId()); |
|
| 573 | + $this->object->setService('delivery', $delivery->getId()); |
|
| 574 | 574 | |
| 575 | 575 | $basket = $this->object->get(); |
| 576 | 576 | $price = $basket->getPrice(); |
| 577 | 577 | |
| 578 | - foreach( $basket->getProducts() as $product ) |
|
| 578 | + foreach ($basket->getProducts() as $product) |
|
| 579 | 579 | { |
| 580 | - $this->assertEquals( 2, $product->getQuantity() ); |
|
| 581 | - $product->getPrice()->setCurrencyId( 'CHF' ); |
|
| 580 | + $this->assertEquals(2, $product->getQuantity()); |
|
| 581 | + $product->getPrice()->setCurrencyId('CHF'); |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | - $basket->getService( 'delivery' )->getPrice()->setCurrencyId( 'CHF' ); |
|
| 585 | - $basket->getService( 'payment' )->getPrice()->setCurrencyId( 'CHF' ); |
|
| 586 | - $basket->getLocale()->setCurrencyId( 'CHF' ); |
|
| 587 | - $price->setCurrencyId( 'CHF' ); |
|
| 584 | + $basket->getService('delivery')->getPrice()->setCurrencyId('CHF'); |
|
| 585 | + $basket->getService('payment')->getPrice()->setCurrencyId('CHF'); |
|
| 586 | + $basket->getLocale()->setCurrencyId('CHF'); |
|
| 587 | + $price->setCurrencyId('CHF'); |
|
| 588 | 588 | |
| 589 | - $this->context->getLocale()->setCurrencyId( 'CHF' ); |
|
| 590 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress( 'Example company' ) ); |
|
| 589 | + $this->context->getLocale()->setCurrencyId('CHF'); |
|
| 590 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress('Example company')); |
|
| 591 | 591 | |
| 592 | - $this->context->getSession()->set( 'aimeos/basket/currency', 'CHF' ); |
|
| 593 | - $this->context->getLocale()->setCurrencyId( 'EUR' ); |
|
| 592 | + $this->context->getSession()->set('aimeos/basket/currency', 'CHF'); |
|
| 593 | + $this->context->getLocale()->setCurrencyId('EUR'); |
|
| 594 | 594 | |
| 595 | - $this->context->getSession()->set( 'aimeos/basket/content-unittest-en-EUR-', null ); |
|
| 595 | + $this->context->getSession()->set('aimeos/basket/content-unittest-en-EUR-', null); |
|
| 596 | 596 | |
| 597 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 597 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 598 | 598 | $basket = $object->get(); |
| 599 | 599 | |
| 600 | - foreach( $basket->getProducts() as $product ) |
|
| 600 | + foreach ($basket->getProducts() as $product) |
|
| 601 | 601 | { |
| 602 | - $this->assertEquals( 'EUR', $product->getPrice()->getCurrencyId() ); |
|
| 603 | - $this->assertEquals( 2, $product->getQuantity() ); |
|
| 602 | + $this->assertEquals('EUR', $product->getPrice()->getCurrencyId()); |
|
| 603 | + $this->assertEquals(2, $product->getQuantity()); |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | - $this->assertEquals( 'EUR', $basket->getService( 'payment' )->getPrice()->getCurrencyId() ); |
|
| 607 | - $this->assertEquals( 'EUR', $basket->getService( 'delivery' )->getPrice()->getCurrencyId() ); |
|
| 608 | - $this->assertEquals( 'EUR', $basket->getLocale()->getCurrencyId() ); |
|
| 609 | - $this->assertEquals( 'EUR', $basket->getPrice()->getCurrencyId() ); |
|
| 606 | + $this->assertEquals('EUR', $basket->getService('payment')->getPrice()->getCurrencyId()); |
|
| 607 | + $this->assertEquals('EUR', $basket->getService('delivery')->getPrice()->getCurrencyId()); |
|
| 608 | + $this->assertEquals('EUR', $basket->getLocale()->getCurrencyId()); |
|
| 609 | + $this->assertEquals('EUR', $basket->getPrice()->getCurrencyId()); |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | |
| 613 | 613 | /** |
| 614 | 614 | * @param string $company |
| 615 | 615 | */ |
| 616 | - protected function getAddress( $company ) |
|
| 616 | + protected function getAddress($company) |
|
| 617 | 617 | { |
| 618 | - $customer = \Aimeos\MShop\Customer\Manager\Factory::createManager( \TestHelperFrontend::getContext(), 'Standard' ); |
|
| 619 | - $addressManager = $customer->getSubManager( 'address', 'Standard' ); |
|
| 618 | + $customer = \Aimeos\MShop\Customer\Manager\Factory::createManager(\TestHelperFrontend::getContext(), 'Standard'); |
|
| 619 | + $addressManager = $customer->getSubManager('address', 'Standard'); |
|
| 620 | 620 | |
| 621 | 621 | $search = $addressManager->createSearch(); |
| 622 | - $search->setConditions( $search->compare( '==', 'customer.address.company', $company ) ); |
|
| 623 | - $items = $addressManager->searchItems( $search ); |
|
| 622 | + $search->setConditions($search->compare('==', 'customer.address.company', $company)); |
|
| 623 | + $items = $addressManager->searchItems($search); |
|
| 624 | 624 | |
| 625 | - if( ( $item = reset( $items ) ) === false ) { |
|
| 626 | - throw new \RuntimeException( sprintf( 'No address item with company "%1$s" found', $company ) ); |
|
| 625 | + if (($item = reset($items)) === false) { |
|
| 626 | + throw new \RuntimeException(sprintf('No address item with company "%1$s" found', $company)); |
|
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | return $item; |