Skip to content

Commit 72949d9

Browse files
Andrewb89glogen
authored andcommitted
MAGETWO-70163: Add quote generaion ability for fixtures generation tool
- Implemented quote generator
1 parent edb0ea3 commit 72949d9

File tree

4 files changed

+1178
-0
lines changed

4 files changed

+1178
-0
lines changed
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Setup\Fixtures\Quote;
8+
9+
use Magento\Setup\Fixtures\FixtureModel;
10+
11+
/**
12+
* Configuration for generating quotes for orders.
13+
*/
14+
class QuoteConfiguration extends \Magento\Framework\DataObject
15+
{
16+
/**
17+
* Product type for "big" configurable products.
18+
*
19+
* @var string
20+
*/
21+
const BIG_CONFIGURABLE_TYPE = 'big_configurable';
22+
23+
/**
24+
* Default value for minimum items (simple) per order configuration.
25+
*
26+
* @var int
27+
*/
28+
const SIMPLE_PRODUCT_COUNT_FROM = 2;
29+
30+
/**
31+
* Default value for maximum items (simple) per order configuration.
32+
*
33+
* @var int
34+
*/
35+
const SIMPLE_PRODUCT_COUNT_TO = 2;
36+
37+
/**
38+
* Default value for minimum items (configurable) per order configuration.
39+
*
40+
* @var int
41+
*/
42+
const CONFIGURABLE_PRODUCT_COUNT_FROM = 0;
43+
44+
/**
45+
* Default value for maximum items (configurable) per order configuration.
46+
*
47+
* @var int
48+
*/
49+
const CONFIGURABLE_PRODUCT_COUNT_TO = 0;
50+
51+
/**
52+
* Default value for minimum items (big configurable) per order configuration.
53+
*
54+
* @var int
55+
*/
56+
const BIG_CONFIGURABLE_PRODUCT_COUNT_FROM = 0;
57+
58+
/**
59+
* Default value for maximum items (big configurable) per order configuration.
60+
*
61+
* @var int
62+
*/
63+
const BIG_CONFIGURABLE_PRODUCT_COUNT_TO = 0;
64+
65+
/**
66+
* Mappings for number of different types of products in quote.
67+
*
68+
* @var array
69+
*/
70+
protected $_globalMap = [
71+
'order_simple_product_count_to' => 'simple_count_to',
72+
'order_simple_product_count_from' => 'simple_count_from',
73+
'order_configurable_product_count_to' => 'configurable_count_to',
74+
'order_configurable_product_count_from' => 'configurable_count_from',
75+
'order_big_configurable_product_count_to' => 'big_configurable_count_to',
76+
'order_big_configurable_product_count_from' => 'big_configurable_count_from',
77+
'order_quotes_enable' => 'order_quotes_enable',
78+
];
79+
80+
/**
81+
* @var string
82+
*/
83+
protected $fixtureDataFilename = 'orders_fixture_data.json';
84+
85+
/**
86+
* @var FixtureModel
87+
*/
88+
private $fixtureModel;
89+
90+
/**
91+
* @param FixtureModel $fixtureModel
92+
*/
93+
public function __construct(FixtureModel $fixtureModel)
94+
{
95+
$this->fixtureModel = $fixtureModel;
96+
}
97+
98+
/**
99+
* Fills object with data.
100+
*
101+
* @return $this
102+
*/
103+
public function load()
104+
{
105+
$this->addData([
106+
'simple_count_to' => self::SIMPLE_PRODUCT_COUNT_TO,
107+
'simple_count_from' => self::SIMPLE_PRODUCT_COUNT_FROM,
108+
'configurable_count_to' => self::CONFIGURABLE_PRODUCT_COUNT_TO,
109+
'configurable_count_from' => self::CONFIGURABLE_PRODUCT_COUNT_FROM,
110+
'big_configurable_count_to' => self::BIG_CONFIGURABLE_PRODUCT_COUNT_TO,
111+
'big_configurable_count_from' => self::BIG_CONFIGURABLE_PRODUCT_COUNT_FROM,
112+
]);
113+
114+
$this->setData(
115+
'fixture_data_filename',
116+
dirname(__DIR__) . DIRECTORY_SEPARATOR . "_files" . DIRECTORY_SEPARATOR . $this->fixtureDataFilename
117+
);
118+
119+
\Magento\Framework\DataObject\Mapper::accumulateByMap(
120+
[$this->fixtureModel, 'getValue'],
121+
[$this, 'setNotEmptyData'],
122+
$this->_globalMap
123+
);
124+
return $this;
125+
}
126+
127+
/**
128+
* @param string|array $key
129+
* @param mixed $value
130+
* @return $this
131+
*/
132+
public function setNotEmptyData($key, $value)
133+
{
134+
if (null === $value) {
135+
return $this;
136+
}
137+
return $this->setData($key, $value);
138+
}
139+
}

0 commit comments

Comments
 (0)