Skip to content

Commit 9ed631d

Browse files
author
Joan He
authored
Merge pull request #450 from magento-mustang/MAGETWO-56350
[Mustangs] Measure Search
2 parents 2f9032b + 24c8cf1 commit 9ed631d

22 files changed

+8759
-162
lines changed
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<attribute_sets> <!-- Content of Attribute Sets -->
9+
<attribute_set>
10+
<name>Attribute Set 1</name>
11+
<attributes>
12+
<attribute>
13+
<is_required>1</is_required>
14+
<is_visible_on_front>1</is_visible_on_front>
15+
<is_visible_in_advanced_search>1</is_visible_in_advanced_search>
16+
<attribute_code>mycolor</attribute_code>
17+
<backend_type></backend_type>
18+
<is_searchable>1</is_searchable>
19+
<is_filterable>1</is_filterable>
20+
<is_filterable_in_search>1</is_filterable_in_search>
21+
<frontend_label>my color</frontend_label>
22+
<frontend_input>select</frontend_input>
23+
<default_value>my yellow</default_value>
24+
<options>
25+
<option>
26+
<label>my green</label>
27+
<value>my green</value>
28+
</option>
29+
<option>
30+
<label>my red</label>
31+
<value>my red</value>
32+
</option>
33+
<option>
34+
<label>my yellow</label>
35+
<value>my yellow</value>
36+
</option>
37+
</options>
38+
</attribute>
39+
<attribute>
40+
<is_required>1</is_required>
41+
<is_visible_on_front>1</is_visible_on_front>
42+
<is_visible_in_advanced_search>1</is_visible_in_advanced_search>
43+
<attribute_code>mysize</attribute_code>
44+
<backend_type></backend_type>
45+
<is_searchable>1</is_searchable>
46+
<is_filterable>1</is_filterable>
47+
<is_filterable_in_search>1</is_filterable_in_search>
48+
<frontend_label>my size</frontend_label>
49+
<frontend_input>select</frontend_input>
50+
<default_value>my large</default_value>
51+
<options>
52+
<option>
53+
<label>my small</label>
54+
<value>my small</value>
55+
</option>
56+
<option>
57+
<label>my medium</label>
58+
<value>my medium</value>
59+
</option>
60+
<option>
61+
<label>my large</label>
62+
<value>my large</value>
63+
</option>
64+
</options>
65+
</attribute>
66+
</attributes>
67+
</attribute_set>
68+
<attribute_set>
69+
<name>Attribute Set 2</name>
70+
<attributes>
71+
<attribute>
72+
<is_required>1</is_required>
73+
<is_visible_on_front>1</is_visible_on_front>
74+
<is_visible_in_advanced_search>1</is_visible_in_advanced_search>
75+
<attribute_code>attributeset2attribute1</attribute_code>
76+
<backend_type></backend_type>
77+
<is_searchable>1</is_searchable>
78+
<is_filterable>1</is_filterable>
79+
<is_filterable_in_search>1</is_filterable_in_search>
80+
<frontend_label>Attribute Set 2 - Attribute 1</frontend_label>
81+
<frontend_input>select</frontend_input>
82+
<default_value>attributeset2attribute1option1</default_value>
83+
<options>
84+
<option>
85+
<label>Attribute Set 2 - Attribute 1 - Option a</label>
86+
<value>attributeset2attribute1option1</value>
87+
</option>
88+
<option>
89+
<label>Attribute Set 2 - Attribute 1 - Option b</label>
90+
<value>attributeset2attribute1option2</value>
91+
</option>
92+
<option>
93+
<label>Attribute Set 2 - Attribute 1 - Option c</label>
94+
<value>attributeset2attribute1option3</value>
95+
</option>
96+
</options>
97+
</attribute>
98+
</attributes>
99+
</attribute_set>
100+
<attribute_set>
101+
<name>Attribute Set 3</name>
102+
<attributes>
103+
<attribute>
104+
<is_required>1</is_required>
105+
<is_visible_on_front>1</is_visible_on_front>
106+
<is_visible_in_advanced_search>1</is_visible_in_advanced_search>
107+
<attribute_code>attributeset3attribute1</attribute_code>
108+
<backend_type></backend_type>
109+
<is_searchable>1</is_searchable>
110+
<is_filterable>1</is_filterable>
111+
<is_filterable_in_search>1</is_filterable_in_search>
112+
<frontend_label>Attribute Set 3 - Attribute 1</frontend_label>
113+
<frontend_input>select</frontend_input>
114+
<default_value>attributeset3attribute1option1</default_value>
115+
<options>
116+
<option>
117+
<label>Attribute Set 3 - Attribute 1 - Option a</label>
118+
<value>attributeset3attribute1option1</value>
119+
</option>
120+
<option>
121+
<label>Attribute Set 3 - Attribute 1 - Option b</label>
122+
<value>attributeset3attribute1option2</value>
123+
</option>
124+
<option>
125+
<label>Attribute Set 3 - Attribute 1 - Option c</label>
126+
<value>attributeset3attribute1option3</value>
127+
</option>
128+
</options>
129+
</attribute>
130+
</attributes>
131+
</attribute_set>
132+
</attribute_sets>

