FactFinderSdkQueryContainer::getExportDataQuery()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 22
rs 9.7998
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
/**
4
 * MIT License
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\FactFinderSdk\Persistence;
9
10
use Generated\Shared\Transfer\CurrencyTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\CurrencyTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Generated\Shared\Transfer\LocaleTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\LocaleTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Generated\Shared\Transfer\ProductAbstractDataFeedTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...bstractDataFeedTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Generated\Shared\Transfer\StoreTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\StoreTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Orm\Zed\Category\Persistence\Map\SpyCategoryAttributeTableMap;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Category\Persist...tegoryAttributeTableMap was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Orm\Zed\Category\Persistence\Map\SpyCategoryTableMap;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Category\Persist...Map\SpyCategoryTableMap was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use Orm\Zed\PriceProduct\Persistence\Map\SpyPriceProductStoreTableMap;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\PriceProduct\Per...iceProductStoreTableMap was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use Orm\Zed\Product\Persistence\Map\SpyProductAbstractTableMap;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Product\Persiste...ProductAbstractTableMap was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use Orm\Zed\Product\Persistence\Map\SpyProductLocalizedAttributesTableMap;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Product\Persiste...lizedAttributesTableMap was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
use Orm\Zed\Product\Persistence\Map\SpyProductTableMap;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Product\Persistence\Map\SpyProductTableMap was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
use Orm\Zed\Product\Persistence\SpyProductAbstractQuery;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Product\Persiste...SpyProductAbstractQuery was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
use Orm\Zed\ProductCategory\Persistence\Map\SpyProductCategoryTableMap;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\ProductCategory\...ProductCategoryTableMap was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
use Orm\Zed\ProductImage\Persistence\Map\SpyProductImageTableMap;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\ProductImage\Per...SpyProductImageTableMap was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
use Orm\Zed\Stock\Persistence\Map\SpyStockProductTableMap;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Stock\Persistenc...SpyStockProductTableMap was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
use Spryker\Zed\Kernel\Persistence\AbstractQueryContainer;
25
use Spryker\Zed\PropelOrm\Business\Runtime\ActiveQuery\Criteria;
26
use SprykerEco\Shared\FactFinderSdk\FactFinderSdkConstants;
27
28
/**
29
 * @method \SprykerEco\Zed\FactFinderSdk\Persistence\FactFinderSdkPersistenceFactory getFactory()
30
 */
