@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * Returns the given search filter with the conditions attached for filtering by type code |
26 | 26 | * |
27 | 27 | * @param \Aimeos\MW\Criteria\Iface $filter Criteria object used for attribute search |
28 | - * @param array $codes List of attribute type codes |
|
28 | + * @param string[] $codes List of attribute type codes |
|
29 | 29 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
30 | 30 | * @since 2017.03 |
31 | 31 | */ |
@@ -108,6 +108,7 @@ discard block |
||
108 | 108 | * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions |
109 | 109 | * @param string[] $domains Domain names of items that are associated with the attributes and that should be fetched too |
110 | 110 | * @param integer &$total Parameter where the total number of found attributes will be stored in |
111 | + * @param integer $total |
|
111 | 112 | * @return array Ordered list of attribute items implementing \Aimeos\MShop\Attribute\Item\Iface |
112 | 113 | * @since 2017.03 |
113 | 114 | */ |
@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
30 | 30 | * @since 2017.03 |
31 | 31 | */ |
32 | - public function addFilterTypes( \Aimeos\MW\Criteria\Iface $filter, array $codes ) |
|
32 | + public function addFilterTypes(\Aimeos\MW\Criteria\Iface $filter, array $codes) |
|
33 | 33 | { |
34 | - if( !empty( $codes ) ) |
|
34 | + if (!empty($codes)) |
|
35 | 35 | { |
36 | 36 | $expr = [ |
37 | - $filter->compare( '==', 'attribute.type.code', $codes ), |
|
37 | + $filter->compare('==', 'attribute.type.code', $codes), |
|
38 | 38 | $filter->getConditions(), |
39 | 39 | ]; |
40 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
40 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | return $filter; |
@@ -53,15 +53,15 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function createFilter() |
55 | 55 | { |
56 | - $filter = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' )->createSearch( true ); |
|
56 | + $filter = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute')->createSearch(true); |
|
57 | 57 | |
58 | 58 | $expr = array( |
59 | - $filter->compare( '==', 'attribute.domain', 'product' ), |
|
59 | + $filter->compare('==', 'attribute.domain', 'product'), |
|
60 | 60 | $filter->getConditions(), |
61 | 61 | ); |
62 | 62 | |
63 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
64 | - $filter->setSortations( array( $filter->sort( '+', 'attribute.position' ) ) ); |
|
63 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
64 | + $filter->setSortations(array($filter->sort('+', 'attribute.position'))); |
|
65 | 65 | |
66 | 66 | return $filter; |
67 | 67 | } |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | * @return \Aimeos\MShop\Attribute\Item\Iface Attribute item including the referenced domains items |
76 | 76 | * @since 2017.03 |
77 | 77 | */ |
78 | - public function getItem( $id, array $domains = array( 'media', 'price', 'text' ) ) |
|
78 | + public function getItem($id, array $domains = array('media', 'price', 'text')) |
|
79 | 79 | { |
80 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' )->getItem( $id, $domains, true ); |
|
80 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute')->getItem($id, $domains, true); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -89,16 +89,16 @@ discard block |
||
89 | 89 | * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute item including the referenced domains items |
90 | 90 | * @since 2017.03 |
91 | 91 | */ |
92 | - public function getItems( array $ids, array $domains = array( 'media', 'price', 'text' ) ) |
|
92 | + public function getItems(array $ids, array $domains = array('media', 'price', 'text')) |
|
93 | 93 | { |
94 | 94 | $filter = $this->createFilter(); |
95 | 95 | $expr = [ |
96 | - $filter->compare( '==', 'attribute.id', $ids ), |
|
96 | + $filter->compare('==', 'attribute.id', $ids), |
|
97 | 97 | $filter->getConditions(), |
98 | 98 | ]; |
99 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
99 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
100 | 100 | |
101 | - return $this->searchItems( $filter, $domains ); |
|
101 | + return $this->searchItems($filter, $domains); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | * @return array Ordered list of attribute items implementing \Aimeos\MShop\Attribute\Item\Iface |
112 | 112 | * @since 2017.03 |
113 | 113 | */ |
114 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ) |
|
114 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null) |
|
115 | 115 | { |
116 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' )->searchItems( $filter, $domains, $total ); |
|
116 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute')->searchItems($filter, $domains, $total); |
|
117 | 117 | } |
118 | 118 | } |
@@ -65,6 +65,7 @@ |
||
65 | 65 | * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions |
66 | 66 | * @param string[] $domains Domain names of items that are associated with the locales and that should be fetched too |
67 | 67 | * @param integer &$total Parameter where the total number of found locales will be stored in |
68 | + * @param integer $total |
|
68 | 69 | * @return array Ordered list of locale items implementing \Aimeos\MShop\Locale\Item\Iface |
69 | 70 | * @since 2017.03 |
70 | 71 | */ |
@@ -31,15 +31,15 @@ discard block |
||
31 | 31 | public function createFilter() |
32 | 32 | { |
33 | 33 | $context = $this->getContext(); |
34 | - $filter = \Aimeos\MShop\Factory::createManager( $context, 'locale' )->createSearch( true ); |
|
34 | + $filter = \Aimeos\MShop\Factory::createManager($context, 'locale')->createSearch(true); |
|
35 | 35 | |
36 | 36 | $expr = array( |
37 | - $filter->compare( '==', 'locale.siteid', $context->getLocale()->getSitePath() ), |
|
37 | + $filter->compare('==', 'locale.siteid', $context->getLocale()->getSitePath()), |
|
38 | 38 | $filter->getConditions(), |
39 | 39 | ); |
40 | 40 | |
41 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
42 | - $filter->setSortations( array( $filter->sort( '+', 'locale.position' ) ) ); |
|
41 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
42 | + $filter->setSortations(array($filter->sort('+', 'locale.position'))); |
|
43 | 43 | |
44 | 44 | return $filter; |
45 | 45 | } |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | * @return \Aimeos\MShop\Locale\Item\Iface Locale item including the referenced domains items |
54 | 54 | * @since 2017.03 |
55 | 55 | */ |
56 | - public function getItem( $id, array $domains = array() ) |
|
56 | + public function getItem($id, array $domains = array()) |
|
57 | 57 | { |
58 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'locale' )->getItem( $id, $domains, true ); |
|
58 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'locale')->getItem($id, $domains, true); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * @return array Ordered list of locale items implementing \Aimeos\MShop\Locale\Item\Iface |
69 | 69 | * @since 2017.03 |
70 | 70 | */ |
71 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array(), &$total = null ) |
|
71 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array(), &$total = null) |
|
72 | 72 | { |
73 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'locale' )->searchItems( $filter, $domains, $total ); |
|
73 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'locale')->searchItems($filter, $domains, $total); |
|
74 | 74 | } |
75 | 75 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * Returns the given search filter with the conditions attached for filtering by product code |
26 | 26 | * |
27 | 27 | * @param \Aimeos\MW\Criteria\Iface $filter Criteria object used for stock search |
28 | - * @param array $codes List of product codes |
|
28 | + * @param string[] $codes List of product codes |
|
29 | 29 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
30 | 30 | * @since 2017.03 |
31 | 31 | */ |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * Returns the given search filter with the conditions attached for filtering by type code |
46 | 46 | * |
47 | 47 | * @param \Aimeos\MW\Criteria\Iface $filter Criteria object used for stock search |
48 | - * @param array $codes List of stock type codes |
|
48 | + * @param string[] $codes List of stock type codes |
|
49 | 49 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
50 | 50 | * @since 2017.03 |
51 | 51 | */ |
@@ -95,6 +95,7 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions |
97 | 97 | * @param integer &$total Parameter where the total number of found stocks will be stored in |
98 | + * @param integer $total |
|
98 | 99 | * @return array Ordered list of stock items implementing \Aimeos\MShop\Stock\Item\Iface |
99 | 100 | * @since 2017.03 |
100 | 101 | */ |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
30 | 30 | * @since 2017.03 |
31 | 31 | */ |
32 | - public function addFilterCodes( \Aimeos\MW\Criteria\Iface $filter, array $codes ) |
|
32 | + public function addFilterCodes(\Aimeos\MW\Criteria\Iface $filter, array $codes) |
|
33 | 33 | { |
34 | 34 | $expr = [ |
35 | - $filter->compare( '==', 'stock.productcode', $codes ), |
|
35 | + $filter->compare('==', 'stock.productcode', $codes), |
|
36 | 36 | $filter->getConditions(), |
37 | 37 | ]; |
38 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
38 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
39 | 39 | |
40 | 40 | return $filter; |
41 | 41 | } |
@@ -49,15 +49,15 @@ discard block |
||
49 | 49 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
50 | 50 | * @since 2017.03 |
51 | 51 | */ |
52 | - public function addFilterTypes( \Aimeos\MW\Criteria\Iface $filter, array $codes ) |
|
52 | + public function addFilterTypes(\Aimeos\MW\Criteria\Iface $filter, array $codes) |
|
53 | 53 | { |
54 | - if( !empty( $codes ) ) |
|
54 | + if (!empty($codes)) |
|
55 | 55 | { |
56 | 56 | $expr = [ |
57 | - $filter->compare( '==', 'stock.type.code', $codes ), |
|
57 | + $filter->compare('==', 'stock.type.code', $codes), |
|
58 | 58 | $filter->getConditions(), |
59 | 59 | ]; |
60 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
60 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | return $filter; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function createFilter() |
75 | 75 | { |
76 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'stock' )->createSearch( true ); |
|
76 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'stock')->createSearch(true); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | * @return \Aimeos\MShop\Stock\Item\Iface Stock item including the referenced domains items |
85 | 85 | * @since 2017.03 |
86 | 86 | */ |
87 | - public function getItem( $id ) |
|
87 | + public function getItem($id) |
|
88 | 88 | { |
89 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'stock' )->getItem( $id, [], true ); |
|
89 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'stock')->getItem($id, [], true); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | * @return array Ordered list of stock items implementing \Aimeos\MShop\Stock\Item\Iface |
99 | 99 | * @since 2017.03 |
100 | 100 | */ |
101 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, &$total = null ) |
|
101 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, &$total = null) |
|
102 | 102 | { |
103 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'stock' )->searchItems( $filter, [], $total ); |
|
103 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'stock')->searchItems($filter, [], $total); |
|
104 | 104 | } |
105 | 105 | } |
@@ -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(), array $variantAttributeIds = array(), |
|
44 | + public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
45 | 45 | array $configAttributeIds = array(), array $hiddenAttributeIds = array(), array $customAttributeValues = array(), |
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( $productItem->getType() !== 'bundle' ) |
|
52 | + if ($productItem->getType() !== 'bundle') |
|
53 | 53 | { |
54 | 54 | return $this->getController()->addProduct( |
55 | 55 | $prodid, $quantity, $options, $variantAttributeIds, $configAttributeIds, |
@@ -57,30 +57,30 @@ discard block |
||
57 | 57 | ); |
58 | 58 | } |
59 | 59 | |
60 | - $productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true ); |
|
60 | + $productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true); |
|
61 | 61 | |
62 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
63 | - $orderBaseProductItem->copyFrom( $productItem ); |
|
64 | - $orderBaseProductItem->setQuantity( $quantity ); |
|
65 | - $orderBaseProductItem->setStockType( $stocktype ); |
|
62 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
63 | + $orderBaseProductItem->copyFrom($productItem); |
|
64 | + $orderBaseProductItem->setQuantity($quantity); |
|
65 | + $orderBaseProductItem->setStockType($stocktype); |
|
66 | 66 | |
67 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
68 | - $this->addBundleProducts( $orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype ); |
|
67 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
68 | + $this->addBundleProducts($orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype); |
|
69 | 69 | |
70 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
71 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
70 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
71 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
72 | 72 | |
73 | - $attr = $this->createOrderProductAttributes( $price, $prodid, $quantity, $configAttributeIds, 'config' ); |
|
74 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $hiddenAttributeIds, 'hidden' ) ); |
|
75 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, array_keys( $customAttributeValues ), 'custom', $customAttributeValues ) ); |
|
73 | + $attr = $this->createOrderProductAttributes($price, $prodid, $quantity, $configAttributeIds, 'config'); |
|
74 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $hiddenAttributeIds, 'hidden')); |
|
75 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, array_keys($customAttributeValues), 'custom', $customAttributeValues)); |
|
76 | 76 | |
77 | 77 | // remove product rebate of original price in favor to rebates granted for the order |
78 | - $price->setRebate( '0.00' ); |
|
78 | + $price->setRebate('0.00'); |
|
79 | 79 | |
80 | - $orderBaseProductItem->setPrice( $price ); |
|
81 | - $orderBaseProductItem->setAttributes( $attr ); |
|
80 | + $orderBaseProductItem->setPrice($price); |
|
81 | + $orderBaseProductItem->setAttributes($attr); |
|
82 | 82 | |
83 | - $this->getController()->get()->addProduct( $orderBaseProductItem ); |
|
83 | + $this->getController()->get()->addProduct($orderBaseProductItem); |
|
84 | 84 | $this->getController()->save(); |
85 | 85 | } |
86 | 86 | |
@@ -93,43 +93,43 @@ discard block |
||
93 | 93 | * @param array $variantAttributeIds List of product variant attribute IDs |
94 | 94 | * @param string $stocktype |
95 | 95 | */ |
96 | - protected function addBundleProducts( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
97 | - \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype ) |
|
96 | + protected function addBundleProducts(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
97 | + \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype) |
|
98 | 98 | { |
99 | 99 | $quantity = $orderBaseProductItem->getQuantity(); |
100 | 100 | $products = $subProductIds = $orderProducts = array(); |
101 | - $orderProductManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product' ); |
|
101 | + $orderProductManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product'); |
|
102 | 102 | |
103 | - foreach( $productItem->getRefItems( 'product', null, 'default' ) as $item ) { |
|
103 | + foreach ($productItem->getRefItems('product', null, 'default') as $item) { |
|
104 | 104 | $subProductIds[] = $item->getId(); |
105 | 105 | } |
106 | 106 | |
107 | - if( count( $subProductIds ) > 0 ) |
|
107 | + if (count($subProductIds) > 0) |
|
108 | 108 | { |
109 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
109 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
110 | 110 | |
111 | - $search = $productManager->createSearch( true ); |
|
111 | + $search = $productManager->createSearch(true); |
|
112 | 112 | $expr = array( |
113 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
113 | + $search->compare('==', 'product.id', $subProductIds), |
|
114 | 114 | $search->getConditions(), |
115 | 115 | ); |
116 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
116 | + $search->setConditions($search->combine('&&', $expr)); |
|
117 | 117 | |
118 | - $products = $productManager->searchItems( $search, array( 'attribute', 'media', 'price', 'text' ) ); |
|
118 | + $products = $productManager->searchItems($search, array('attribute', 'media', 'price', 'text')); |
|
119 | 119 | } |
120 | 120 | |
121 | - foreach( $products as $product ) |
|
121 | + foreach ($products as $product) |
|
122 | 122 | { |
123 | - $prices = $product->getRefItems( 'price', 'default', 'default' ); |
|
123 | + $prices = $product->getRefItems('price', 'default', 'default'); |
|
124 | 124 | |
125 | 125 | $orderProduct = $orderProductManager->createItem(); |
126 | - $orderProduct->copyFrom( $product ); |
|
127 | - $orderProduct->setStockType( $stocktype ); |
|
128 | - $orderProduct->setPrice( $this->calcPrice( $orderProduct, $prices, $quantity ) ); |
|
126 | + $orderProduct->copyFrom($product); |
|
127 | + $orderProduct->setStockType($stocktype); |
|
128 | + $orderProduct->setPrice($this->calcPrice($orderProduct, $prices, $quantity)); |
|
129 | 129 | |
130 | 130 | $orderProducts[] = $orderProduct; |
131 | 131 | } |
132 | 132 | |
133 | - $orderBaseProductItem->setProducts( $orderProducts ); |
|
133 | + $orderBaseProductItem->setProducts($orderProducts); |
|
134 | 134 | } |
135 | 135 | } |
@@ -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(), array $variantAttributeIds = array(), |
|
44 | + public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
45 | 45 | array $configAttributeIds = array(), array $hiddenAttributeIds = array(), array $customAttributeValues = array(), |
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( $productItem->getType() !== 'select' ) |
|
52 | + if ($productItem->getType() !== 'select') |
|
53 | 53 | { |
54 | 54 | return $this->getController()->addProduct( |
55 | 55 | $prodid, $quantity, $options, $variantAttributeIds, $configAttributeIds, |
@@ -57,31 +57,31 @@ discard block |
||
57 | 57 | ); |
58 | 58 | } |
59 | 59 | |
60 | - $productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true ); |
|
60 | + $productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true); |
|
61 | 61 | |
62 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
63 | - $orderBaseProductItem->copyFrom( $productItem ); |
|
64 | - $orderBaseProductItem->setQuantity( $quantity ); |
|
65 | - $orderBaseProductItem->setStockType( $stocktype ); |
|
62 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
63 | + $orderBaseProductItem->copyFrom($productItem); |
|
64 | + $orderBaseProductItem->setQuantity($quantity); |
|
65 | + $orderBaseProductItem->setStockType($stocktype); |
|
66 | 66 | |
67 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
68 | - $attr = $this->getVariantDetails( $orderBaseProductItem, $productItem, $prices, $variantAttributeIds, $options ); |
|
69 | - $prodIds = array( $prodid, $productItem->getId() ); |
|
67 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
68 | + $attr = $this->getVariantDetails($orderBaseProductItem, $productItem, $prices, $variantAttributeIds, $options); |
|
69 | + $prodIds = array($prodid, $productItem->getId()); |
|
70 | 70 | |
71 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
72 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
71 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
72 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
73 | 73 | |
74 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodIds, $quantity, $configAttributeIds, 'config' ) ); |
|
75 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodIds, $quantity, $hiddenAttributeIds, 'hidden' ) ); |
|
76 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodIds, $quantity, array_keys( $customAttributeValues ), 'custom', $customAttributeValues ) ); |
|
74 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodIds, $quantity, $configAttributeIds, 'config')); |
|
75 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodIds, $quantity, $hiddenAttributeIds, 'hidden')); |
|
76 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodIds, $quantity, array_keys($customAttributeValues), 'custom', $customAttributeValues)); |
|
77 | 77 | |
78 | 78 | // remove product rebate of original price in favor to rebates granted for the order |
79 | - $price->setRebate( '0.00' ); |
|
79 | + $price->setRebate('0.00'); |
|
80 | 80 | |
81 | - $orderBaseProductItem->setPrice( $price ); |
|
82 | - $orderBaseProductItem->setAttributes( $attr ); |
|
81 | + $orderBaseProductItem->setPrice($price); |
|
82 | + $orderBaseProductItem->setAttributes($attr); |
|
83 | 83 | |
84 | - $this->getController()->get()->addProduct( $orderBaseProductItem ); |
|
84 | + $this->getController()->get()->addProduct($orderBaseProductItem); |
|
85 | 85 | $this->getController()->save(); |
86 | 86 | } |
87 | 87 | |
@@ -97,50 +97,50 @@ discard block |
||
97 | 97 | * @return \Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface[] List of order product attributes |
98 | 98 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If no product variant is found |
99 | 99 | */ |
100 | - protected function getVariantDetails( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
101 | - \Aimeos\MShop\Product\Item\Iface &$productItem, array &$prices, array $variantAttributeIds, array $options ) |
|
100 | + protected function getVariantDetails(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
101 | + \Aimeos\MShop\Product\Item\Iface & $productItem, array &$prices, array $variantAttributeIds, array $options) |
|
102 | 102 | { |
103 | 103 | $attr = array(); |
104 | - $productItems = $this->getProductVariants( $productItem, $variantAttributeIds ); |
|
104 | + $productItems = $this->getProductVariants($productItem, $variantAttributeIds); |
|
105 | 105 | |
106 | - if( count( $productItems ) > 1 ) |
|
106 | + if (count($productItems) > 1) |
|
107 | 107 | { |
108 | - $msg = sprintf( 'No unique article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
|
109 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
108 | + $msg = sprintf('No unique article found for selected attributes and product ID "%1$s"', $productItem->getId()); |
|
109 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
110 | 110 | } |
111 | - else if( ( $result = reset( $productItems ) ) !== false ) // count == 1 |
|
111 | + else if (($result = reset($productItems)) !== false) // count == 1 |
|
112 | 112 | { |
113 | 113 | $productItem = $result; |
114 | - $orderBaseProductItem->setProductCode( $productItem->getCode() ); |
|
114 | + $orderBaseProductItem->setProductCode($productItem->getCode()); |
|
115 | 115 | |
116 | - $subprices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
116 | + $subprices = $productItem->getRefItems('price', 'default', 'default'); |
|
117 | 117 | |
118 | - if( !empty( $subprices ) ) { |
|
118 | + if (!empty($subprices)) { |
|
119 | 119 | $prices = $subprices; |
120 | 120 | } |
121 | 121 | |
122 | - $submedia = $productItem->getRefItems( 'media', 'default', 'default' ); |
|
122 | + $submedia = $productItem->getRefItems('media', 'default', 'default'); |
|
123 | 123 | |
124 | - if( ( $mediaItem = reset( $submedia ) ) !== false ) { |
|
125 | - $orderBaseProductItem->setMediaUrl( $mediaItem->getPreview() ); |
|
124 | + if (($mediaItem = reset($submedia)) !== false) { |
|
125 | + $orderBaseProductItem->setMediaUrl($mediaItem->getPreview()); |
|
126 | 126 | } |
127 | 127 | |
128 | - $orderProductAttrManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' ); |
|
129 | - $variantAttributes = $productItem->getRefItems( 'attribute', null, 'variant' ); |
|
128 | + $orderProductAttrManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute'); |
|
129 | + $variantAttributes = $productItem->getRefItems('attribute', null, 'variant'); |
|
130 | 130 | |
131 | - foreach( $this->getAttributes( array_keys( $variantAttributes ), array( 'text' ) ) as $attrItem ) |
|
131 | + foreach ($this->getAttributes(array_keys($variantAttributes), array('text')) as $attrItem) |
|
132 | 132 | { |
133 | 133 | $orderAttributeItem = $orderProductAttrManager->createItem(); |
134 | - $orderAttributeItem->copyFrom( $attrItem ); |
|
135 | - $orderAttributeItem->setType( 'variant' ); |
|
134 | + $orderAttributeItem->copyFrom($attrItem); |
|
135 | + $orderAttributeItem->setType('variant'); |
|
136 | 136 | |
137 | 137 | $attr[] = $orderAttributeItem; |
138 | 138 | } |
139 | 139 | } |
140 | - else if( !isset( $options['variant'] ) || $options['variant'] != false ) // count == 0 |
|
140 | + else if (!isset($options['variant']) || $options['variant'] != false) // count == 0 |
|
141 | 141 | { |
142 | - $msg = sprintf( 'No article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
|
143 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
142 | + $msg = sprintf('No article found for selected attributes and product ID "%1$s"', $productItem->getId()); |
|
143 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | return $attr; |
@@ -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; |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | public function store() |
109 | 109 | { |
110 | 110 | $basket = $this->get(); |
111 | - $basket->setCustomerId( $this->getContext()->getUserId() ); |
|
111 | + $basket->setCustomerId($this->getContext()->getUserId()); |
|
112 | 112 | $basket->finish(); |
113 | 113 | |
114 | 114 | $this->domainManager->begin(); |
115 | - $this->domainManager->store( $basket ); |
|
115 | + $this->domainManager->store($basket); |
|
116 | 116 | $this->domainManager->commit(); |
117 | 117 | |
118 | 118 | return $basket; |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | * @param boolean $default True to add default criteria (user logged in), false if not |
128 | 128 | * @return \Aimeos\MShop\Order\Item\Base\Iface Order base object including the given parts |
129 | 129 | */ |
130 | - public function load( $id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true ) |
|
130 | + public function load($id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true) |
|
131 | 131 | { |
132 | - return $this->domainManager->load( $id, $parts, false, $default ); |
|
132 | + return $this->domainManager->load($id, $parts, false, $default); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
@@ -149,36 +149,36 @@ discard block |
||
149 | 149 | * @param string $stocktype Unique code of the stock type to deliver the products from |
150 | 150 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
151 | 151 | */ |
152 | - public function addProduct( $prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
152 | + public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
153 | 153 | array $configAttributeIds = array(), array $hiddenAttributeIds = array(), array $customAttributeValues = array(), |
154 | - $stocktype = 'default' ) |
|
154 | + $stocktype = 'default') |
|
155 | 155 | { |
156 | 156 | $context = $this->getContext(); |
157 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
158 | - $productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true ); |
|
157 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
158 | + $productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true); |
|
159 | 159 | |
160 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
161 | - $orderBaseProductItem->copyFrom( $productItem ); |
|
162 | - $orderBaseProductItem->setQuantity( $quantity ); |
|
163 | - $orderBaseProductItem->setStockType( $stocktype ); |
|
160 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
161 | + $orderBaseProductItem->copyFrom($productItem); |
|
162 | + $orderBaseProductItem->setQuantity($quantity); |
|
163 | + $orderBaseProductItem->setStockType($stocktype); |
|
164 | 164 | |
165 | 165 | $attr = array(); |
166 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
166 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
167 | 167 | |
168 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
169 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
168 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
169 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
170 | 170 | |
171 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $configAttributeIds, 'config' ) ); |
|
172 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $hiddenAttributeIds, 'hidden' ) ); |
|
173 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, array_keys( $customAttributeValues ), 'custom', $customAttributeValues ) ); |
|
171 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $configAttributeIds, 'config')); |
|
172 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $hiddenAttributeIds, 'hidden')); |
|
173 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, array_keys($customAttributeValues), 'custom', $customAttributeValues)); |
|
174 | 174 | |
175 | 175 | // remove product rebate of original price in favor to rebates granted for the order |
176 | - $price->setRebate( '0.00' ); |
|
176 | + $price->setRebate('0.00'); |
|
177 | 177 | |
178 | - $orderBaseProductItem->setPrice( $price ); |
|
179 | - $orderBaseProductItem->setAttributes( $attr ); |
|
178 | + $orderBaseProductItem->setPrice($price); |
|
179 | + $orderBaseProductItem->setAttributes($attr); |
|
180 | 180 | |
181 | - $this->get()->addProduct( $orderBaseProductItem ); |
|
181 | + $this->get()->addProduct($orderBaseProductItem); |
|
182 | 182 | $this->save(); |
183 | 183 | } |
184 | 184 | |
@@ -188,17 +188,17 @@ discard block |
||
188 | 188 | * |
189 | 189 | * @param integer $position Position number (key) of the order product item |
190 | 190 | */ |
191 | - public function deleteProduct( $position ) |
|
191 | + public function deleteProduct($position) |
|
192 | 192 | { |
193 | - $product = $this->get()->getProduct( $position ); |
|
193 | + $product = $this->get()->getProduct($position); |
|
194 | 194 | |
195 | - if( $product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
195 | + if ($product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
196 | 196 | { |
197 | - $msg = sprintf( 'Basket item at position "%1$d" cannot be deleted manually', $position ); |
|
198 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
197 | + $msg = sprintf('Basket item at position "%1$d" cannot be deleted manually', $position); |
|
198 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
199 | 199 | } |
200 | 200 | |
201 | - $this->get()->deleteProduct( $position ); |
|
201 | + $this->get()->deleteProduct($position); |
|
202 | 202 | $this->save(); |
203 | 203 | } |
204 | 204 | |
@@ -212,34 +212,34 @@ discard block |
||
212 | 212 | * The 'stock'=>false option allows adding products without being in stock. |
213 | 213 | * @param string[] $configAttributeCodes Codes of the product config attributes that should be REMOVED |
214 | 214 | */ |
215 | - public function editProduct( $position, $quantity, array $options = array(), |
|
216 | - array $configAttributeCodes = array() ) |
|
215 | + public function editProduct($position, $quantity, array $options = array(), |
|
216 | + array $configAttributeCodes = array()) |
|
217 | 217 | { |
218 | - $product = $this->get()->getProduct( $position ); |
|
218 | + $product = $this->get()->getProduct($position); |
|
219 | 219 | |
220 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
220 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
221 | 221 | { |
222 | - $msg = sprintf( 'Basket item at position "%1$d" cannot be changed', $position ); |
|
223 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
222 | + $msg = sprintf('Basket item at position "%1$d" cannot be changed', $position); |
|
223 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
224 | 224 | } |
225 | 225 | |
226 | - $product->setQuantity( $quantity ); |
|
226 | + $product->setQuantity($quantity); |
|
227 | 227 | |
228 | 228 | $attributes = $product->getAttributes(); |
229 | - foreach( $attributes as $key => $attribute ) |
|
229 | + foreach ($attributes as $key => $attribute) |
|
230 | 230 | { |
231 | - if( in_array( $attribute->getCode(), $configAttributeCodes ) ) { |
|
232 | - unset( $attributes[$key] ); |
|
231 | + if (in_array($attribute->getCode(), $configAttributeCodes)) { |
|
232 | + unset($attributes[$key]); |
|
233 | 233 | } |
234 | 234 | } |
235 | - $product->setAttributes( $attributes ); |
|
235 | + $product->setAttributes($attributes); |
|
236 | 236 | |
237 | - $productItem = $this->getDomainItem( 'product', 'product.code', $product->getProductCode(), array( 'price', 'text' ) ); |
|
238 | - $prices = $productItem->getRefItems( 'price', 'default' ); |
|
239 | - $product->setPrice( $this->calcPrice( $product, $prices, $quantity ) ); |
|
237 | + $productItem = $this->getDomainItem('product', 'product.code', $product->getProductCode(), array('price', 'text')); |
|
238 | + $prices = $productItem->getRefItems('price', 'default'); |
|
239 | + $product->setPrice($this->calcPrice($product, $prices, $quantity)); |
|
240 | 240 | |
241 | - $this->get()->deleteProduct( $position ); |
|
242 | - $this->get()->addProduct( $product, $position ); |
|
241 | + $this->get()->deleteProduct($position); |
|
242 | + $this->get()->addProduct($product, $position); |
|
243 | 243 | |
244 | 244 | $this->save(); |
245 | 245 | } |
@@ -251,49 +251,49 @@ discard block |
||
251 | 251 | * @param string $code Coupon code entered by the user |
252 | 252 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
253 | 253 | */ |
254 | - public function addCoupon( $code ) |
|
254 | + public function addCoupon($code) |
|
255 | 255 | { |
256 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
257 | - $codeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon/code' ); |
|
256 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
257 | + $codeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon/code'); |
|
258 | 258 | |
259 | 259 | |
260 | - $search = $codeManager->createSearch( true ); |
|
260 | + $search = $codeManager->createSearch(true); |
|
261 | 261 | $expr = array( |
262 | - $search->compare( '==', 'coupon.code.code', $code ), |
|
262 | + $search->compare('==', 'coupon.code.code', $code), |
|
263 | 263 | $search->getConditions(), |
264 | 264 | ); |
265 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
266 | - $search->setSlice( 0, 1 ); |
|
265 | + $search->setConditions($search->combine('&&', $expr)); |
|
266 | + $search->setSlice(0, 1); |
|
267 | 267 | |
268 | - $result = $codeManager->searchItems( $search ); |
|
268 | + $result = $codeManager->searchItems($search); |
|
269 | 269 | |
270 | - if( ( $codeItem = reset( $result ) ) === false ) { |
|
271 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid or not available any more', $code ) ); |
|
270 | + if (($codeItem = reset($result)) === false) { |
|
271 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid or not available any more', $code)); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | |
275 | - $search = $manager->createSearch( true ); |
|
275 | + $search = $manager->createSearch(true); |
|
276 | 276 | $expr = array( |
277 | - $search->compare( '==', 'coupon.id', $codeItem->getParentId() ), |
|
277 | + $search->compare('==', 'coupon.id', $codeItem->getParentId()), |
|
278 | 278 | $search->getConditions(), |
279 | 279 | ); |
280 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
281 | - $search->setSlice( 0, 1 ); |
|
280 | + $search->setConditions($search->combine('&&', $expr)); |
|
281 | + $search->setSlice(0, 1); |
|
282 | 282 | |
283 | - $result = $manager->searchItems( $search ); |
|
283 | + $result = $manager->searchItems($search); |
|
284 | 284 | |
285 | - if( ( $item = reset( $result ) ) === false ) { |
|
286 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon for code "%1$s" is not available any more', $code ) ); |
|
285 | + if (($item = reset($result)) === false) { |
|
286 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon for code "%1$s" is not available any more', $code)); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | |
290 | - $provider = $manager->getProvider( $item, $code ); |
|
290 | + $provider = $manager->getProvider($item, $code); |
|
291 | 291 | |
292 | - if( $provider->isAvailable( $this->get() ) !== true ) { |
|
293 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Requirements for coupon code "%1$s" aren\'t met', $code ) ); |
|
292 | + if ($provider->isAvailable($this->get()) !== true) { |
|
293 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Requirements for coupon code "%1$s" aren\'t met', $code)); |
|
294 | 294 | } |
295 | 295 | |
296 | - $provider->addCoupon( $this->get() ); |
|
296 | + $provider->addCoupon($this->get()); |
|
297 | 297 | $this->save(); |
298 | 298 | } |
299 | 299 | |
@@ -304,21 +304,21 @@ discard block |
||
304 | 304 | * @param string $code Coupon code entered by the user |
305 | 305 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
306 | 306 | */ |
307 | - public function deleteCoupon( $code ) |
|
307 | + public function deleteCoupon($code) |
|
308 | 308 | { |
309 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
309 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
310 | 310 | |
311 | 311 | $search = $manager->createSearch(); |
312 | - $search->setConditions( $search->compare( '==', 'coupon.code.code', $code ) ); |
|
313 | - $search->setSlice( 0, 1 ); |
|
312 | + $search->setConditions($search->compare('==', 'coupon.code.code', $code)); |
|
313 | + $search->setSlice(0, 1); |
|
314 | 314 | |
315 | - $result = $manager->searchItems( $search ); |
|
315 | + $result = $manager->searchItems($search); |
|
316 | 316 | |
317 | - if( ( $item = reset( $result ) ) === false ) { |
|
318 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid', $code ) ); |
|
317 | + if (($item = reset($result)) === false) { |
|
318 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid', $code)); |
|
319 | 319 | } |
320 | 320 | |
321 | - $manager->getProvider( $item, $code )->deleteCoupon( $this->get() ); |
|
321 | + $manager->getProvider($item, $code)->deleteCoupon($this->get()); |
|
322 | 322 | $this->save(); |
323 | 323 | } |
324 | 324 | |
@@ -331,28 +331,28 @@ discard block |
||
331 | 331 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the billing or delivery address is not of any required type of |
332 | 332 | * if one of the keys is invalid when using an array with key/value pairs |
333 | 333 | */ |
334 | - public function setAddress( $type, $value ) |
|
334 | + public function setAddress($type, $value) |
|
335 | 335 | { |
336 | - $address = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/address' )->createItem(); |
|
337 | - $address->setType( $type ); |
|
336 | + $address = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/address')->createItem(); |
|
337 | + $address->setType($type); |
|
338 | 338 | |
339 | - if( $value instanceof \Aimeos\MShop\Common\Item\Address\Iface ) |
|
339 | + if ($value instanceof \Aimeos\MShop\Common\Item\Address\Iface) |
|
340 | 340 | { |
341 | - $address->copyFrom( $value ); |
|
342 | - $this->get()->setAddress( $address, $type ); |
|
341 | + $address->copyFrom($value); |
|
342 | + $this->get()->setAddress($address, $type); |
|
343 | 343 | } |
344 | - else if( is_array( $value ) ) |
|
344 | + else if (is_array($value)) |
|
345 | 345 | { |
346 | - $this->setAddressFromArray( $address, $value ); |
|
347 | - $this->get()->setAddress( $address, $type ); |
|
346 | + $this->setAddressFromArray($address, $value); |
|
347 | + $this->get()->setAddress($address, $type); |
|
348 | 348 | } |
349 | - else if( $value === null ) |
|
349 | + else if ($value === null) |
|
350 | 350 | { |
351 | - $this->get()->deleteAddress( $type ); |
|
351 | + $this->get()->deleteAddress($type); |
|
352 | 352 | } |
353 | 353 | else |
354 | 354 | { |
355 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid value for address type "%1$s"', $type ) ); |
|
355 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Invalid value for address type "%1$s"', $type)); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | $this->save(); |
@@ -368,48 +368,48 @@ discard block |
||
368 | 368 | * entered by the customer when choosing one of the delivery or payment options |
369 | 369 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
370 | 370 | */ |
371 | - public function setService( $type, $id, array $attributes = array() ) |
|
371 | + public function setService($type, $id, array $attributes = array()) |
|
372 | 372 | { |
373 | - if( $id === null ) |
|
373 | + if ($id === null) |
|
374 | 374 | { |
375 | - $this->get()->deleteService( $type ); |
|
375 | + $this->get()->deleteService($type); |
|
376 | 376 | $this->save(); |
377 | 377 | return; |
378 | 378 | } |
379 | 379 | |
380 | 380 | $context = $this->getContext(); |
381 | 381 | |
382 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' ); |
|
383 | - $serviceItem = $this->getDomainItem( 'service', 'service.id', $id, array( 'media', 'price', 'text' ) ); |
|
382 | + $serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service'); |
|
383 | + $serviceItem = $this->getDomainItem('service', 'service.id', $id, array('media', 'price', 'text')); |
|
384 | 384 | |
385 | - $provider = $serviceManager->getProvider( $serviceItem ); |
|
386 | - $result = $provider->checkConfigFE( $attributes ); |
|
387 | - $unknown = array_diff_key( $attributes, $result ); |
|
385 | + $provider = $serviceManager->getProvider($serviceItem); |
|
386 | + $result = $provider->checkConfigFE($attributes); |
|
387 | + $unknown = array_diff_key($attributes, $result); |
|
388 | 388 | |
389 | - if( count( $unknown ) > 0 ) |
|
389 | + if (count($unknown) > 0) |
|
390 | 390 | { |
391 | - $msg = sprintf( 'Unknown attributes "%1$s"', implode( '","', array_keys( $unknown ) ) ); |
|
392 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
391 | + $msg = sprintf('Unknown attributes "%1$s"', implode('","', array_keys($unknown))); |
|
392 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
393 | 393 | } |
394 | 394 | |
395 | - foreach( $result as $key => $value ) |
|
395 | + foreach ($result as $key => $value) |
|
396 | 396 | { |
397 | - if( $value !== null ) { |
|
398 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $value ); |
|
397 | + if ($value !== null) { |
|
398 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($value); |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
402 | - $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/service' ); |
|
402 | + $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/service'); |
|
403 | 403 | $orderServiceItem = $orderBaseServiceManager->createItem(); |
404 | - $orderServiceItem->copyFrom( $serviceItem ); |
|
404 | + $orderServiceItem->copyFrom($serviceItem); |
|
405 | 405 | |
406 | 406 | // remove service rebate of original price |
407 | - $price = $provider->calcPrice( $this->get() )->setRebate( '0.00' ); |
|
408 | - $orderServiceItem->setPrice( $price ); |
|
407 | + $price = $provider->calcPrice($this->get())->setRebate('0.00'); |
|
408 | + $orderServiceItem->setPrice($price); |
|
409 | 409 | |
410 | - $provider->setConfigFE( $orderServiceItem, $attributes ); |
|
410 | + $provider->setConfigFE($orderServiceItem, $attributes); |
|
411 | 411 | |
412 | - $this->get()->setService( $orderServiceItem, $type ); |
|
412 | + $this->get()->setService($orderServiceItem, $type); |
|
413 | 413 | $this->save(); |
414 | 414 | } |
415 | 415 | |
@@ -422,18 +422,18 @@ discard block |
||
422 | 422 | * an address item. |
423 | 423 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
424 | 424 | */ |
425 | - protected function setAddressFromArray( \Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map ) |
|
425 | + protected function setAddressFromArray(\Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map) |
|
426 | 426 | { |
427 | - foreach( $map as $key => $value ) { |
|
428 | - $map[$key] = strip_tags( $value ); // prevent XSS |
|
427 | + foreach ($map as $key => $value) { |
|
428 | + $map[$key] = strip_tags($value); // prevent XSS |
|
429 | 429 | } |
430 | 430 | |
431 | - $errors = $address->fromArray( $map ); |
|
431 | + $errors = $address->fromArray($map); |
|
432 | 432 | |
433 | - if( count( $errors ) > 0 ) |
|
433 | + if (count($errors) > 0) |
|
434 | 434 | { |
435 | - $msg = sprintf( 'Invalid address properties, please check your input' ); |
|
436 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg, 0, null, $errors ); |
|
435 | + $msg = sprintf('Invalid address properties, please check your input'); |
|
436 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg, 0, null, $errors); |
|
437 | 437 | } |
438 | 438 | } |
439 | 439 | } |
@@ -31,42 +31,42 @@ discard block |
||
31 | 31 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
32 | 32 | * @since 2017.03 |
33 | 33 | */ |
34 | - public function addFilterAttribute( \Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds ) |
|
34 | + public function addFilterAttribute(\Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds) |
|
35 | 35 | { |
36 | - if( !empty( $attrIds ) ) |
|
36 | + if (!empty($attrIds)) |
|
37 | 37 | { |
38 | - $attrIds = $this->validateIds( $attrIds ); |
|
38 | + $attrIds = $this->validateIds($attrIds); |
|
39 | 39 | |
40 | - $func = $filter->createFunction( 'index.attributeaggregate', array( $attrIds ) ); |
|
40 | + $func = $filter->createFunction('index.attributeaggregate', array($attrIds)); |
|
41 | 41 | $expr = array( |
42 | - $filter->compare( '==', $func, count( $attrIds ) ), |
|
42 | + $filter->compare('==', $func, count($attrIds)), |
|
43 | 43 | $filter->getConditions(), |
44 | 44 | ); |
45 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
45 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
46 | 46 | } |
47 | 47 | |
48 | - if( !empty( $optIds ) ) |
|
48 | + if (!empty($optIds)) |
|
49 | 49 | { |
50 | - $optIds = $this->validateIds( $optIds ); |
|
50 | + $optIds = $this->validateIds($optIds); |
|
51 | 51 | |
52 | - $func = $filter->createFunction( 'index.attributeaggregate', array( $optIds ) ); |
|
52 | + $func = $filter->createFunction('index.attributeaggregate', array($optIds)); |
|
53 | 53 | $expr = array( |
54 | - $filter->compare( '>', $func, 0 ), |
|
54 | + $filter->compare('>', $func, 0), |
|
55 | 55 | $filter->getConditions(), |
56 | 56 | ); |
57 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
57 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
58 | 58 | } |
59 | 59 | |
60 | - foreach( $oneIds as $type => $list ) |
|
60 | + foreach ($oneIds as $type => $list) |
|
61 | 61 | { |
62 | - if( ( $list = $this->validateIds( (array) $list ) ) !== array() ) |
|
62 | + if (($list = $this->validateIds((array) $list)) !== array()) |
|
63 | 63 | { |
64 | - $func = $filter->createFunction( 'index.attributeaggregate', array( $list ) ); |
|
64 | + $func = $filter->createFunction('index.attributeaggregate', array($list)); |
|
65 | 65 | $expr = array( |
66 | - $filter->compare( '>', $func, 0 ), |
|
66 | + $filter->compare('>', $func, 0), |
|
67 | 67 | $filter->getConditions(), |
68 | 68 | ); |
69 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
69 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
@@ -86,38 +86,38 @@ discard block |
||
86 | 86 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
87 | 87 | * @since 2017.03 |
88 | 88 | */ |
89 | - public function addFilterCategory( \Aimeos\MW\Criteria\Iface $filter, $catId, |
|
90 | - $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default' ) |
|
89 | + public function addFilterCategory(\Aimeos\MW\Criteria\Iface $filter, $catId, |
|
90 | + $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default') |
|
91 | 91 | { |
92 | - $catIds = ( !is_array( $catId ) ? explode( ',', $catId ) : $catId ); |
|
92 | + $catIds = (!is_array($catId) ? explode(',', $catId) : $catId); |
|
93 | 93 | |
94 | - if( $level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ) |
|
94 | + if ($level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE) |
|
95 | 95 | { |
96 | 96 | $list = array(); |
97 | - $cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'catalog' ); |
|
97 | + $cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'catalog'); |
|
98 | 98 | |
99 | - foreach( $catIds as $catId ) |
|
99 | + foreach ($catIds as $catId) |
|
100 | 100 | { |
101 | - $tree = $cntl->getCatalogTree( $catId, array(), $level ); |
|
102 | - $list = array_merge( $list, $this->getCatalogIdsFromTree( $tree ) ); |
|
101 | + $tree = $cntl->getCatalogTree($catId, array(), $level); |
|
102 | + $list = array_merge($list, $this->getCatalogIdsFromTree($tree)); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | $catIds = $list; |
106 | 106 | } |
107 | 107 | |
108 | - $expr = array( $filter->compare( '==', 'index.catalog.id', array_unique( $catIds ) ) ); |
|
108 | + $expr = array($filter->compare('==', 'index.catalog.id', array_unique($catIds))); |
|
109 | 109 | $expr[] = $filter->getConditions(); |
110 | 110 | |
111 | - if( $sort === 'relevance' ) |
|
111 | + if ($sort === 'relevance') |
|
112 | 112 | { |
113 | - $cmpfunc = $filter->createFunction( 'index.catalog.position', array( $listtype, $catIds ) ); |
|
114 | - $expr[] = $filter->compare( '>=', $cmpfunc, 0 ); |
|
113 | + $cmpfunc = $filter->createFunction('index.catalog.position', array($listtype, $catIds)); |
|
114 | + $expr[] = $filter->compare('>=', $cmpfunc, 0); |
|
115 | 115 | |
116 | - $sortfunc = $filter->createFunction( 'sort:index.catalog.position', array( $listtype, $catIds ) ); |
|
117 | - $filter->setSortations( array( $filter->sort( $direction, $sortfunc ) ) ); |
|
116 | + $sortfunc = $filter->createFunction('sort:index.catalog.position', array($listtype, $catIds)); |
|
117 | + $filter->setSortations(array($filter->sort($direction, $sortfunc))); |
|
118 | 118 | } |
119 | 119 | |
120 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
120 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
121 | 121 | |
122 | 122 | return $filter; |
123 | 123 | } |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
135 | 135 | * @since 2017.03 |
136 | 136 | */ |
137 | - public function addFilterText( \Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default' ) |
|
137 | + public function addFilterText(\Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default') |
|
138 | 138 | { |
139 | 139 | $langid = $this->getContext()->getLocale()->getLanguageId(); |
140 | - $cmpfunc = $filter->createFunction( 'index.text.relevance', array( $listtype, $langid, $input ) ); |
|
141 | - $expr = array( $filter->compare( '>', $cmpfunc, 0 ), $filter->getConditions() ); |
|
140 | + $cmpfunc = $filter->createFunction('index.text.relevance', array($listtype, $langid, $input)); |
|
141 | + $expr = array($filter->compare('>', $cmpfunc, 0), $filter->getConditions()); |
|
142 | 142 | |
143 | - return $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
143 | + return $filter->setConditions($filter->combine('&&', $expr)); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | * @return array Associative list of key values as key and the product count for this key as value |
153 | 153 | * @since 2017.03 |
154 | 154 | */ |
155 | - public function aggregate( \Aimeos\MW\Criteria\Iface $filter, $key ) |
|
155 | + public function aggregate(\Aimeos\MW\Criteria\Iface $filter, $key) |
|
156 | 156 | { |
157 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->aggregate( $filter, $key ); |
|
157 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->aggregate($filter, $key); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -169,46 +169,46 @@ discard block |
||
169 | 169 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
170 | 170 | * @since 2017.03 |
171 | 171 | */ |
172 | - public function createFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' ) |
|
172 | + public function createFilter($sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default') |
|
173 | 173 | { |
174 | 174 | $sortations = array(); |
175 | 175 | $context = $this->getContext(); |
176 | 176 | |
177 | - $search = \Aimeos\MShop\Factory::createManager( $context, 'index' )->createSearch( true ); |
|
178 | - $expr = array( $search->compare( '!=', 'index.catalog.id', null ) ); |
|
177 | + $search = \Aimeos\MShop\Factory::createManager($context, 'index')->createSearch(true); |
|
178 | + $expr = array($search->compare('!=', 'index.catalog.id', null)); |
|
179 | 179 | |
180 | - switch( $sort ) |
|
180 | + switch ($sort) |
|
181 | 181 | { |
182 | 182 | case 'code': |
183 | - $sortations[] = $search->sort( $direction, 'product.code' ); |
|
183 | + $sortations[] = $search->sort($direction, 'product.code'); |
|
184 | 184 | break; |
185 | 185 | |
186 | 186 | case 'name': |
187 | 187 | $langid = $context->getLocale()->getLanguageId(); |
188 | 188 | |
189 | - $cmpfunc = $search->createFunction( 'index.text.value', array( $listtype, $langid, 'name', 'product' ) ); |
|
190 | - $expr[] = $search->compare( '>=', $cmpfunc, '' ); |
|
189 | + $cmpfunc = $search->createFunction('index.text.value', array($listtype, $langid, 'name', 'product')); |
|
190 | + $expr[] = $search->compare('>=', $cmpfunc, ''); |
|
191 | 191 | |
192 | - $sortfunc = $search->createFunction( 'sort:index.text.value', array( $listtype, $langid, 'name' ) ); |
|
193 | - $sortations[] = $search->sort( $direction, $sortfunc ); |
|
192 | + $sortfunc = $search->createFunction('sort:index.text.value', array($listtype, $langid, 'name')); |
|
193 | + $sortations[] = $search->sort($direction, $sortfunc); |
|
194 | 194 | break; |
195 | 195 | |
196 | 196 | case 'price': |
197 | 197 | $currencyid = $context->getLocale()->getCurrencyId(); |
198 | 198 | |
199 | - $cmpfunc = $search->createFunction( 'index.price.value', array( $listtype, $currencyid, 'default' ) ); |
|
200 | - $expr[] = $search->compare( '>=', $cmpfunc, '0.00' ); |
|
199 | + $cmpfunc = $search->createFunction('index.price.value', array($listtype, $currencyid, 'default')); |
|
200 | + $expr[] = $search->compare('>=', $cmpfunc, '0.00'); |
|
201 | 201 | |
202 | - $sortfunc = $search->createFunction( 'sort:index.price.value', array( $listtype, $currencyid, 'default' ) ); |
|
203 | - $sortations[] = $search->sort( $direction, $sortfunc ); |
|
202 | + $sortfunc = $search->createFunction('sort:index.price.value', array($listtype, $currencyid, 'default')); |
|
203 | + $sortations[] = $search->sort($direction, $sortfunc); |
|
204 | 204 | break; |
205 | 205 | } |
206 | 206 | |
207 | 207 | $expr[] = $search->getConditions(); |
208 | 208 | |
209 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
210 | - $search->setSortations( $sortations ); |
|
211 | - $search->setSlice( $start, $size ); |
|
209 | + $search->setConditions($search->combine('&&', $expr)); |
|
210 | + $search->setSortations($sortations); |
|
211 | + $search->setSlice($start, $size); |
|
212 | 212 | |
213 | 213 | return $search; |
214 | 214 | } |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items |
223 | 223 | * @since 2017.03 |
224 | 224 | */ |
225 | - public function getItem( $productId, array $domains = array( 'attribute', 'media', 'price', 'product', 'product/property', 'text' ) ) |
|
225 | + public function getItem($productId, array $domains = array('attribute', 'media', 'price', 'product', 'product/property', 'text')) |
|
226 | 226 | { |
227 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' )->getItem( $productId, $domains, true ); |
|
227 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'product')->getItem($productId, $domains, true); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | |
@@ -236,19 +236,19 @@ discard block |
||
236 | 236 | * @return \Aimeos\MShop\Product\Item\Iface[] Associative list of product IDs as keys and product items as values |
237 | 237 | * @since 2017.03 |
238 | 238 | */ |
239 | - public function getItems( array $productIds, array $domains = array( 'media', 'price', 'text' ) ) |
|
239 | + public function getItems(array $productIds, array $domains = array('media', 'price', 'text')) |
|
240 | 240 | { |
241 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
241 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
242 | 242 | |
243 | - $search = $manager->createSearch( true ); |
|
243 | + $search = $manager->createSearch(true); |
|
244 | 244 | $expr = array( |
245 | - $search->compare( '==', 'product.id', $productIds ), |
|
245 | + $search->compare('==', 'product.id', $productIds), |
|
246 | 246 | $search->getConditions(), |
247 | 247 | ); |
248 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
249 | - $search->setSlice( 0, count( $productIds ) ); |
|
248 | + $search->setConditions($search->combine('&&', $expr)); |
|
249 | + $search->setSlice(0, count($productIds)); |
|
250 | 250 | |
251 | - return $manager->searchItems( $search, $domains ); |
|
251 | + return $manager->searchItems($search, $domains); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface |
262 | 262 | * @since 2017.03 |
263 | 263 | */ |
264 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ) |
|
264 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null) |
|
265 | 265 | { |
266 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->searchItems( $filter, $domains, $total ); |
|
266 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->searchItems($filter, $domains, $total); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -273,12 +273,12 @@ discard block |
||
273 | 273 | * @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item with children |
274 | 274 | * @return array List of catalog IDs |
275 | 275 | */ |
276 | - protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item ) |
|
276 | + protected function getCatalogIdsFromTree(\Aimeos\MShop\Catalog\Item\Iface $item) |
|
277 | 277 | { |
278 | - $list = array( $item->getId() ); |
|
278 | + $list = array($item->getId()); |
|
279 | 279 | |
280 | - foreach( $item->getChildren() as $child ) { |
|
281 | - $list = array_merge( $list, $this->getCatalogIdsFromTree( $child ) ); |
|
280 | + foreach ($item->getChildren() as $child) { |
|
281 | + $list = array_merge($list, $this->getCatalogIdsFromTree($child)); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | return $list; |
@@ -291,13 +291,13 @@ discard block |
||
291 | 291 | * @param array $ids List of IDs to validate |
292 | 292 | * @return array List of validated IDs |
293 | 293 | */ |
294 | - protected function validateIds( array $ids ) |
|
294 | + protected function validateIds(array $ids) |
|
295 | 295 | { |
296 | 296 | $list = array(); |
297 | 297 | |
298 | - foreach( $ids as $id ) |
|
298 | + foreach ($ids as $id) |
|
299 | 299 | { |
300 | - if( $id != '' ) { |
|
300 | + if ($id != '') { |
|
301 | 301 | $list[] = (int) $id; |
302 | 302 | } |
303 | 303 | } |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | |
17 | 17 | protected function setUp() |
18 | 18 | { |
19 | - $this->object = new \Aimeos\Controller\Frontend\Locale\Standard( \TestHelperFrontend::getContext() ); |
|
19 | + $this->object = new \Aimeos\Controller\Frontend\Locale\Standard(\TestHelperFrontend::getContext()); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
23 | 23 | protected function tearDown() |
24 | 24 | { |
25 | - unset( $this->object ); |
|
25 | + unset($this->object); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -30,29 +30,29 @@ discard block |
||
30 | 30 | { |
31 | 31 | $filter = $this->object->createFilter(); |
32 | 32 | |
33 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
34 | - $this->assertEquals( 1, count( $filter->getSortations() ) ); |
|
35 | - $this->assertEquals( 0, $filter->getSliceStart() ); |
|
36 | - $this->assertEquals( 100, $filter->getSliceSize() ); |
|
33 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
34 | + $this->assertEquals(1, count($filter->getSortations())); |
|
35 | + $this->assertEquals(0, $filter->getSliceStart()); |
|
36 | + $this->assertEquals(100, $filter->getSliceSize()); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
40 | 40 | public function testGetItem() |
41 | 41 | { |
42 | - $localeManager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'locale' ); |
|
43 | - $search = $localeManager->createSearch( true ); |
|
44 | - $search->setSortations( [$search->sort( '+', 'locale.position' )] ); |
|
45 | - $search->setSlice( 0, 1 ); |
|
46 | - $localeItems = $localeManager->searchItems( $search ); |
|
47 | - |
|
48 | - if( ( $localeItem = reset( $localeItems ) ) === false ) { |
|
49 | - throw new \Exception( 'No locale item found' ); |
|
42 | + $localeManager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'locale'); |
|
43 | + $search = $localeManager->createSearch(true); |
|
44 | + $search->setSortations([$search->sort('+', 'locale.position')]); |
|
45 | + $search->setSlice(0, 1); |
|
46 | + $localeItems = $localeManager->searchItems($search); |
|
47 | + |
|
48 | + if (($localeItem = reset($localeItems)) === false) { |
|
49 | + throw new \Exception('No locale item found'); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
53 | - $result = $this->object->getItem( $localeItem->getId() ); |
|
53 | + $result = $this->object->getItem($localeItem->getId()); |
|
54 | 54 | |
55 | - $this->assertInstanceOf( '\Aimeos\MShop\Locale\Item\Iface', $result ); |
|
55 | + $this->assertInstanceOf('\Aimeos\MShop\Locale\Item\Iface', $result); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | { |
61 | 61 | $total = 0; |
62 | 62 | $filter = $this->object->createFilter(); |
63 | - $results = $this->object->searchItems( $filter, [], $total ); |
|
63 | + $results = $this->object->searchItems($filter, [], $total); |
|
64 | 64 | |
65 | - $this->assertEquals( 1, $total ); |
|
66 | - $this->assertEquals( 1, count( $results ) ); |
|
65 | + $this->assertEquals(1, $total); |
|
66 | + $this->assertEquals(1, count($results)); |
|
67 | 67 | } |
68 | 68 | } |