setup/performance-toolkit/profiles/ce/extra_large.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<config>
8+
<config xmlns:xi="http://www.w3.org/2001/XInclude">
99
<profile>
1010
<websites>5</websites> <!-- Number of websites to generate -->
1111
<store_groups>5</store_groups> <!--Number of stores-->
@@ -68,5 +68,8 @@
6868
<set_scheduled>true</set_scheduled>
6969
</indexer>
7070
</indexers>
71+
<xi:include href="searchTerms.xml" />
72+
<xi:include href="searchConfig.xml" />
73+
<xi:include href="attributeSets.xml" />
7174
</profile>
7275
</config>

setup/performance-toolkit/profiles/ce/large.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<config>
8+
<config xmlns:xi="http://www.w3.org/2001/XInclude">
99
<profile>
1010
<websites>3</websites> <!-- Number of websites to generate -->
1111
<store_groups>3</store_groups> <!--Number of stores-->
@@ -68,5 +68,8 @@
6868
<set_scheduled>true</set_scheduled>
6969
</indexer>
7070
</indexers>
71+
<xi:include href="searchTerms.xml" />
72+
<xi:include href="searchConfig.xml" />
73+
<xi:include href="attributeSets.xml" />
7174
</profile>
7275
</config>

setup/performance-toolkit/profiles/ce/medium.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<config>
8+
<config xmlns:xi="http://www.w3.org/2001/XInclude">
99
<profile>
1010
<websites>1</websites> <!-- Number of websites to generate -->
1111
<store_groups>2</store_groups> <!--Number of stores-->
@@ -68,5 +68,8 @@
6868
<set_scheduled>false</set_scheduled>
6969
</indexer>
7070
</indexers>
71+
<xi:include href="searchTerms.xml" />
72+
<xi:include href="searchConfig.xml" />
73+
<xi:include href="attributeSets.xml" />
7174
</profile>
7275
</config>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<search_config> <!-- Search configuration for Simple/Configurable products -->
9+
<max_amount_of_words_description>200</max_amount_of_words_description>
10+
<max_amount_of_words_short_description>20</max_amount_of_words_short_description>
11+
<min_amount_of_words_description>20</min_amount_of_words_description>
12+
<min_amount_of_words_short_description>5</min_amount_of_words_short_description>
13+
</search_config>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<search_terms> <!-- Content of Search Terms -->
9+
<search_term>
10+
<term>iphone 6</term>
11+
<count>50</count>
12+
</search_term>
13+
<search_term>
14+
<term>galaxy s3</term>
15+
<count>100</count>
16+
</search_term>
17+
</search_terms>

setup/performance-toolkit/profiles/ce/small.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<config>
8+
<config xmlns:xi="http://www.w3.org/2001/XInclude">
99
<profile>
1010
<websites>1</websites> <!-- Number of websites to generate -->
1111
<store_groups>1</store_groups> <!--Number of stores-->
@@ -68,5 +68,8 @@
6868
<set_scheduled>false</set_scheduled>
6969
</indexer>
7070
</indexers>
71+
<xi:include href="searchTerms.xml" />
72+
<xi:include href="searchConfig.xml" />
73+
<xi:include href="attributeSets.xml" />
7174
</profile>
7275
</config>

setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
7878
$output->writeln('<info>Generating profile with following params:</info>');
7979

8080
foreach ($fixtureModel->getParamLabels() as $configKey => $label) {
81-
$output->writeln('<info> |- ' . $label . ': ' . $fixtureModel->getValue($configKey) . '</info>');
81+
$output->writeln(
82+
'<info> |- ' . $label . ': ' . (is_array($fixtureModel->getValue($configKey)) === true
83+
? sizeof(
84+
$fixtureModel->getValue($configKey)[array_keys($fixtureModel->getValue($configKey))[0]]
85+
) : $fixtureModel->getValue($configKey)) . '</info>'
86+
);
8287
}
8388

