1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* WellCommerce Open-Source E-Commerce Platform |
4
|
|
|
* |
5
|
|
|
* This file is part of the WellCommerce package. |
6
|
|
|
* |
7
|
|
|
* (c) Adam Piotrowski <[email protected]> |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, |
10
|
|
|
* please view the LICENSE file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace WellCommerce\Bundle\CatalogBundle\Controller\Box; |
14
|
|
|
|
15
|
|
|
use Symfony\Component\HttpFoundation\Response; |
16
|
|
|
use WellCommerce\Bundle\CoreBundle\Controller\Box\AbstractBoxController; |
17
|
|
|
use WellCommerce\Component\Layout\Collection\LayoutBoxSettingsCollection; |
18
|
|
|
use WellCommerce\Component\DataSet\Conditions\Condition\Eq; |
19
|
|
|
use WellCommerce\Component\DataSet\Conditions\ConditionsCollection; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Class ProducerCollectionProductsBoxController |
23
|
|
|
* |
24
|
|
|
* @author Rafał Martonik <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
class ProducerCollectionProductsBoxController extends AbstractBoxController |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* {@inheritdoc} |
30
|
|
|
*/ |
31
|
|
|
public function indexAction(LayoutBoxSettingsCollection $boxSettings) : Response |
32
|
|
|
{ |
33
|
|
|
$dataset = $this->get('product.dataset.front'); |
34
|
|
|
$requestHelper = $this->getRequestHelper(); |
35
|
|
|
$limit = $requestHelper->getAttributesBagParam('limit', $boxSettings->getParam('per_page', 12)); |
36
|
|
|
$conditions = $this->getCurrentProducerConditions(); |
37
|
|
|
$conditions = $this->get('layered_navigation.helper')->addLayeredNavigationConditions($conditions); |
38
|
|
|
|
39
|
|
|
$products = $dataset->getResult('array', [ |
40
|
|
|
'limit' => $limit, |
41
|
|
|
'page' => $requestHelper->getAttributesBagParam('page', 1), |
42
|
|
|
'order_by' => $requestHelper->getAttributesBagParam('orderBy', 'hierarchy'), |
43
|
|
|
'order_dir' => $requestHelper->getAttributesBagParam('orderDir', 'asc'), |
44
|
|
|
'conditions' => $conditions, |
45
|
|
|
]); |
46
|
|
|
|
47
|
|
|
return $this->displayTemplate('index', [ |
48
|
|
|
'dataset' => $products, |
49
|
|
|
]); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return ConditionsCollection |
54
|
|
|
*/ |
55
|
|
|
protected function getCurrentProducerConditions() : ConditionsCollection |
56
|
|
|
{ |
57
|
|
|
$conditions = new ConditionsCollection(); |
58
|
|
|
$conditions->add(new Eq('producerCollectionId', $this->getProducerCollectionStorage()->getCurrentProducerCollectionIdentifier())); |
59
|
|
|
|
60
|
|
|
return $conditions; |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|