31
class FactFinderSdkQueryContainer extends AbstractQueryContainer implements FactFinderSdkQueryContainerInterface
32
{
33
    public const STOCK_QUANTITY_CONDITION = 'STOCK_QUANTITY_CONDITION';
34
    public const STOCK_NEVER_OUTOFSTOCK_CONDITION = 'STOCK_NEVER_OUTOFSTOCK_CONDITION';
35
36
    /**
37
     * @uses \Orm\Zed\Url\Persistence\Map\SpyUrlTableMap::COL_URL
38
     */
39
    protected const COLUMN_URL = 'spy_url.url';
40
41
    /**
42
     * {@inheritDoc}
43
     *
44
     * @api
45
     *
46
     * @module Product
47
     * @module ProductAbstractDataFeed
48
     * @module Url
49
     *
50
     * @param \Generated\Shared\Transfer\LocaleTransfer $localeTransfer
51
     * @param \Generated\Shared\Transfer\StoreTransfer $storeTransfer
52
     * @param \Generated\Shared\Transfer\CurrencyTransfer $currencyTransfer
53
     *
54
     * @throws \Spryker\Zed\Propel\Business\Exception\AmbiguousComparisonException
55
     *
56
     * @return \Orm\Zed\Product\Persistence\SpyProductAbstractQuery
57
     */
58
    public function getExportDataQuery(LocaleTransfer $localeTransfer, StoreTransfer $storeTransfer, CurrencyTransfer $currencyTransfer)
59
    {
60
        $productAbstractDataFeedTransfer = new ProductAbstractDataFeedTransfer();
61
        $productAbstractDataFeedTransfer->setJoinProduct(true);
62
        $productAbstractDataFeedTransfer->setJoinImage(true);
63
64
        $productAbstractDataFeedTransfer->setIdLocale($localeTransfer->getIdLocale());
65
66
        $productsAbstractQuery = $this->getFactory()
67
            ->getProductAbstractDataFeedQueryContainer()
68
            ->queryAbstractProductDataFeed($productAbstractDataFeedTransfer);
69
70
        $productsAbstractQuery
71
            ->useSpyUrlQuery()
72
                ->filterByFkLocale($localeTransfer->getIdLocale())
73
            ->endUse();
74
75
        $productsAbstractQuery = $this->addColumns($productsAbstractQuery);
76
77
        $productsAbstractQuery->orderBySku();
78
79
        return $productsAbstractQuery;
80
    }
81
82
    /**
83
     * {@inheritDoc}
84
     *
85
     * @api
86
     *
87
     * @module Category
88
     *
89
     * @param \Generated\Shared\Transfer\LocaleTransfer $localeTransfer
90
     * @param int $idProductAbstract
91
     *
92
     * @return \Orm\Zed\Category\Persistence\SpyCategoryQuery
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Category\Persistence\SpyCategoryQuery was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
93
     */
94
    public function getCategoriesQuery(LocaleTransfer $localeTransfer, $idProductAbstract)
95
    {
96
        $categoryQuery = $this->getFactory()
97
            ->createCategoryQuery();
98
        $categoryQuery->joinWithSpyProductCategory(Criteria::LEFT_JOIN)
99
            ->joinWithAttribute(Criteria::INNER_JOIN)
100
            ->where(SpyProductCategoryTableMap::COL_FK_PRODUCT_ABSTRACT . ' = ?', $idProductAbstract)
101
            ->where(SpyCategoryAttributeTableMap::COL_FK_LOCALE . ' = ?', $localeTransfer->getIdLocale())
102
            ->withColumn(SpyCategoryAttributeTableMap::COL_NAME, 'name');
103
104
        return $categoryQuery;
105
    }
106
107
    /**
108
     * {@inheritDoc}
109
     *
110
     * @api
111
     *
112
     * @module Category
113
     *
114
     * @param int $idCategory
115
     * @param \Generated\Shared\Transfer\LocaleTransfer $localeTransfer
116
     *
117
     * @return \Orm\Zed\Category\Persistence\SpyCategoryQuery
118
     */
119
    public function getCategoryQuery($idCategory, LocaleTransfer $localeTransfer)
120
    {
121
        $categoryQuery = $this->getFactory()
122
            ->createCategoryQuery();
123
        $categoryQuery->joinWithAttribute(Criteria::INNER_JOIN);
124
125
        $categoryQuery->where(SpyCategoryTableMap::COL_ID_CATEGORY . ' = ?', $idCategory);
126
        $categoryQuery->where(SpyCategoryAttributeTableMap::COL_FK_LOCALE . ' = ?', $localeTransfer->getIdLocale());
127
        $categoryQuery->withColumn(SpyCategoryAttributeTableMap::COL_NAME, 'name');
128
129
        return $categoryQuery;
130
    }
131
132
    /**
133
     * {@inheritDoc}
134
     *
135
     * @api
136
     *
137
     * @module Product
138
     * @module PriceProduct
139
     *
140
     * @param string $concreteProductSku
141
     * @param \Generated\Shared\Transfer\CurrencyTransfer $currencyTransfer
142
     * @param \Generated\Shared\Transfer\StoreTransfer $storeTransfer
143
     *
144
     * @return \Orm\Zed\PriceProduct\Persistence\SpyPriceProductQuery
0 ignored issues
show
Bug introduced by
The type Orm\Zed\PriceProduct\Per...ce\SpyPriceProductQuery was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
145
     */
146
    public function getPricesQuery($concreteProductSku, CurrencyTransfer $currencyTransfer, StoreTransfer $storeTransfer)
147
    {
148
        $priceProductQuery = $this->getFactory()
149
            ->createPriceProductQuery();
150
151
        $priceProductQuery
152
            ->useProductQuery()
153
                ->filterBySku($concreteProductSku)
154
            ->endUse()
155
            ->usePriceProductStoreQuery()
156
                ->filterByFkCurrency($currencyTransfer->getIdCurrency())
157
                ->filterByFkStore($storeTransfer->getIdStore())
158
            ->endUse();
159
160
        $priceProductQuery->withColumn(SpyPriceProductStoreTableMap::COL_GROSS_PRICE, FactFinderSdkConstants::ITEM_PRICE);
161
162
        return $priceProductQuery;
163
    }
164
165
    /**
166
     * {@inheritDoc}
167
     *
168
     * @api
169
     *
170
     * @module Product
171
     * @module PriceProduct
172
     *
173
     * @param string $concreteProductSku
174
     * @param \Generated\Shared\Transfer\CurrencyTransfer $currencyTransfer
175
     * @param \Generated\Shared\Transfer\StoreTransfer $storeTransfer
176
     *
177
     * @return \Orm\Zed\PriceProduct\Persistence\SpyPriceProductQuery
178
     */
179
    public function getProductAbstractPriceQuery($concreteProductSku, CurrencyTransfer $currencyTransfer, StoreTransfer $storeTransfer)
180
    {
181
        $priceProductQuery = $this->getFactory()
182
            ->createPriceProductQuery();
183
184
        $priceProductQuery
185
            ->useSpyProductAbstractQuery()
186
                ->useSpyProductQuery()
187
                    ->filterBySku($concreteProductSku)
188
                ->endUse()
189
            ->endUse()
190
            ->usePriceProductStoreQuery()
191
                ->filterByFkCurrency($currencyTransfer->getIdCurrency())
192
                ->filterByFkStore($storeTransfer->getIdStore())
193
            ->endUse();
194
195
        $priceProductQuery->withColumn(SpyPriceProductStoreTableMap::COL_GROSS_PRICE, FactFinderSdkConstants::ITEM_PRICE);
196
197
        return $priceProductQuery;
198
    }
199
200
    /**
201
     * {@inheritDoc}
202
     *
203
     * @api
204
     *
205
     * @module Product
206
     * @module ProductAbstractDataFeed
207
     * @module ProductReview
208
     *
209
     * @param int $idProductAbstract
210
     * @param \Generated\Shared\Transfer\LocaleTransfer $localeTransfer
211
     *
212
     * @return \Orm\Zed\Product\Persistence\SpyProductAbstractQuery
213
     */
214
    public function getReviewsQuery($idProductAbstract, LocaleTransfer $localeTransfer)
215
    {
216
        $productAbstractDataFeedTransfer = new ProductAbstractDataFeedTransfer();
217
        $productAbstractDataFeedTransfer->setIdLocale($localeTransfer->getIdLocale());
218
219
        $query = $this->getFactory()
220
            ->getProductAbstractDataFeedQueryContainer()
221
            ->queryAbstractProductDataFeed($productAbstractDataFeedTransfer);
222
223
        $query
224
            ->leftJoinWithSpyProductReview()
225
            ->useSpyProductReviewQuery()
226
                ->filterByFkProductAbstract($idProductAbstract)
227
            ->endUse();
228
229
        return $query;
230
    }
231
232
    /**
233
     * @param \Orm\Zed\Product\Persistence\SpyProductAbstractQuery $productsAbstractQuery
234
     *
235
     * @return \Orm\Zed\Product\Persistence\SpyProductAbstractQuery
236
     */
237
    protected function addColumns(SpyProductAbstractQuery $productsAbstractQuery)
238
    {
239
        $productsAbstractQuery->select([
240
            SpyProductTableMap::COL_SKU,
241
            SpyProductLocalizedAttributesTableMap::COL_NAME,
242
            SpyStockProductTableMap::COL_QUANTITY,
243
            SpyProductImageTableMap::COL_EXTERNAL_URL_SMALL,
244
            SpyProductLocalizedAttributesTableMap::COL_DESCRIPTION,
245
            static::COLUMN_URL,
246
            SpyProductAbstractTableMap::COL_SKU,
247
            SpyProductTableMap::COL_ATTRIBUTES,
248
            SpyProductAbstractTableMap::COL_ATTRIBUTES,
249
        ]);
250
251
        $productsAbstractQuery->withColumn(SpyProductTableMap::COL_SKU, FactFinderSdkConstants::ITEM_PRODUCT_NUMBER);
252
        $productsAbstractQuery->withColumn(SpyProductLocalizedAttributesTableMap::COL_NAME, FactFinderSdkConstants::ITEM_NAME);
253
        $productsAbstractQuery->withColumn(SpyStockProductTableMap::COL_QUANTITY, FactFinderSdkConstants::ITEM_STOCK);
254
        $productsAbstractQuery->withColumn(SpyProductImageTableMap::COL_EXTERNAL_URL_SMALL, FactFinderSdkConstants::ITEM_IMAGE_URL);
255
        $productsAbstractQuery->withColumn(SpyProductLocalizedAttributesTableMap::COL_DESCRIPTION, FactFinderSdkConstants::ITEM_DESCRIPTION);
256
        $productsAbstractQuery->withColumn(static::COLUMN_URL, FactFinderSdkConstants::ITEM_PRODUCT_URL);
257
        $productsAbstractQuery->withColumn(SpyProductAbstractTableMap::COL_SKU, FactFinderSdkConstants::ITEM_MASTER_ID);
258
        $productsAbstractQuery->withColumn(SpyProductTableMap::COL_ATTRIBUTES, FactFinderSdkConstants::ITEM_CONCRETE_PRODUCT_ATTRIBUTES);
259
        $productsAbstractQuery->withColumn(SpyProductAbstractTableMap::COL_ATTRIBUTES, FactFinderSdkConstants::ITEM_ABSTRACT_PRODUCT_ATTRIBUTES);
260
        $productsAbstractQuery->withColumn(SpyProductAbstractTableMap::COL_ID_PRODUCT_ABSTRACT, FactFinderSdkConstants::ITEM_ID_ABSTRACT_PRODUCT);
261
        $productsAbstractQuery->withColumn(SpyProductTableMap::COL_CREATED_AT, FactFinderSdkConstants::ITEM_CREATED_AT);
262
        $productsAbstractQuery->withColumn(SpyProductAbstractTableMap::COL_NEW_FROM, FactFinderSdkConstants::ITEM_NEW_FROM);
263
        $productsAbstractQuery->withColumn(SpyProductAbstractTableMap::COL_NEW_TO, FactFinderSdkConstants::ITEM_NEW_TO);
264
265
        return $productsAbstractQuery;
266
    }
267
}
268