8489
/** @var $config \Magento\Indexer\Model\Config */
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Setup\Fixtures;
8+
9+
/**
10+
* Class AttributeSetFixture
11+
*/
12+
class AttributeSetsFixture extends Fixture
13+
{
14+
/**
15+
* @var int
16+
*/
17+
protected $priority = 25;
18+
19+
/**
20+
* {@inheritdoc}
21+
*/
22+
public function execute()
23+
{
24+
$attributeSets = $this->fixtureModel->getValue('attribute_sets', null);
25+
if ($attributeSets === null) {
26+
return;
27+
}
28+
$this->fixtureModel->resetObjectManager();
29+
/** @var \Magento\Catalog\Api\AttributeSetManagementInterface $attributeSetManagement */
30+
$attributeSetManagement = $this->fixtureModel->getObjectManager()->create(
31+
\Magento\Catalog\Api\AttributeSetManagementInterface::class
32+
);
33+
/** @var \Magento\Catalog\Api\ProductAttributeGroupRepositoryInterface $attributeGroupRepository */
34+
$attributeGroupRepository = $this->fixtureModel->getObjectManager()->create(
35+
\Magento\Catalog\Api\ProductAttributeGroupRepositoryInterface::class
36+
);
37+
38+
foreach ($attributeSets['attribute_set'] as $attributeSetData) {
39+
//Create Attribute Set
40+
/** @var \Magento\Eav\Api\Data\AttributeSetInterfaceFactory $attributeSetFactory */
41+
$attributeSetFactory = $this->fixtureModel->getObjectManager()->create(
42+
\Magento\Eav\Api\Data\AttributeSetInterfaceFactory::class
43+
);
44+
$attributeSet = $attributeSetFactory->create();
45+
$attributeSet->setAttributeSetName($attributeSetData['name']);
46+
$attributeSet->setEntityTypeId(\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE);
47+
48+
$result = $attributeSetManagement->create($attributeSet, 4);
49+
$attributeSetId = $result->getAttributeSetId();
50+
51+
//Create Attribute Group
52+
/** @var \Magento\Eav\Api\Data\AttributeGroupInterfaceFactory $attributeGroupFactory */
53+
$attributeGroupFactory = $this->fixtureModel->getObjectManager()->create(
54+
\Magento\Eav\Api\Data\AttributeGroupInterfaceFactory::class
55+
);
56+
$attributeGroup = $attributeGroupFactory->create();
57+
$attributeGroup->setAttributeGroupName($result->getAttributeSetName() . ' - Group');
58+
$attributeGroup->setAttributeSetId($attributeSetId);
59+
$attributeGroupRepository->save($attributeGroup);
60+
$attributeGroupId = $attributeGroup->getAttributeGroupId();
61+
62+
/** @var \Magento\Catalog\Api\ProductAttributeRepositoryInterface $attributeRepository */
63+
$attributeRepository = $this->fixtureModel->getObjectManager()->create(
64+
\Magento\Catalog\Api\ProductAttributeRepositoryInterface::class
65+
);
66+
/** @var \Magento\Catalog\Api\ProductAttributeManagementInterface $attributeManagementManagement */
67+
$attributeManagement = $this->fixtureModel->getObjectManager()->create(
68+
\Magento\Catalog\Api\ProductAttributeManagementInterface::class
69+
);
70+
71+
$attributesData = array_key_exists(0, $attributeSetData['attributes']['attribute'])
72+
? $attributeSetData['attributes']['attribute'] : [$attributeSetData['attributes']['attribute']];
73+
foreach ($attributesData as $attributeData) {
74+
//Create Attribute
75+
/** @var \Magento\Catalog\Api\Data\ProductAttributeInterfaceFactory $attributeFactory */
76+
$attributeFactory = $this->fixtureModel->getObjectManager()->create(
77+
\Magento\Catalog\Api\Data\ProductAttributeInterfaceFactory::class
78+
);
79+
80+
$optionsData = array_key_exists(0, $attributeData['options']['option'])
81+
? $attributeData['options']['option'] : [$attributeData['options']['option']];
82+
$options = [];
83+
foreach ($optionsData as $optionData) {
84+
/** @var \Magento\Eav\Api\Data\AttributeOptionInterfaceFactory $optionFactory */
85+
$optionFactory = $this->fixtureModel->getObjectManager()->create(
86+
\Magento\Eav\Api\Data\AttributeOptionInterfaceFactory::class
87+
);
88+
$option = $optionFactory->create(['data' => $optionData]);
89+
$options[] = $option;
90+
}
91+
92+
$attribute = $attributeFactory->create(['data' => $attributeData]);
93+
$attribute->setOptions($options);
94+
95+
$result = $attributeRepository->save($attribute);
96+
$attributeId = $result->getAttributeId();
97+
98+
//Associate Attribute to Attribute Set
99+
$sortOrder = 3;
100+
$attributeManagement->assign($attributeSetId, $attributeGroupId, $attributeId, $sortOrder);
101+
}
102+
}
103+
}
104+
105+
/**
106+
* {@inheritdoc}
107+
*/
108+
public function getActionTitle()
109+
{
110+
return 'Generating attribute sets';
111+
}
112+
113+
/**
114+
* {@inheritdoc}
115+
*/
116+
public function introduceParamLabels()
117+
{
118+
return [
119+
'attribute_sets' => 'Attribute Sets'
120+
];
121+
}
122+
}

0 commit comments

Comments
 (0)