Skip to content

Commit e2dbf63

Browse files
author
Egor Shitikov
committed
MAGETWO-34014: Create fixture or script for changing Magento FPC ttl
1 parent b32bd91 commit e2dbf63

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
/**
8+
* Class DisableFormKeyUsageFixture
9+
*/
10+
class ConfigsApplyFixture extends \Magento\ToolkitFramework\Fixture
11+
{
12+
/**
13+
* @var int
14+
*/
15+
protected $priority = 100;
16+
17+
/**
18+
* {@inheritdoc}
19+
*/
20+
public function execute()
21+
{
22+
$configs = \Magento\ToolkitFramework\Config::getInstance()->getValue('configs', array());
23+
24+
$this->application->resetObjectManager();
25+
/**
26+
* @var \Magento\Framework\App\Config\Value $configData
27+
*/
28+
$configData = $this->application->getObjectManager()->create('Magento\Framework\App\Config\Value');
29+
30+
foreach ($configs as $config) {
31+
try {
32+
$configData->setPath($config['path'])
33+
->setScope($config['scope'])
34+
->setScopeId($config['scopeId'])
35+
->setValue($config['value'])
36+
->save();
37+
} catch (\Exception $e) {
38+
if (strpos($e->getMessage(), '1062 Duplicate entry')) {
39+
echo 'Config value the same' . PHP_EOL;
40+
} else {
41+
throw new Exception('Error update config');
42+
}
43+
}
44+
}
45+
$this->application->getObjectManager()->get('Magento\Framework\App\CacheInterface')
46+
->clean([\Magento\Framework\App\Config::CACHE_TAG]);
47+
}
48+
49+
/**
50+
* {@inheritdoc}
51+
*/
52+
public function getActionTitle()
53+
{
54+
return 'Config Changes';
55+
}
56+
57+
/**
58+
* {@inheritdoc}
59+
*/
60+
public function introduceParamLabels()
61+
{
62+
return [];
63+
}
64+
}
65+
66+
return new ConfigsApplyFixture($this);

dev/tools/performance-toolkit/profiles/ce/small.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,19 @@
1818
<cart_price_rules>10</cart_price_rules> <!-- Number of shopping cart price rules -->
1919
<cart_price_rules_floor>2</cart_price_rules_floor> <!-- The price rule condition: minimum products amount in shopping cart for price rule to be applied -->
2020
<customers>20</customers> <!-- Number of customers to generate -->
21+
<configs> <!-- Config variables and values for change -->
22+
<config>
23+
<path>admin/security/use_form_key</path>
24+
<scope>default</scope>
25+
<scopeId>0</scopeId>
26+
<value>1</value>
27+
</config>
28+
<config>
29+
<path>carriers/flatrate/active</path>
30+
<scope>default2</scope>
31+
<scopeId>0</scopeId>
32+
<value>1</value>
33+
</config>
34+
</configs>
2135
</profile>
2236
</config>

0 commit comments

Comments
 (0)