1
|
|
|
<?php |
2
|
|
|
/*************************************************************************************/ |
3
|
|
|
/* This file is part of the Thelia package. */ |
4
|
|
|
/* */ |
5
|
|
|
/* Copyright (c) OpenStudio */ |
6
|
|
|
/* email : [email protected] */ |
7
|
|
|
/* web : http://www.thelia.net */ |
8
|
|
|
/* */ |
9
|
|
|
/* For the full copyright and license information, please view the LICENSE.txt */ |
10
|
|
|
/* file that was distributed with this source code. */ |
11
|
|
|
/*************************************************************************************/ |
12
|
|
|
|
13
|
|
|
namespace Thelia\ImportExport\Export\Type; |
14
|
|
|
|
15
|
|
|
use Propel\Runtime\ActiveQuery\Criteria; |
16
|
|
|
use Propel\Runtime\ActiveQuery\Join; |
17
|
|
|
use Thelia\Model\Lang; |
18
|
|
|
use Thelia\Model\Map\AttributeAvI18nTableMap; |
19
|
|
|
use Thelia\Model\Map\AttributeAvTableMap; |
20
|
|
|
use Thelia\Model\Map\CurrencyTableMap; |
21
|
|
|
use Thelia\Model\Map\ProductI18nTableMap; |
22
|
|
|
use Thelia\Model\Map\ProductPriceTableMap; |
23
|
|
|
use Thelia\Model\Map\ProductSaleElementsTableMap; |
24
|
|
|
use Thelia\Model\Map\ProductTableMap; |
25
|
|
|
use Thelia\Model\Map\TaxRuleI18nTableMap; |
26
|
|
|
use Thelia\Model\Map\TaxRuleTableMap; |
27
|
|
|
use Thelia\Model\ProductSaleElementsQuery; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Class ProductTaxedPricesExport |
31
|
|
|
* @package Thelia\ImportExport\Export\Type |
32
|
|
|
* @author Thomas Arnaud <[email protected]> |
33
|
|
|
*/ |
34
|
|
|
class ProductTaxedPricesExport extends ProductPricesExport |
35
|
|
|
{ |
36
|
|
|
public function buildDataSet(Lang $lang) |
37
|
|
|
{ |
38
|
|
|
$locale = $lang->getLocale(); |
39
|
|
|
|
40
|
|
|
$productI18nJoin = new Join(ProductTableMap::ID, ProductI18nTableMap::ID, Criteria::LEFT_JOIN); |
41
|
|
|
|
42
|
|
|
$attributeAvI18nJoin = new Join(AttributeAvTableMap::ID, AttributeAvI18nTableMap::ID, Criteria::LEFT_JOIN); |
43
|
|
|
|
44
|
|
|
$taxRuleI18nJoin = new Join(TaxRuleTableMap::ID, TaxRuleI18nTableMap::ID, Criteria::LEFT_JOIN); |
45
|
|
|
|
46
|
|
|
$query = ProductSaleElementsQuery::create() |
47
|
|
|
->useProductPriceQuery() |
48
|
|
|
->useCurrencyQuery() |
49
|
|
|
->addAsColumn("currency_CODE", CurrencyTableMap::CODE) |
50
|
|
|
->endUse() |
51
|
|
|
->addAsColumn("price_PRICE", ProductPriceTableMap::PRICE) |
52
|
|
|
->addAsColumn("price_PROMO_PRICE", ProductPriceTableMap::PROMO_PRICE) |
53
|
|
|
->endUse() |
54
|
|
|
->useProductQuery() |
55
|
|
|
->useTaxRuleQuery() |
56
|
|
|
->addJoinObject($taxRuleI18nJoin, "tax_rule_i18n_join") |
57
|
|
|
->addJoinCondition( |
58
|
|
|
"tax_rule_i18n_join", |
59
|
|
|
TaxRuleI18nTableMap::LOCALE . " = ?", |
60
|
|
|
$locale, |
61
|
|
|
null, |
62
|
|
|
\PDO::PARAM_STR |
63
|
|
|
) |
64
|
|
|
->addAsColumn("tax_TITLE", TaxRuleI18nTableMap::TITLE) |
65
|
|
|
->addAsColumn("tax_ID", TaxRuleTableMap::ID) |
66
|
|
|
->endUse() |
67
|
|
|
->addJoinObject($productI18nJoin, "product_i18n_join") |
68
|
|
|
->addJoinCondition( |
69
|
|
|
"product_i18n_join", |
70
|
|
|
ProductI18nTableMap::LOCALE . " = ?", |
71
|
|
|
$locale, |
72
|
|
|
null, |
73
|
|
|
\PDO::PARAM_STR |
74
|
|
|
) |
75
|
|
|
->addAsColumn("product_TITLE", ProductI18nTableMap::TITLE) |
76
|
|
|
->addAsColumn("product_ID", ProductTableMap::ID) |
77
|
|
|
->endUse() |
78
|
|
|
->useAttributeCombinationQuery(null, Criteria::LEFT_JOIN) |
79
|
|
|
->useAttributeAvQuery(null, Criteria::LEFT_JOIN) |
80
|
|
|
->addJoinObject($attributeAvI18nJoin, "attribute_av_i18n_join") |
81
|
|
|
->addJoinCondition( |
82
|
|
|
"attribute_av_i18n_join", |
83
|
|
|
AttributeAvI18nTableMap::LOCALE . " = ?", |
84
|
|
|
$locale, |
85
|
|
|
null, |
86
|
|
|
\PDO::PARAM_STR |
87
|
|
|
) |
88
|
|
|
->addAsColumn( |
89
|
|
|
"attribute_av_i18n_ATTRIBUTES", |
90
|
|
|
"GROUP_CONCAT(DISTINCT ".AttributeAvI18nTableMap::TITLE.")" |
91
|
|
|
) |
92
|
|
|
->endUse() |
93
|
|
|
->endUse() |
94
|
|
|
->addAsColumn("product_sale_elements_ID", ProductSaleElementsTableMap::ID) |
95
|
|
|
->addAsColumn("product_sale_elements_EAN_CODE", ProductSaleElementsTableMap::EAN_CODE) |
96
|
|
|
->addAsColumn("product_sale_elements_PROMO", ProductSaleElementsTableMap::PROMO) |
97
|
|
|
->select([ |
98
|
|
|
"product_sale_elements_ID", |
99
|
|
|
"product_sale_elements_EAN_CODE", |
100
|
|
|
"product_sale_elements_PROMO", |
101
|
|
|
"price_PRICE", |
102
|
|
|
"price_PROMO_PRICE", |
103
|
|
|
"currency_CODE", |
104
|
|
|
"product_TITLE", |
105
|
|
|
"attribute_av_i18n_ATTRIBUTES", |
106
|
|
|
"tax_TITLE", |
107
|
|
|
"tax_ID" |
108
|
|
|
]) |
109
|
|
|
->orderBy("product_sale_elements_ID") |
110
|
|
|
->groupBy("product_sale_elements_ID") |
111
|
|
|
; |
112
|
|
|
|
113
|
|
|
return $query; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
protected function getAliases() |
117
|
|
|
{ |
118
|
|
|
return [ |
119
|
|
|
"product_sale_elements_ID" => "id", |
120
|
|
|
"product_sale_elements_EAN_CODE" => "ean", |
121
|
|
|
"price_PRICE" => "price", |
122
|
|
|
"price_PROMO_PRICE" => "promo_price", |
123
|
|
|
"currency_CODE" => "currency", |
124
|
|
|
"product_TITLE" => "title", |
125
|
|
|
"product_sale_elements_PROMO" => "promo", |
126
|
|
|
"attribute_av_i18n_ATTRIBUTES" => "attributes", |
127
|
|
|
"tax_TITLE" => "tax_title", |
128
|
|
|
"tax_id" => "tax_id", |
129
|
|
|
]; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
public function getOrder() |
133
|
|
|
{ |
134
|
|
|
return [ |
135
|
|
|
"id", |
136
|
|
|
"product_id", |
137
|
|
|
"title", |
138
|
|
|
"attributes", |
139
|
|
|
"ean", |
140
|
|
|
"price", |
141
|
|
|
"promo_price", |
142
|
|
|
"currency", |
143
|
|
|
"promo", |
144
|
|
|
"tax_id", |
145
|
|
|
"tax_title", |
146
|
|
|
]; |
147
|
|
|
} |
148
|
|
|
} |
149
|
|
|
|