|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* (c) shopware AG <[email protected]> |
|
4
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
5
|
|
|
* file that was distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace ShopwarePlugins\Connect\Components; |
|
9
|
|
|
|
|
10
|
|
|
use Shopware\Models\Customer\Group; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Price gateway |
|
14
|
|
|
* |
|
15
|
|
|
* @category Shopware |
|
16
|
|
|
* @package Shopware\Components\Api |
|
17
|
|
|
* @copyright Copyright (c) shopware AG (http://www.shopware.de) |
|
18
|
|
|
*/ |
|
19
|
|
|
class PriceGateway |
|
20
|
|
|
{ |
|
21
|
|
|
private $db; |
|
22
|
|
|
|
|
23
|
|
|
public function __construct(\Enlight_Components_Db_Adapter_Pdo_Mysql $db) |
|
24
|
|
|
{ |
|
25
|
|
|
$this->db = $db; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Returns count of product without |
|
30
|
|
|
* configured price |
|
31
|
|
|
* |
|
32
|
|
|
* @param Group $group |
|
|
|
|
|
|
33
|
|
|
* @param $priceField |
|
34
|
|
|
* @throws \Zend_Db_Statement_Exception |
|
35
|
|
|
* @return array |
|
36
|
|
|
*/ |
|
37
|
|
View Code Duplication |
public function countProductsWithoutConfiguredPrice(Group $group = null, $priceField) |
|
|
|
|
|
|
38
|
|
|
{ |
|
39
|
|
|
if ($priceField == 'detailPurchasePrice') { |
|
40
|
|
|
$query = $this->db->query(' |
|
41
|
|
|
SELECT COUNT(sad.id) |
|
42
|
|
|
FROM s_articles_details sad |
|
43
|
|
|
LEFT JOIN s_plugin_connect_items spci ON sad.id = spci.article_detail_id |
|
44
|
|
|
WHERE spci.shop_id IS NULL AND sad.purchaseprice = 0 |
|
45
|
|
|
'); |
|
46
|
|
|
} else { |
|
47
|
|
|
$query = $this->db->query(" |
|
48
|
|
|
SELECT COUNT(sad.id) |
|
49
|
|
|
FROM s_articles_details sad |
|
50
|
|
|
LEFT JOIN s_articles_prices sap ON sad.id = sap.articledetailsID AND sap.pricegroup = ? |
|
51
|
|
|
LEFT JOIN s_plugin_connect_items spci ON sad.id = spci.article_detail_id |
|
52
|
|
|
WHERE spci.shop_id IS NULL AND sap.{$priceField} IS NULL OR sap.{$priceField} = 0 |
|
53
|
|
|
", [$group->getKey()]); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
return (int) $query->fetchColumn(); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Returns count of product with |
|
61
|
|
|
* configured price |
|
62
|
|
|
* |
|
63
|
|
|
* @param Group $group |
|
|
|
|
|
|
64
|
|
|
* @param $priceField |
|
65
|
|
|
* @throws \Zend_Db_Statement_Exception |
|
66
|
|
|
* @return array |
|
67
|
|
|
*/ |
|
68
|
|
View Code Duplication |
public function countProductsWithConfiguredPrice(Group $group = null, $priceField) |
|
|
|
|
|
|
69
|
|
|
{ |
|
70
|
|
|
if ($priceField == 'detailPurchasePrice') { |
|
71
|
|
|
$query = $this->db->query(' |
|
72
|
|
|
SELECT COUNT(sad.id) |
|
73
|
|
|
FROM s_articles_details sad |
|
74
|
|
|
LEFT JOIN s_plugin_connect_items spci ON sad.id = spci.article_detail_id |
|
75
|
|
|
WHERE spci.shop_id IS NULL AND sad.purchaseprice > 0 |
|
76
|
|
|
'); |
|
77
|
|
|
} else { |
|
78
|
|
|
$query = $this->db->query(" |
|
79
|
|
|
SELECT COUNT(sad.id) |
|
80
|
|
|
FROM s_articles_details sad |
|
81
|
|
|
LEFT JOIN s_articles_prices sap ON sad.id = sap.articledetailsID AND sap.pricegroup = ? |
|
82
|
|
|
LEFT JOIN s_plugin_connect_items spci ON sad.id = spci.article_detail_id |
|
83
|
|
|
WHERE spci.shop_id IS NULL AND sap.{$priceField} IS NOT NULL AND sap.{$priceField} > 0 |
|
84
|
|
|
", [$group->getKey()]); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
return (int) $query->fetchColumn(); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Returns count of product including variants for a group |
|
92
|
|
|
* |
|
93
|
|
|
* @param Group $group |
|
|
|
|
|
|
94
|
|
|
* @throws \Zend_Db_Statement_Exception |
|
95
|
|
|
* @return array |
|
96
|
|
|
*/ |
|
97
|
|
|
public function countProducts(Group $group = null) |
|
98
|
|
|
{ |
|
99
|
|
|
$query = $this->db->query(' |
|
100
|
|
|
SELECT COUNT(sad.id) |
|
101
|
|
|
FROM s_articles_details sad |
|
102
|
|
|
LEFT JOIN s_articles_prices sap ON sad.id = sap.articledetailsID AND sap.pricegroup = ? |
|
103
|
|
|
LEFT JOIN s_plugin_connect_items spci ON sad.id = spci.article_detail_id |
|
104
|
|
|
WHERE spci.shop_id IS NULL', [$group->getKey()]); |
|
105
|
|
|
|
|
106
|
|
|
return (int) $query->fetchColumn(); |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|
This check looks for
@paramannotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.