ltsecurityinc安防产品在线商城代码
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Framework\Search\Request\Config;
|
||||
|
||||
class ConverterTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/** @var Converter */
|
||||
protected $object;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->object = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->create(\Magento\Framework\Search\Request\Config\Converter::class);
|
||||
}
|
||||
|
||||
public function testConvert()
|
||||
{
|
||||
$document = new \DOMDocument();
|
||||
$document->load(__DIR__ . '../../../_files/search_request.xml');
|
||||
$result = $this->object->convert($document);
|
||||
$expected = include __DIR__ . '/../../_files/search_request_config.php';
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Application config file resolver
|
||||
*
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Framework\Search\Request\Config;
|
||||
|
||||
class FileResolverStub implements \Magento\Framework\Config\FileResolverInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($filename, $scope)
|
||||
{
|
||||
$path = realpath(__DIR__ . '/../../_files/etc');
|
||||
$paths = [$path . '/search_request_1.xml', $path . '/search_request_2.xml'];
|
||||
return new \Magento\Framework\Config\FileIterator(
|
||||
new \Magento\Framework\Filesystem\File\ReadFactory(new \Magento\Framework\Filesystem\DriverPool),
|
||||
$paths
|
||||
);
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Framework\Search\Request\Config;
|
||||
|
||||
class FileSystemReaderTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/** @var FilesystemReader */
|
||||
protected $object;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$fileResolver = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Framework\Search\Request\Config\FileResolverStub::class
|
||||
);
|
||||
$this->object = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Framework\Search\Request\Config\FilesystemReader::class,
|
||||
['fileResolver' => $fileResolver]
|
||||
);
|
||||
}
|
||||
|
||||
public function testRead()
|
||||
{
|
||||
$result = $this->object->read();
|
||||
// Filter values added by \Magento\CatalogSearch\Model\Search\ReaderPlugin
|
||||
$result = array_intersect_key($result, array_flip(['bool_query', 'filter_query', 'new_match_query']));
|
||||
$expected = include __DIR__ . '/../../_files/search_request_merged.php';
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Framework\Search\Request;
|
||||
|
||||
use Magento\Framework\Search\Request\Aggregation\DynamicBucket;
|
||||
use Magento\Framework\Search\Request\BucketInterface;
|
||||
|
||||
class MapperTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Framework\Search\Request\Mapper
|
||||
*/
|
||||
protected $mapper;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$config = include __DIR__ . '/../_files/search_request_config.php';
|
||||
$request = reset($config);
|
||||
/** @var \Magento\Framework\Search\Request\Mapper $mapper */
|
||||
$this->mapper = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->create(
|
||||
\Magento\Framework\Search\Request\Mapper::class,
|
||||
[
|
||||
'queries' => $request['queries'],
|
||||
'rootQueryName' => 'suggested_search_container',
|
||||
'filters' => $request['filters'],
|
||||
'aggregations' => $request['aggregations'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$this->assertInstanceOf(
|
||||
\Magento\Framework\Search\Request\QueryInterface::class,
|
||||
$this->mapper->getRootQuery()
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetBuckets(): void
|
||||
{
|
||||
$buckets = $this->mapper->getBuckets();
|
||||
$this->assertCount(3, $buckets);
|
||||
|
||||
$this->assertInstanceOf(\Magento\Framework\Search\Request\Aggregation\TermBucket::class, $buckets[0]);
|
||||
$this->assertEquals('category_bucket', $buckets[0]->getName());
|
||||
$this->assertEquals('category', $buckets[0]->getField());
|
||||
$this->assertEquals(BucketInterface::TYPE_TERM, $buckets[0]->getType());
|
||||
$metrics = $buckets[0]->getMetrics();
|
||||
$this->assertInstanceOf(\Magento\Framework\Search\Request\Aggregation\Metric::class, $metrics[0]);
|
||||
|
||||
$this->assertInstanceOf(\Magento\Framework\Search\Request\Aggregation\RangeBucket::class, $buckets[1]);
|
||||
$this->assertEquals('price_bucket', $buckets[1]->getName());
|
||||
$this->assertEquals('price', $buckets[1]->getField());
|
||||
$this->assertEquals(BucketInterface::TYPE_RANGE, $buckets[1]->getType());
|
||||
$metrics = $buckets[1]->getMetrics();
|
||||
$ranges = $buckets[1]->getRanges();
|
||||
$this->assertInstanceOf(\Magento\Framework\Search\Request\Aggregation\Metric::class, $metrics[0]);
|
||||
$this->assertInstanceOf(\Magento\Framework\Search\Request\Aggregation\Range::class, $ranges[0]);
|
||||
|
||||
$this->assertInstanceOf(DynamicBucket::class, $buckets[2]);
|
||||
$this->assertEquals('dynamic_bucket', $buckets[2]->getName());
|
||||
$this->assertEquals('price', $buckets[2]->getField());
|
||||
$this->assertEquals(BucketInterface::TYPE_DYNAMIC, $buckets[2]->getType());
|
||||
$this->assertSame('auto', $buckets[2]->getMethod());
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\Eav\Api\AttributeRepositoryInterface;
|
||||
|
||||
$eavConfig = Bootstrap::getObjectManager()->get(\Magento\Eav\Model\Config::class);
|
||||
$attribute = $eavConfig->getAttribute('catalog_product', 'test_configurable');
|
||||
|
||||
$eavConfig->clear();
|
||||
|
||||
/** @var $installer \Magento\Catalog\Setup\CategorySetup */
|
||||
$installer = Bootstrap::getObjectManager()->create(\Magento\Catalog\Setup\CategorySetup::class);
|
||||
|
||||
if (!$attribute->getId()) {
|
||||
|
||||
/** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */
|
||||
$attribute = Bootstrap::getObjectManager()->create(
|
||||
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
|
||||
);
|
||||
|
||||
/** @var AttributeRepositoryInterface $attributeRepository */
|
||||
$attributeRepository = Bootstrap::getObjectManager()->create(AttributeRepositoryInterface::class);
|
||||
|
||||
$attribute->setData(
|
||||
[
|
||||
'attribute_code' => 'test_configurable',
|
||||
'entity_type_id' => $installer->getEntityTypeId('catalog_product'),
|
||||
'is_global' => 1,
|
||||
'is_user_defined' => 1,
|
||||
'frontend_input' => 'select',
|
||||
'is_unique' => 0,
|
||||
'is_required' => 0,
|
||||
'is_searchable' => 1,
|
||||
'is_visible_in_advanced_search' => 1,
|
||||
'is_comparable' => 0,
|
||||
'is_filterable' => 1,
|
||||
'is_filterable_in_search' => 1,
|
||||
'is_used_for_promo_rules' => 0,
|
||||
'is_html_allowed_on_front' => 1,
|
||||
'is_visible_on_front' => 0,
|
||||
'used_in_product_listing' => 0,
|
||||
'used_for_sort_by' => 0,
|
||||
'frontend_label' => ['Test Configurable'],
|
||||
'backend_type' => 'int',
|
||||
'option' => [
|
||||
'value' => ['option_0' => ['Option 1'], 'option_1' => ['Option 2']],
|
||||
'order' => ['option_0' => 1, 'option_1' => 2],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$attributeRepository->save($attribute);
|
||||
}
|
||||
|
||||
/* Assign attribute to attribute set */
|
||||
$installer->addAttributeToGroup('catalog_product', 'Default', 'General', $attribute->getId());
|
||||
$eavConfig->clear();
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
/** @var \Magento\Framework\Registry $registry */
|
||||
$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class);
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', true);
|
||||
$productCollection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->get(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
|
||||
foreach ($productCollection as $product) {
|
||||
$product->delete();
|
||||
}
|
||||
|
||||
$eavConfig = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Eav\Model\Config::class);
|
||||
$attribute = $eavConfig->getAttribute('catalog_product', 'test_configurable');
|
||||
if ($attribute instanceof \Magento\Eav\Model\Entity\Attribute\AbstractAttribute
|
||||
&& $attribute->getId()
|
||||
) {
|
||||
$attribute->delete();
|
||||
}
|
||||
$eavConfig->clear();
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', false);
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
/* Create attribute */
|
||||
|
||||
/** @var \Magento\Framework\ObjectManagerInterface $objectManager */
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
|
||||
/** @var $installer \Magento\Catalog\Setup\CategorySetup */
|
||||
$installer = $objectManager->create(
|
||||
\Magento\Catalog\Setup\CategorySetup::class,
|
||||
['resourceName' => 'catalog_setup']
|
||||
);
|
||||
|
||||
/** @var $selectAttribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */
|
||||
$dateAttribute = $objectManager->create(
|
||||
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
|
||||
);
|
||||
$dateAttribute->setData(
|
||||
[
|
||||
'attribute_code' => 'date_attribute',
|
||||
'entity_type_id' => $installer->getEntityTypeId('catalog_product'),
|
||||
'is_global' => 1,
|
||||
'is_filterable' => 1,
|
||||
'is_user_defined' => 1,
|
||||
'backend_type' => 'datetime',
|
||||
'frontend_input' => 'date',
|
||||
'frontend_label' => 'Test Date',
|
||||
]
|
||||
);
|
||||
$dateAttribute->save();
|
||||
/* Assign attribute to attribute set */
|
||||
$installer->addAttributeToGroup('catalog_product', 'Default', 'General', $dateAttribute->getId());
|
||||
|
||||
/** @var $product \Magento\Catalog\Model\Product */
|
||||
$product = $objectManager->create(\Magento\Catalog\Model\Product::class);
|
||||
$product
|
||||
->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
|
||||
->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default'))
|
||||
->setWebsiteIds([1])
|
||||
->setName('Simple Product with date attribute')
|
||||
->setSku('simple_product_with_date_attribute')
|
||||
->setPrice(1)
|
||||
->setCategoryIds([2])
|
||||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
|
||||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
|
||||
->setStockData(['use_config_manage_stock' => 1, 'qty' => 5, 'is_in_stock' => 1])
|
||||
->save();
|
||||
|
||||
$objectManager->get(\Magento\Catalog\Model\Product\Action::class)
|
||||
->updateAttributes(
|
||||
[$product->getId()],
|
||||
[
|
||||
$dateAttribute->getAttributeCode() => '01/01/2000' // m/d/Y
|
||||
],
|
||||
$product->getStoreId()
|
||||
);
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
/* Create attribute */
|
||||
/** @var $installer \Magento\Catalog\Setup\CategorySetup */
|
||||
$installer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Catalog\Setup\CategorySetup::class,
|
||||
['resourceName' => 'catalog_setup']
|
||||
);
|
||||
$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class);
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', true);
|
||||
|
||||
/** @var $product \Magento\Catalog\Model\Product */
|
||||
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class);
|
||||
$product = $product->loadByAttribute('sku', 'simple_product_with_date_attribute');
|
||||
if ($product->getId()) {
|
||||
$product->delete();
|
||||
}
|
||||
|
||||
/** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */
|
||||
$attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
|
||||
);
|
||||
$attribute->loadByCode($installer->getEntityTypeId('catalog_product'), 'date_attribute');
|
||||
if ($attribute->getId()) {
|
||||
$attribute->delete();
|
||||
}
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', false);
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<requests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:Search/etc/search_request.xsd">
|
||||
<request query="bool_query" index="bool_query_index">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="boolQuery" name="bool_query" boost="1">
|
||||
<queryReference clause="must" ref="must_query"/>
|
||||
<queryReference clause="should" ref="should_query"/>
|
||||
<queryReference clause="not" ref="not_query"/>
|
||||
</query>
|
||||
<query xsi:type="matchQuery" value="$match_term$" name="match_query">
|
||||
<match field="match_field"/>
|
||||
<match field="*"/>
|
||||
</query>
|
||||
<query xsi:type="filteredQuery" name="must_query">
|
||||
<filterReference clause="must" ref="must_filter"/>
|
||||
</query>
|
||||
<query xsi:type="filteredQuery" name="should_query">
|
||||
<filterReference clause="should" ref="should_filter"/>
|
||||
</query>
|
||||
<query xsi:type="filteredQuery" name="not_query">
|
||||
<filterReference clause="not" ref="not_filter"/>
|
||||
</query>
|
||||
</queries>
|
||||
<filters>
|
||||
<filter xsi:type="termFilter" name="must_filter" field="field_1" value="$value_1$"/>
|
||||
<filter xsi:type="rangeFilter" name="should_filter" field="field_2" from="$value_2.from$"
|
||||
to="$value_2.to$"/>
|
||||
<filter xsi:type="wildcardFilter" name="not_filter" field="field_3" value="$field_3$"/>
|
||||
</filters>
|
||||
<aggregations>
|
||||
<bucket name="bucket_1" field="field_1" xsi:type="dynamicBucket" method="$field_1_dynamic_algorithm$">
|
||||
<metrics>
|
||||
<metric type="count"/>
|
||||
</metrics>
|
||||
</bucket>
|
||||
<bucket name="bucket_2" field="field_2" xsi:type="termBucket">
|
||||
<metrics>
|
||||
<metric type="count"/>
|
||||
</metrics>
|
||||
</bucket>
|
||||
<bucket name="bucket_3" field="field_2" xsi:type="rangeBucket">
|
||||
<ranges>
|
||||
<range from="$value_2.from$" to="value_2.to$"/>
|
||||
</ranges>
|
||||
</bucket>
|
||||
</aggregations>
|
||||
<from>0</from>
|
||||
<size>10000</size>
|
||||
</request>
|
||||
<request query="filter_query" index="filter_query_index">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="filteredQuery" name="filter_query">
|
||||
<filterReference clause="must" ref="bool_filter"/>
|
||||
</query>
|
||||
</queries>
|
||||
<filters>
|
||||
<filter xsi:type="boolFilter" name="bool_filter">
|
||||
<filterReference clause="must" ref="must_filter"/>
|
||||
<filterReference clause="should" ref="should_filter"/>
|
||||
<filterReference clause="not" ref="not_filter"/>
|
||||
</filter>
|
||||
<filter xsi:type="termFilter" name="must_filter" field="field_1" value="$value_1$"/>
|
||||
<filter xsi:type="rangeFilter" name="should_filter" field="field_2" from="$value_2.from$"
|
||||
to="$value_2.to$"/>
|
||||
<filter xsi:type="wildcardFilter" name="not_filter" field="field_3" value="$field_3$"/>
|
||||
</filters>
|
||||
<from>0</from>
|
||||
<size>10000</size>
|
||||
</request>
|
||||
</requests>
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<requests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:Search/etc/search_request.xsd">
|
||||
<request query="bool_query" index="bool_query_index_override">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default_override"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="boolQuery" name="bool_query" boost="10">
|
||||
<queryReference clause="must" ref="must_query"/>
|
||||
<queryReference clause="should" ref="should_query"/>
|
||||
<queryReference clause="not" ref="not_query"/>
|
||||
</query>
|
||||
<query xsi:type="matchQuery" value="$match_term_override$" name="match_query">
|
||||
<!--Add one more field to match query-->
|
||||
<match field="match_field_3"/>
|
||||
</query>
|
||||
<query xsi:type="matchQuery" value="$match_term_override$" name="match_query_2">
|
||||
<match field="match_field_4"/>
|
||||
</query>
|
||||
<query xsi:type="filteredQuery" name="must_query">
|
||||
<filterReference clause="must" ref="must_filter"/>
|
||||
</query>
|
||||
<query xsi:type="filteredQuery" name="should_query">
|
||||
<filterReference clause="should" ref="should_filter"/>
|
||||
</query>
|
||||
<query xsi:type="filteredQuery" name="not_query">
|
||||
<filterReference clause="not" ref="not_filter"/>
|
||||
</query>
|
||||
</queries>
|
||||
<filters>
|
||||
<filter xsi:type="termFilter" name="must_filter" field="field_1_override" value="$value_1_override$"/>
|
||||
<filter xsi:type="rangeFilter" name="should_filter" field="field_2_override" from="$value_2_override.from$"
|
||||
to="$value_2_override.to$"/>
|
||||
<filter xsi:type="wildcardFilter" name="not_filter" field="field_3_override" value="$field_3_override$"/>
|
||||
</filters>
|
||||
<aggregations>
|
||||
<bucket name="bucket_1" field="field_1_override" xsi:type="dynamicBucket" method="$field_1_dynamic_algorithm_override$">
|
||||
<metrics>
|
||||
<metric type="count"/>
|
||||
</metrics>
|
||||
</bucket>
|
||||
<bucket name="bucket_2" field="field_2_override" xsi:type="termBucket">
|
||||
<metrics>
|
||||
<metric type="count"/>
|
||||
</metrics>
|
||||
</bucket>
|
||||
<bucket name="bucket_3" field="field_2_override" xsi:type="rangeBucket">
|
||||
<ranges>
|
||||
<range from="$value_2_override.from$" to="value_2_override.to$"/>
|
||||
</ranges>
|
||||
</bucket>
|
||||
</aggregations>
|
||||
<from>0</from>
|
||||
<size>10000</size>
|
||||
</request>
|
||||
<request query="filter_query" index="filter_query_index_override">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default_override"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="filteredQuery" name="filter_query">
|
||||
<filterReference clause="must" ref="bool_filter"/>
|
||||
</query>
|
||||
</queries>
|
||||
<filters>
|
||||
<filter xsi:type="boolFilter" name="bool_filter">
|
||||
<filterReference clause="must" ref="must_filter"/>
|
||||
<filterReference clause="should" ref="should_filter"/>
|
||||
<filterReference clause="not" ref="not_filter"/>
|
||||
</filter>
|
||||
<filter xsi:type="termFilter" name="must_filter" field="field_1" value="$value_1$"/>
|
||||
<filter xsi:type="rangeFilter" name="should_filter" field="field_2" from="$value_2.from$"
|
||||
to="$value_2.to$"/>
|
||||
<filter xsi:type="wildcardFilter" name="not_filter" field="field_3" value="$field_3$"/>
|
||||
</filters>
|
||||
<from>0</from>
|
||||
<size>10000</size>
|
||||
</request>
|
||||
<request query="new_match_query" index="new_query_index">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="new"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="matchQuery" value="$match_term$" name="new_match_query">
|
||||
<match field="new_match_field"/>
|
||||
</query>
|
||||
</queries>
|
||||
<filters/>
|
||||
<from>0</from>
|
||||
<size>10000</size>
|
||||
</request>
|
||||
</requests>
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
/* Create attribute */
|
||||
/** @var $installer \Magento\Catalog\Setup\CategorySetup */
|
||||
$installer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Catalog\Setup\CategorySetup::class,
|
||||
['resourceName' => 'catalog_setup']
|
||||
);
|
||||
/** @var $selectAttribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */
|
||||
$selectAttribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
|
||||
);
|
||||
$selectAttribute->setData(
|
||||
[
|
||||
'attribute_code' => 'select_attribute',
|
||||
'entity_type_id' => $installer->getEntityTypeId('catalog_product'),
|
||||
'is_global' => 1,
|
||||
'frontend_input' => 'select',
|
||||
'is_filterable' => 1,
|
||||
'is_user_defined' => 1,
|
||||
'option' => [
|
||||
'value' => ['option_0' => ['Option 1'], 'option_1' => ['Option 2']],
|
||||
'order' => ['option_0' => 1, 'option_1' => 2],
|
||||
],
|
||||
'backend_type' => 'int',
|
||||
]
|
||||
);
|
||||
$selectAttribute->save();
|
||||
/* Assign attribute to attribute set */
|
||||
$installer->addAttributeToGroup('catalog_product', 'Default', 'General', $selectAttribute->getId());
|
||||
|
||||
/** @var $selectOptions \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection */
|
||||
$selectOptions = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection::class
|
||||
);
|
||||
$selectOptions->setAttributeFilter($selectAttribute->getId());
|
||||
|
||||
$multiselectAttribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
|
||||
);
|
||||
$multiselectAttribute->setData(
|
||||
[
|
||||
'attribute_code' => 'multiselect_attribute',
|
||||
'entity_type_id' => $installer->getEntityTypeId('catalog_product'),
|
||||
'is_global' => 1,
|
||||
'frontend_input' => 'multiselect',
|
||||
'is_filterable' => 1,
|
||||
'is_user_defined' => 1,
|
||||
'option' => [
|
||||
'value' => ['option_0' => ['Option 1'], 'option_1' => ['Option 2']],
|
||||
'order' => ['option_0' => 1, 'option_1' => 2],
|
||||
],
|
||||
'backend_type' => 'text',
|
||||
]
|
||||
);
|
||||
$multiselectAttribute->save();
|
||||
/* Assign attribute to attribute set */
|
||||
$installer->addAttributeToGroup('catalog_product', 'Default', 'General', $multiselectAttribute->getId());
|
||||
|
||||
/** @var $multiselectOptions \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection */
|
||||
$multiselectOptions = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection::class
|
||||
);
|
||||
$multiselectOptions->setAttributeFilter($multiselectAttribute->getId());
|
||||
|
||||
/* Create simple products per each select(dropdown) option */
|
||||
foreach ($selectOptions as $option) {
|
||||
/** @var $product \Magento\Catalog\Model\Product */
|
||||
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Catalog\Model\Product::class
|
||||
);
|
||||
$product->setTypeId(
|
||||
\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE
|
||||
)->setAttributeSetId(
|
||||
$installer->getAttributeSetId('catalog_product', 'Default')
|
||||
)->setWebsiteIds(
|
||||
[1]
|
||||
)->setName(
|
||||
'Simple Product ' . $option->getId()
|
||||
)->setSku(
|
||||
'simple_product_' . $option->getId()
|
||||
)->setPrice(
|
||||
99
|
||||
)->setCategoryIds(
|
||||
[2]
|
||||
)->setVisibility(
|
||||
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
|
||||
)->setStatus(
|
||||
\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
|
||||
)->setStockData(
|
||||
['use_config_manage_stock' => 1, 'qty' => 5, 'is_in_stock' => 1]
|
||||
)->save();
|
||||
|
||||
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
|
||||
\Magento\Catalog\Model\Product\Action::class
|
||||
)->updateAttributes(
|
||||
[$product->getId()],
|
||||
[
|
||||
$selectAttribute->getAttributeCode() => $option->getId(),
|
||||
$multiselectAttribute->getAttributeCode() => $multiselectOptions->getLastItem()->getId()
|
||||
],
|
||||
$product->getStoreId()
|
||||
);
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
/* Create attribute */
|
||||
/** @var $installer \Magento\Catalog\Setup\CategorySetup */
|
||||
$installer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Catalog\Setup\CategorySetup::class,
|
||||
['resourceName' => 'catalog_setup']
|
||||
);
|
||||
/** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */
|
||||
$attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
|
||||
);
|
||||
$attribute->loadByCode(\Magento\Catalog\Model\Product::ENTITY, 'select_attribute');
|
||||
|
||||
/** @var $selectOptions \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection */
|
||||
$selectOptions = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection::class
|
||||
);
|
||||
$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class);
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', true);
|
||||
|
||||
$selectOptions->setAttributeFilter($attribute->getId());
|
||||
/* Delete simple products per each select(dropdown) option */
|
||||
foreach ($selectOptions as $option) {
|
||||
/** @var $product \Magento\Catalog\Model\Product */
|
||||
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Catalog\Model\Product::class
|
||||
);
|
||||
$product = $product->loadByAttribute('sku', 'simple_product_' . $option->getId());
|
||||
if ($product->getId()) {
|
||||
$product->delete();
|
||||
}
|
||||
}
|
||||
if ($attribute->getId()) {
|
||||
$attribute->delete();
|
||||
}
|
||||
|
||||
$attribute->loadByCode($installer->getEntityTypeId('catalog_product'), 'multiselect_attribute');
|
||||
if ($attribute->getId()) {
|
||||
$attribute->delete();
|
||||
}
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', false);
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\Catalog\Model\Product\Action;
|
||||
use Magento\Catalog\Model\Product\Attribute\Source\Status;
|
||||
use Magento\Catalog\Model\Product\Type;
|
||||
use Magento\Catalog\Model\Product\Visibility;
|
||||
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
|
||||
use Magento\Catalog\Setup\CategorySetup;
|
||||
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
/* Create attribute */
|
||||
/** @var $installer CategorySetup */
|
||||
$installer = Bootstrap::getObjectManager()->create(
|
||||
CategorySetup::class,
|
||||
['resourceName' => 'catalog_setup']
|
||||
);
|
||||
$productEntityTypeId = $installer->getEntityTypeId(
|
||||
\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE
|
||||
);
|
||||
|
||||
$selectOptions = [];
|
||||
$selectAttributes = [];
|
||||
foreach (range(1, 2) as $index) {
|
||||
/** @var $selectAttribute Attribute */
|
||||
$selectAttribute = Bootstrap::getObjectManager()->create(
|
||||
Attribute::class
|
||||
);
|
||||
$selectAttribute->setData(
|
||||
[
|
||||
'attribute_code' => 'select_attribute_' . $index,
|
||||
'entity_type_id' => $productEntityTypeId,
|
||||
'is_global' => 1,
|
||||
'is_user_defined' => 1,
|
||||
'frontend_input' => 'select',
|
||||
'is_unique' => 0,
|
||||
'is_required' => 0,
|
||||
'is_searchable' => 1,
|
||||
'is_visible_in_advanced_search' => 1,
|
||||
'is_comparable' => 0,
|
||||
'is_filterable' => 1,
|
||||
'is_filterable_in_search' => 1,
|
||||
'is_used_for_promo_rules' => 0,
|
||||
'is_html_allowed_on_front' => 1,
|
||||
'is_visible_on_front' => 0,
|
||||
'used_in_product_listing' => 0,
|
||||
'used_for_sort_by' => 0,
|
||||
'frontend_label' => ['Select Attribute'],
|
||||
'backend_type' => 'int',
|
||||
'option' => [
|
||||
'value' => ['option_0' => ['Option 1'], 'option_1' => ['Option 2']],
|
||||
'order' => ['option_0' => 1, 'option_1' => 2],
|
||||
],
|
||||
]
|
||||
);
|
||||
$selectAttribute->save();
|
||||
/* Assign attribute to attribute set */
|
||||
$installer->addAttributeToGroup($productEntityTypeId, 'Default', 'General', $selectAttribute->getId());
|
||||
|
||||
/** @var $selectOptions Collection */
|
||||
$selectOption = Bootstrap::getObjectManager()->create(
|
||||
Collection::class
|
||||
);
|
||||
$selectOption->setAttributeFilter($selectAttribute->getId());
|
||||
$selectAttributes[$index] = $selectAttribute;
|
||||
$selectOptions[$index] = $selectOption;
|
||||
}
|
||||
|
||||
$dateAttribute = Bootstrap::getObjectManager()->create(Attribute::class);
|
||||
$dateAttribute->setData(
|
||||
[
|
||||
'attribute_code' => 'date_attribute',
|
||||
'entity_type_id' => $productEntityTypeId,
|
||||
'is_global' => 1,
|
||||
'is_filterable' => 1,
|
||||
'is_user_defined' => 1,
|
||||
'backend_type' => 'datetime',
|
||||
'frontend_input' => 'date',
|
||||
'frontend_label' => 'Test Date',
|
||||
'is_searchable' => 1,
|
||||
'is_filterable_in_search' => 1,
|
||||
]
|
||||
);
|
||||
$dateAttribute->save();
|
||||
/* Assign attribute to attribute set */
|
||||
$installer->addAttributeToGroup($productEntityTypeId, 'Default', 'General', $dateAttribute->getId());
|
||||
|
||||
$decimalAttribute = Bootstrap::getObjectManager()->create(Attribute::class);
|
||||
$decimalAttribute->setData(
|
||||
[
|
||||
'attribute_code' => 'decimal_attribute',
|
||||
'entity_type_id' => $productEntityTypeId,
|
||||
'is_global' => 1,
|
||||
'is_filterable' => 1,
|
||||
'is_user_defined' => 1,
|
||||
'backend_type' => 'decimal',
|
||||
'frontend_input' => 'weight',
|
||||
'frontend_label' => 'Test Decimal',
|
||||
'is_searchable' => 1,
|
||||
'is_filterable_in_search' => 1,
|
||||
]
|
||||
);
|
||||
$decimalAttribute->save();
|
||||
/* Assign attribute to attribute set */
|
||||
$installer->addAttributeToGroup($productEntityTypeId, 'Default', 'General', $decimalAttribute->getId());
|
||||
|
||||
$productAttributeSetId = $installer->getAttributeSetId($productEntityTypeId, 'Default');
|
||||
/* Create simple products per each first attribute option */
|
||||
foreach ($selectOptions[1] as $option) {
|
||||
/** @var $product Product */
|
||||
$product = Bootstrap::getObjectManager()->create(
|
||||
Product::class
|
||||
);
|
||||
$product->setTypeId(
|
||||
Type::TYPE_SIMPLE
|
||||
)->setAttributeSetId(
|
||||
$productAttributeSetId
|
||||
)->setWebsiteIds(
|
||||
[1]
|
||||
)->setName(
|
||||
'Simple Product ' . $option->getId()
|
||||
)->setSku(
|
||||
'simple_product_' . $option->getId()
|
||||
)->setPrice(
|
||||
99
|
||||
)->setCategoryIds(
|
||||
[2]
|
||||
)->setVisibility(
|
||||
Visibility::VISIBILITY_BOTH
|
||||
)->setStatus(
|
||||
Status::STATUS_ENABLED
|
||||
)->setStockData(
|
||||
['use_config_manage_stock' => 1, 'qty' => 5, 'is_in_stock' => 1]
|
||||
)->save();
|
||||
|
||||
Bootstrap::getObjectManager()->get(
|
||||
Action::class
|
||||
)->updateAttributes(
|
||||
[$product->getId()],
|
||||
[
|
||||
$selectAttributes[1]->getAttributeCode() => $option->getId(),
|
||||
$selectAttributes[2]->getAttributeCode() => $selectOptions[2]->getLastItem()->getId(),
|
||||
$dateAttribute->getAttributeCode() => '10/30/2000',
|
||||
$decimalAttribute->getAttributeCode() => 1.11,
|
||||
],
|
||||
$product->getStoreId()
|
||||
);
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
|
||||
use Magento\Catalog\Setup\CategorySetup;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
$registry = Bootstrap::getObjectManager()->get(Registry::class);
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', true);
|
||||
|
||||
/** @var $productCollection \Magento\Catalog\Model\ResourceModel\Product\Collection */
|
||||
$productCollection = Bootstrap::getObjectManager()
|
||||
->create(Product::class)
|
||||
->getCollection();
|
||||
foreach ($productCollection as $product) {
|
||||
$product->delete();
|
||||
}
|
||||
|
||||
/** @var $attribute Attribute */
|
||||
$attribute = Bootstrap::getObjectManager()->create(
|
||||
Attribute::class
|
||||
);
|
||||
/** @var $installer CategorySetup */
|
||||
$installer = Bootstrap::getObjectManager()->create(CategorySetup::class);
|
||||
$productEntityTypeId = $installer->getEntityTypeId(
|
||||
\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE
|
||||
);
|
||||
foreach (range(1, 2) as $index) {
|
||||
$attribute->loadByCode($productEntityTypeId, 'select_attribute_' . $index);
|
||||
if ($attribute->getId()) {
|
||||
$attribute->delete();
|
||||
}
|
||||
}
|
||||
$attribute->loadByCode($productEntityTypeId, 'date_attribute');
|
||||
if ($attribute->getId()) {
|
||||
$attribute->delete();
|
||||
}
|
||||
|
||||
$attribute->loadByCode($productEntityTypeId, 'decimal_attribute');
|
||||
if ($attribute->getId()) {
|
||||
$attribute->delete();
|
||||
}
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', false);
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\Catalog\Model\Product\Attribute\Source\Status;
|
||||
use Magento\Catalog\Model\Product\Type;
|
||||
use Magento\Catalog\Model\Product\Visibility;
|
||||
use Magento\Catalog\Setup\CategorySetup;
|
||||
use Magento\ConfigurableProduct\Helper\Product\Options\Factory;
|
||||
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
|
||||
use Magento\Eav\Api\Data\AttributeOptionInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
use Magento\Eav\Model\Config;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Framework/Search/_files/configurable_attribute.php');
|
||||
|
||||
/** @var ProductRepositoryInterface $productRepository */
|
||||
$productRepository = Bootstrap::getObjectManager()
|
||||
->create(ProductRepositoryInterface::class);
|
||||
|
||||
$eavConfig = Bootstrap::getObjectManager()->get(Config::class);
|
||||
$attribute = $eavConfig->getAttribute(Product::ENTITY, 'test_configurable');
|
||||
/** @var $installer CategorySetup */
|
||||
$installer = Bootstrap::getObjectManager()->create(CategorySetup::class);
|
||||
|
||||
/* Create simple products per each option value*/
|
||||
/** @var AttributeOptionInterface[] $options */
|
||||
$options = $attribute->getOptions();
|
||||
|
||||
$attributeValues = [];
|
||||
$attributeSetId = $installer->getAttributeSetId('catalog_product', 'Default');
|
||||
$associatedProductIds = [];
|
||||
$productIds = [1010, 1020];
|
||||
array_shift($options); //remove the first option which is empty
|
||||
|
||||
$isFirstOption = true;
|
||||
foreach ($options as $option) {
|
||||
/** @var $product Product */
|
||||
$product = Bootstrap::getObjectManager()->create(Product::class);
|
||||
$productId = array_shift($productIds);
|
||||
$product->setTypeId(Type::TYPE_SIMPLE)
|
||||
->setId($productId)
|
||||
->setAttributeSetId($attributeSetId)
|
||||
->setWebsiteIds([1])
|
||||
->setName('Configurable Option' . $option->getLabel())
|
||||
->setSku('simple_' . $productId)
|
||||
->setPrice($productId)
|
||||
->setTestConfigurable($option->getValue())
|
||||
->setVisibility(Visibility::VISIBILITY_NOT_VISIBLE)
|
||||
->setStatus(Status::STATUS_ENABLED)
|
||||
->setStockData(
|
||||
[
|
||||
'use_config_manage_stock' => 1,
|
||||
'qty' => 100,
|
||||
'is_qty_decimal' => 0,
|
||||
'is_in_stock' => (int)!$isFirstOption,
|
||||
]
|
||||
);
|
||||
|
||||
$product = $productRepository->save($product);
|
||||
|
||||
/** @var \Magento\CatalogInventory\Model\Stock\Item $stockItem */
|
||||
$stockItem = Bootstrap::getObjectManager()->create(\Magento\CatalogInventory\Model\Stock\Item::class);
|
||||
$stockItem->load($productId, 'product_id');
|
||||
|
||||
if (!$stockItem->getProductId()) {
|
||||
$stockItem->setProductId($productId);
|
||||
}
|
||||
$stockItem->setUseConfigManageStock(1);
|
||||
$stockItem->setQty(1000);
|
||||
$stockItem->setIsQtyDecimal(0);
|
||||
$stockItem->setIsInStock((int)!$isFirstOption);
|
||||
$stockItem->save();
|
||||
|
||||
$attributeValues[] = [
|
||||
'label' => 'test',
|
||||
'attribute_id' => $attribute->getId(),
|
||||
'value_index' => $option->getValue(),
|
||||
];
|
||||
$associatedProductIds[] = $product->getId();
|
||||
$isFirstOption = false;
|
||||
}
|
||||
|
||||
/** @var $product Product */
|
||||
$product = Bootstrap::getObjectManager()->create(Product::class);
|
||||
|
||||
/** @var Factory $optionsFactory */
|
||||
$optionsFactory = Bootstrap::getObjectManager()->create(Factory::class);
|
||||
|
||||
$configurableAttributesData = [
|
||||
[
|
||||
'attribute_id' => $attribute->getId(),
|
||||
'code' => $attribute->getAttributeCode(),
|
||||
'label' => $attribute->getStoreLabel(),
|
||||
'position' => '0',
|
||||
'values' => $attributeValues,
|
||||
],
|
||||
];
|
||||
|
||||
$configurableOptions = $optionsFactory->create($configurableAttributesData);
|
||||
|
||||
$extensionConfigurableAttributes = $product->getExtensionAttributes();
|
||||
$extensionConfigurableAttributes->setConfigurableProductOptions($configurableOptions);
|
||||
$extensionConfigurableAttributes->setConfigurableProductLinks($associatedProductIds);
|
||||
|
||||
$product->setExtensionAttributes($extensionConfigurableAttributes);
|
||||
|
||||
$product->setTypeId(Configurable::TYPE_CODE)
|
||||
->setId(1001)
|
||||
->setAttributeSetId($attributeSetId)
|
||||
->setWebsiteIds([1])
|
||||
->setName('Configurable Product')
|
||||
->setSku('configurable')
|
||||
->setVisibility(Visibility::VISIBILITY_BOTH)
|
||||
->setStatus(Status::STATUS_ENABLED)
|
||||
->setStockData(['use_config_manage_stock' => 1, 'is_in_stock' => 1]);
|
||||
|
||||
$productRepository->save($product);
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
|
||||
/** @var \Magento\Framework\Registry $registry */
|
||||
$registry = $objectManager->get(\Magento\Framework\Registry::class);
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', true);
|
||||
|
||||
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
|
||||
$productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
|
||||
|
||||
foreach (['simple_1010', 'simple_1020', 'configurable'] as $sku) {
|
||||
try {
|
||||
$product = $productRepository->get($sku, false, null, true);
|
||||
|
||||
$stockStatus = $objectManager->create(\Magento\CatalogInventory\Model\Stock\Status::class);
|
||||
$stockStatus->load($product->getEntityId(), 'product_id');
|
||||
$stockStatus->delete();
|
||||
|
||||
$productRepository->delete($product);
|
||||
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
|
||||
//Product already removed
|
||||
}
|
||||
}
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Framework/Search/_files/configurable_attribute_rollback.php');
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', false);
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Framework/Search/_files/product_configurable.php');
|
||||
|
||||
/** @var ProductRepositoryInterface $productRepository */
|
||||
$productRepository = Bootstrap::getObjectManager()
|
||||
->create(ProductRepositoryInterface::class);
|
||||
|
||||
$product = $productRepository->get('simple_1020');
|
||||
$product->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED);
|
||||
$productRepository->save($product);
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Framework/Search/_files/product_configurable_rollback.php');
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\Catalog\Api\CategoryLinkManagementInterface;
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Catalog\Helper\DefaultCategory;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Framework/Search/_files/product_configurable.php');
|
||||
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
|
||||
/** @var ProductRepositoryInterface $productRepository */
|
||||
$productRepository = $objectManager->create(ProductRepositoryInterface::class);
|
||||
|
||||
$product = $productRepository->get('simple_1010');
|
||||
$product->setStockData(
|
||||
[
|
||||
'qty' => 0,
|
||||
]
|
||||
);
|
||||
$productRepository->save($product);
|
||||
|
||||
$product = $productRepository->get('simple_1020');
|
||||
$product->setStockData(
|
||||
[
|
||||
'qty' => 0,
|
||||
]
|
||||
);
|
||||
$productRepository->save($product);
|
||||
|
||||
/** @var CategoryLinkManagementInterface $categoryLinkManagement */
|
||||
$categoryLinkManagement = $objectManager->create(CategoryLinkManagementInterface::class);
|
||||
/** @var DefaultCategory $categoryHelper */
|
||||
$categoryHelper = $objectManager->get(DefaultCategory::class);
|
||||
|
||||
foreach (['simple_1010', 'simple_1020', 'configurable'] as $sku) {
|
||||
$categoryLinkManagement->assignProductToCategories($sku, [$categoryHelper->getId(), 333]);
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/category_rollback.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Framework/Search/_files/product_configurable_rollback.php');
|
||||
@@ -0,0 +1,324 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
/** @var \Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory $customOptionFactory */
|
||||
$customOptionFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->create(\Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory::class);
|
||||
/** @var $product \Magento\Catalog\Model\Product */
|
||||
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->create(\Magento\Catalog\Model\Product::class);
|
||||
$product->isObjectNew(true);
|
||||
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
|
||||
->setId(1)
|
||||
->setAttributeSetId(4)
|
||||
->setWebsiteIds([1])
|
||||
->setName('Unisex green socks')
|
||||
->setSku('green_socks')
|
||||
->setPrice(12)
|
||||
->setWeight(1)
|
||||
->setShortDescription("Unisex green socks for some good peoples at one")
|
||||
->setTaxClassId(0)
|
||||
->setTierPrice(
|
||||
[
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 2,
|
||||
'price' => 8,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 5,
|
||||
'price' => 5,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::NOT_LOGGED_IN_ID,
|
||||
'price_qty' => 3,
|
||||
'price' => 5,
|
||||
],
|
||||
]
|
||||
)
|
||||
->setDescription('Unisex <b>green socks</b> for some good peoples at one')
|
||||
->setMetaTitle('green socks metadata')
|
||||
->setMetaKeyword('green,socks,unisex')
|
||||
->setMetaDescription('green socks metadata description')
|
||||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
|
||||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
|
||||
->setCategoryIds([2])
|
||||
->setStockData(
|
||||
[
|
||||
'use_config_manage_stock' => 1,
|
||||
'qty' => 100,
|
||||
'is_qty_decimal' => 0,
|
||||
'is_in_stock' => 1,
|
||||
]
|
||||
);
|
||||
$option = [
|
||||
'previous_group' => 'text',
|
||||
'title' => 'Stone',
|
||||
'type' => 'field',
|
||||
'is_require' => 1,
|
||||
'sort_order' => 0,
|
||||
'price' => 1,
|
||||
'price_type' => 'fixed',
|
||||
'sku' => 'stone-1',
|
||||
'max_characters' => 100,
|
||||
];
|
||||
/** @var \Magento\Catalog\Api\Data\ProductCustomOptionInterface $customOption */
|
||||
$customOption = $customOptionFactory->create(['data' => $option]);
|
||||
$customOption->setProductSku($product->getSku());
|
||||
$product->setCanSaveCustomOptions(true)
|
||||
->setOptions([$customOption])
|
||||
->setHasOptions(true)
|
||||
->save();
|
||||
|
||||
/** @var $product \Magento\Catalog\Model\Product */
|
||||
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->create(\Magento\Catalog\Model\Product::class);
|
||||
$product->isObjectNew(true);
|
||||
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
|
||||
->setId(2)
|
||||
->setAttributeSetId(4)
|
||||
->setWebsiteIds([1])
|
||||
->setName('White shorts')
|
||||
->setSku('white_shorts')
|
||||
->setPrice(14)
|
||||
->setWeight(2)
|
||||
->setShortDescription("Small white shorts for your children")
|
||||
->setTaxClassId(0)
|
||||
->setTierPrice(
|
||||
[
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 2,
|
||||
'price' => 8,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 5,
|
||||
'price' => 5,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::NOT_LOGGED_IN_ID,
|
||||
'price_qty' => 3,
|
||||
'price' => 5,
|
||||
],
|
||||
]
|
||||
)
|
||||
->setDescription('Small <b>white shorts</b> for your children')
|
||||
->setMetaTitle('white shorts for your children metadata')
|
||||
->setMetaKeyword('white,shorts,children')
|
||||
->setMetaDescription('white shorts for your children metadata description')
|
||||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
|
||||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
|
||||
->setCategoryIds([2])
|
||||
->setStockData(
|
||||
[
|
||||
'use_config_manage_stock' => 1,
|
||||
'qty' => 100,
|
||||
'is_qty_decimal' => 0,
|
||||
'is_in_stock' => 1,
|
||||
]
|
||||
);
|
||||
$option = [
|
||||
'previous_group' => 'text',
|
||||
'title' => 'Gold',
|
||||
'type' => 'field',
|
||||
'is_require' => 1,
|
||||
'sort_order' => 0,
|
||||
'price' => 1,
|
||||
'price_type' => 'fixed',
|
||||
'sku' => 'Gold',
|
||||
'max_characters' => 100,
|
||||
];
|
||||
/** @var \Magento\Catalog\Api\Data\ProductCustomOptionInterface $customOption */
|
||||
$customOption = $customOptionFactory->create(['data' => $option]);
|
||||
$customOption->setProductSku($product->getSku());
|
||||
$product->setCanSaveCustomOptions(true)
|
||||
->setOptions([$customOption])
|
||||
->setHasOptions(true)
|
||||
->save();
|
||||
|
||||
/** @var $product \Magento\Catalog\Model\Product */
|
||||
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->create(\Magento\Catalog\Model\Product::class);
|
||||
$product->isObjectNew(true);
|
||||
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
|
||||
->setId(3)
|
||||
->setAttributeSetId(4)
|
||||
->setWebsiteIds([1])
|
||||
->setName('Red trousers')
|
||||
->setSku('red_trousers')
|
||||
->setPrice(16)
|
||||
->setWeight(3)
|
||||
->setShortDescription("Red pants for men")
|
||||
->setTaxClassId(0)
|
||||
->setTierPrice(
|
||||
[
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 2,
|
||||
'price' => 8,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 5,
|
||||
'price' => 5,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::NOT_LOGGED_IN_ID,
|
||||
'price_qty' => 3,
|
||||
'price' => 5,
|
||||
],
|
||||
]
|
||||
)
|
||||
->setDescription('Red pants for <b>men</b>')
|
||||
->setMetaTitle('Red trousers meta title')
|
||||
->setMetaKeyword('red,trousers,meta,men')
|
||||
->setMetaDescription('Red trousers meta description')
|
||||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
|
||||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
|
||||
->setCategoryIds([2])
|
||||
->setStockData(
|
||||
[
|
||||
'use_config_manage_stock' => 1,
|
||||
'qty' => 100,
|
||||
'is_qty_decimal' => 0,
|
||||
'is_in_stock' => 1,
|
||||
]
|
||||
);
|
||||
$option = [
|
||||
'previous_group' => 'text',
|
||||
'title' => 'Silver',
|
||||
'type' => 'field',
|
||||
'is_require' => 1,
|
||||
'sort_order' => 0,
|
||||
'price' => 1,
|
||||
'price_type' => 'fixed',
|
||||
'sku' => 'silver',
|
||||
'max_characters' => 100,
|
||||
];
|
||||
/** @var \Magento\Catalog\Api\Data\ProductCustomOptionInterface $customOption */
|
||||
$customOption = $customOptionFactory->create(['data' => $option]);
|
||||
$customOption->setProductSku($product->getSku());
|
||||
$product->setCanSaveCustomOptions(true)
|
||||
->setOptions([$customOption])
|
||||
->setHasOptions(true)
|
||||
->save();
|
||||
|
||||
/** @var $product \Magento\Catalog\Model\Product */
|
||||
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->create(\Magento\Catalog\Model\Product::class);
|
||||
$product->isObjectNew(true);
|
||||
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
|
||||
->setId(4)
|
||||
->setAttributeSetId(4)
|
||||
->setWebsiteIds([1])
|
||||
->setName('Blue briefs')
|
||||
->setSku('blue_briefs')
|
||||
->setPrice(18)
|
||||
->setWeight(3)
|
||||
->setShortDescription("Blue briefs for Russian men")
|
||||
->setTaxClassId(0)
|
||||
->setTierPrice(
|
||||
[
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 2,
|
||||
'price' => 8,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 5,
|
||||
'price' => 5,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::NOT_LOGGED_IN_ID,
|
||||
'price_qty' => 3,
|
||||
'price' => 5,
|
||||
],
|
||||
]
|
||||
)
|
||||
->setDescription('Blue briefs for <b>men</b>')
|
||||
->setMetaTitle('Blue briefs meta title')
|
||||
->setMetaKeyword('blue,briefs,meta,men')
|
||||
->setMetaDescription('Blue briefs meta description')
|
||||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
|
||||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
|
||||
->setCategoryIds([2])
|
||||
->setStockData(
|
||||
[
|
||||
'use_config_manage_stock' => 1,
|
||||
'qty' => 100,
|
||||
'is_qty_decimal' => 0,
|
||||
'is_in_stock' => 1,
|
||||
]
|
||||
)
|
||||
->save();
|
||||
|
||||
/** @var $product \Magento\Catalog\Model\Product */
|
||||
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->create(\Magento\Catalog\Model\Product::class);
|
||||
$product->isObjectNew(true);
|
||||
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
|
||||
->setId(5)
|
||||
->setAttributeSetId(4)
|
||||
->setWebsiteIds([1])
|
||||
->setName('Grey shorts')
|
||||
->setSku('grey_shorts')
|
||||
->setPrice(20)
|
||||
->setWeight(3)
|
||||
->setShortDescription("Grey or green shorts for all peoples at one")
|
||||
->setTaxClassId(0)
|
||||
->setTierPrice(
|
||||
[
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 2,
|
||||
'price' => 8,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 5,
|
||||
'price' => 5,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::NOT_LOGGED_IN_ID,
|
||||
'price_qty' => 3,
|
||||
'price' => 5,
|
||||
],
|
||||
]
|
||||
)
|
||||
->setDescription('Grey or green shorts for peoples at <b>one</b>')
|
||||
->setMetaTitle('Grey shorts meta title')
|
||||
->setMetaKeyword('grey,shorts,meta,men')
|
||||
->setMetaDescription('Grey shorts meta description')
|
||||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
|
||||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
|
||||
->setCategoryIds([2])
|
||||
->setStockData(
|
||||
[
|
||||
'use_config_manage_stock' => 1,
|
||||
'qty' => 100,
|
||||
'is_qty_decimal' => 0,
|
||||
'is_in_stock' => 1,
|
||||
]
|
||||
)
|
||||
->save();
|
||||
+483
@@ -0,0 +1,483 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
/** @var \Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory $customOptionFactory */
|
||||
$customOptionFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->create(\Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory::class);
|
||||
/** @var $product \Magento\Catalog\Model\Product */
|
||||
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->create(\Magento\Catalog\Model\Product::class);
|
||||
$product->isObjectNew(true);
|
||||
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
|
||||
->setId(1)
|
||||
->setAttributeSetId(4)
|
||||
->setWebsiteIds([1])
|
||||
->setName('Unisex green socks')
|
||||
->setSku('green_socks')
|
||||
->setPrice(12)
|
||||
->setWeight(1)
|
||||
->setShortDescription("Unisex green socks for some good peoples at one")
|
||||
->setTaxClassId(0)
|
||||
->setTierPrice(
|
||||
[
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 2,
|
||||
'price' => 8,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 5,
|
||||
'price' => 5,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::NOT_LOGGED_IN_ID,
|
||||
'price_qty' => 3,
|
||||
'price' => 5,
|
||||
],
|
||||
]
|
||||
)
|
||||
->setDescription('Unisex <b>green socks</b> for some good peoples at one')
|
||||
->setMetaTitle('green socks metadata')
|
||||
->setMetaKeyword('green,socks,unisex')
|
||||
->setMetaDescription('green socks metadata description')
|
||||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
|
||||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
|
||||
->setCategoryIds([2])
|
||||
->setStockData(
|
||||
[
|
||||
'use_config_manage_stock' => 1,
|
||||
'qty' => 100,
|
||||
'is_qty_decimal' => 0,
|
||||
'is_in_stock' => 1,
|
||||
]
|
||||
);
|
||||
$option = [
|
||||
'previous_group' => 'text',
|
||||
'title' => 'Stone',
|
||||
'type' => 'field',
|
||||
'is_require' => 1,
|
||||
'sort_order' => 0,
|
||||
'price' => 1,
|
||||
'price_type' => 'fixed',
|
||||
'sku' => 'stone-1',
|
||||
'max_characters' => 100,
|
||||
];
|
||||
/** @var \Magento\Catalog\Api\Data\ProductCustomOptionInterface $customOption */
|
||||
$customOption = $customOptionFactory->create(['data' => $option]);
|
||||
$customOption->setProductSku($product->getSku());
|
||||
$product->setCanSaveCustomOptions(true)
|
||||
->setOptions([$customOption])
|
||||
->setHasOptions(true)
|
||||
->save();
|
||||
|
||||
/** @var $product \Magento\Catalog\Model\Product */
|
||||
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->create(\Magento\Catalog\Model\Product::class);
|
||||
$product->isObjectNew(true);
|
||||
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
|
||||
->setId(2)
|
||||
->setAttributeSetId(4)
|
||||
->setWebsiteIds([1])
|
||||
->setName('White shorts')
|
||||
->setSku('white_shorts')
|
||||
->setPrice(14)
|
||||
->setWeight(2)
|
||||
->setShortDescription("Small white shorts for your children")
|
||||
->setTaxClassId(0)
|
||||
->setTierPrice(
|
||||
[
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 2,
|
||||
'price' => 8,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 5,
|
||||
'price' => 5,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::NOT_LOGGED_IN_ID,
|
||||
'price_qty' => 3,
|
||||
'price' => 5,
|
||||
],
|
||||
]
|
||||
)
|
||||
->setDescription('Small <b>white shorts</b> for your children')
|
||||
->setMetaTitle('white shorts for your children metadata')
|
||||
->setMetaKeyword('white,shorts,children')
|
||||
->setMetaDescription('white shorts for your children metadata description')
|
||||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
|
||||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
|
||||
->setCategoryIds([2])
|
||||
->setStockData(
|
||||
[
|
||||
'use_config_manage_stock' => 1,
|
||||
'qty' => 100,
|
||||
'is_qty_decimal' => 0,
|
||||
'is_in_stock' => 1,
|
||||
]
|
||||
);
|
||||
$option = [
|
||||
'previous_group' => 'text',
|
||||
'title' => 'Gold',
|
||||
'type' => 'field',
|
||||
'is_require' => 1,
|
||||
'sort_order' => 0,
|
||||
'price' => 1,
|
||||
'price_type' => 'fixed',
|
||||
'sku' => 'Gold',
|
||||
'max_characters' => 100,
|
||||
];
|
||||
/** @var \Magento\Catalog\Api\Data\ProductCustomOptionInterface $customOption */
|
||||
$customOption = $customOptionFactory->create(['data' => $option]);
|
||||
$customOption->setProductSku($product->getSku());
|
||||
$product->setCanSaveCustomOptions(true)
|
||||
->setOptions([$customOption])
|
||||
->setHasOptions(true)
|
||||
->save();
|
||||
|
||||
/** @var $product \Magento\Catalog\Model\Product */
|
||||
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->create(\Magento\Catalog\Model\Product::class);
|
||||
$product->isObjectNew(true);
|
||||
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
|
||||
->setId(3)
|
||||
->setAttributeSetId(4)
|
||||
->setWebsiteIds([1])
|
||||
->setName('Red trousers')
|
||||
->setSku('red_trousers')
|
||||
->setPrice(16)
|
||||
->setWeight(3)
|
||||
->setShortDescription("Red pants for men")
|
||||
->setTaxClassId(0)
|
||||
->setTierPrice(
|
||||
[
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 2,
|
||||
'price' => 8,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 5,
|
||||
'price' => 5,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::NOT_LOGGED_IN_ID,
|
||||
'price_qty' => 3,
|
||||
'price' => 5,
|
||||
],
|
||||
]
|
||||
)
|
||||
->setDescription('Red pants for <b>men</b>')
|
||||
->setMetaTitle('Red trousers meta title')
|
||||
->setMetaKeyword('red,trousers,meta,men')
|
||||
->setMetaDescription('Red trousers meta description')
|
||||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
|
||||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
|
||||
->setCategoryIds([2])
|
||||
->setStockData(
|
||||
[
|
||||
'use_config_manage_stock' => 1,
|
||||
'qty' => 100,
|
||||
'is_qty_decimal' => 0,
|
||||
'is_in_stock' => 1,
|
||||
]
|
||||
);
|
||||
$option = [
|
||||
'previous_group' => 'text',
|
||||
'title' => 'Silver',
|
||||
'type' => 'field',
|
||||
'is_require' => 1,
|
||||
'sort_order' => 0,
|
||||
'price' => 1,
|
||||
'price_type' => 'fixed',
|
||||
'sku' => 'silver',
|
||||
'max_characters' => 100,
|
||||
];
|
||||
/** @var \Magento\Catalog\Api\Data\ProductCustomOptionInterface $customOption */
|
||||
$customOption = $customOptionFactory->create(['data' => $option]);
|
||||
$customOption->setProductSku($product->getSku());
|
||||
$product->setCanSaveCustomOptions(true)
|
||||
->setOptions([$customOption])
|
||||
->setHasOptions(true)
|
||||
->save();
|
||||
|
||||
/** @var $product \Magento\Catalog\Model\Product */
|
||||
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->create(\Magento\Catalog\Model\Product::class);
|
||||
$product->isObjectNew(true);
|
||||
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
|
||||
->setId(4)
|
||||
->setAttributeSetId(4)
|
||||
->setWebsiteIds([1])
|
||||
->setName('Blue briefs')
|
||||
->setSku('blue_briefs')
|
||||
->setPrice(18)
|
||||
->setWeight(3)
|
||||
->setShortDescription("Blue briefs for Russian men")
|
||||
->setTaxClassId(0)
|
||||
->setTierPrice(
|
||||
[
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 2,
|
||||
'price' => 8,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 5,
|
||||
'price' => 5,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::NOT_LOGGED_IN_ID,
|
||||
'price_qty' => 3,
|
||||
'price' => 5,
|
||||
],
|
||||
]
|
||||
)
|
||||
->setDescription('Blue briefs for <b>men</b>')
|
||||
->setMetaTitle('Blue briefs meta title')
|
||||
->setMetaKeyword('blue,briefs,meta,men')
|
||||
->setMetaDescription('Blue briefs meta description')
|
||||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
|
||||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
|
||||
->setCategoryIds([2])
|
||||
->setStockData(
|
||||
[
|
||||
'use_config_manage_stock' => 1,
|
||||
'qty' => 100,
|
||||
'is_qty_decimal' => 0,
|
||||
'is_in_stock' => 1,
|
||||
]
|
||||
)
|
||||
->save();
|
||||
|
||||
/** @var $product \Magento\Catalog\Model\Product */
|
||||
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->create(\Magento\Catalog\Model\Product::class);
|
||||
$product->isObjectNew(true);
|
||||
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
|
||||
->setId(5)
|
||||
->setAttributeSetId(4)
|
||||
->setWebsiteIds([1])
|
||||
->setName('Grey shorts')
|
||||
->setSku('grey_shorts')
|
||||
->setPrice(20)
|
||||
->setWeight(3)
|
||||
->setShortDescription("Grey or green shorts for all peoples at one")
|
||||
->setTaxClassId(0)
|
||||
->setTierPrice(
|
||||
[
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 2,
|
||||
'price' => 8,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 5,
|
||||
'price' => 5,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::NOT_LOGGED_IN_ID,
|
||||
'price_qty' => 3,
|
||||
'price' => 5,
|
||||
],
|
||||
]
|
||||
)
|
||||
->setDescription('Grey or green shorts for peoples at <b>one</b>')
|
||||
->setMetaTitle('Grey shorts meta title')
|
||||
->setMetaKeyword('grey,shorts,meta,men')
|
||||
->setMetaDescription('Grey shorts meta description')
|
||||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
|
||||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
|
||||
->setCategoryIds([2])
|
||||
->setStockData(
|
||||
[
|
||||
'use_config_manage_stock' => 1,
|
||||
'qty' => 100,
|
||||
'is_qty_decimal' => 0,
|
||||
'is_in_stock' => 1,
|
||||
]
|
||||
)
|
||||
->save();
|
||||
|
||||
/** @var $product \Magento\Catalog\Model\Product */
|
||||
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->create(\Magento\Catalog\Model\Product::class);
|
||||
$product->isObjectNew(true);
|
||||
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
|
||||
->setId(6)
|
||||
->setAttributeSetId(4)
|
||||
->setWebsiteIds([1])
|
||||
->setName('Blue shorts')
|
||||
->setSku('blue_shorts')
|
||||
->setPrice(22)
|
||||
->setWeight(3)
|
||||
->setShortDescription("Blue or green shorts for all peoples at one")
|
||||
->setTaxClassId(0)
|
||||
->setTierPrice(
|
||||
[
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 2,
|
||||
'price' => 8,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 5,
|
||||
'price' => 5,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::NOT_LOGGED_IN_ID,
|
||||
'price_qty' => 3,
|
||||
'price' => 5,
|
||||
],
|
||||
]
|
||||
)
|
||||
->setDescription('Blue or green shorts for peoples at <b>one</b>')
|
||||
->setMetaTitle('blue shorts meta title')
|
||||
->setMetaKeyword('blue,shorts,meta,men')
|
||||
->setMetaDescription('blue shorts meta description')
|
||||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
|
||||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
|
||||
->setCategoryIds([2])
|
||||
->setStockData(
|
||||
[
|
||||
'use_config_manage_stock' => 1,
|
||||
'qty' => 100,
|
||||
'is_qty_decimal' => 0,
|
||||
'is_in_stock' => 1,
|
||||
]
|
||||
)
|
||||
->save();
|
||||
|
||||
/** @var $product \Magento\Catalog\Model\Product */
|
||||
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->create(\Magento\Catalog\Model\Product::class);
|
||||
$product->isObjectNew(true);
|
||||
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
|
||||
->setId(7)
|
||||
->setAttributeSetId(4)
|
||||
->setWebsiteIds([1])
|
||||
->setName('Red shorts')
|
||||
->setSku('red_shorts')
|
||||
->setPrice(24)
|
||||
->setWeight(3)
|
||||
->setShortDescription("Red or green shorts for all peoples at one")
|
||||
->setTaxClassId(0)
|
||||
->setTierPrice(
|
||||
[
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 2,
|
||||
'price' => 8,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 5,
|
||||
'price' => 5,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::NOT_LOGGED_IN_ID,
|
||||
'price_qty' => 3,
|
||||
'price' => 5,
|
||||
],
|
||||
]
|
||||
)
|
||||
->setDescription('Red or green shorts for peoples at <b>one</b>')
|
||||
->setMetaTitle('red shorts meta title')
|
||||
->setMetaKeyword('red,shorts,meta,men')
|
||||
->setMetaDescription('red shorts meta description')
|
||||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
|
||||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
|
||||
->setCategoryIds([2])
|
||||
->setStockData(
|
||||
[
|
||||
'use_config_manage_stock' => 1,
|
||||
'qty' => 100,
|
||||
'is_qty_decimal' => 0,
|
||||
'is_in_stock' => 1,
|
||||
]
|
||||
)
|
||||
->save();
|
||||
|
||||
/** @var $product \Magento\Catalog\Model\Product */
|
||||
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->create(\Magento\Catalog\Model\Product::class);
|
||||
$product->isObjectNew(true);
|
||||
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
|
||||
->setId(8)
|
||||
->setAttributeSetId(4)
|
||||
->setWebsiteIds([1])
|
||||
->setName('Yellow shorts')
|
||||
->setSku('yellow_shorts')
|
||||
->setPrice(26)
|
||||
->setWeight(3)
|
||||
->setShortDescription("Yellow or green shorts for all peoples at one")
|
||||
->setTaxClassId(0)
|
||||
->setTierPrice(
|
||||
[
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 2,
|
||||
'price' => 8,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL,
|
||||
'price_qty' => 5,
|
||||
'price' => 5,
|
||||
],
|
||||
[
|
||||
'website_id' => 0,
|
||||
'cust_group' => \Magento\Customer\Model\GroupManagement::NOT_LOGGED_IN_ID,
|
||||
'price_qty' => 3,
|
||||
'price' => 5,
|
||||
],
|
||||
]
|
||||
)
|
||||
->setDescription('Yellow or green shorts for peoples at <b>one</b>')
|
||||
->setMetaTitle('yellow shorts meta title')
|
||||
->setMetaKeyword('yellow,shorts,meta,men')
|
||||
->setMetaDescription('yellow shorts meta description')
|
||||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
|
||||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
|
||||
->setCategoryIds([2])
|
||||
->setStockData(
|
||||
[
|
||||
'use_config_manage_stock' => 1,
|
||||
'qty' => 100,
|
||||
'is_qty_decimal' => 0,
|
||||
'is_in_stock' => 1,
|
||||
]
|
||||
)
|
||||
->save();
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
/** @var \Magento\Framework\Registry $registry */
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$registry = $objectManager->get(\Magento\Framework\Registry::class);
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', true);
|
||||
|
||||
/** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $collection */
|
||||
$collection = $objectManager->create(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
|
||||
$collection->addAttributeToSelect('id')->load();
|
||||
if ($collection->count() > 0) {
|
||||
$collection->delete();
|
||||
}
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', false);
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\CatalogInventory\Model\StockRegistryStorage;
|
||||
|
||||
/** @var \Magento\Framework\Registry $registry */
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$registry = $objectManager->get(\Magento\Framework\Registry::class);
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', true);
|
||||
|
||||
$productRepository = $objectManager->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
|
||||
/** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $collection */
|
||||
$collection = $objectManager->create(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
|
||||
foreach ($collection->getItems() as $product) {
|
||||
$productRepository->delete($product);
|
||||
}
|
||||
|
||||
/** @var \Magento\CatalogInventory\Model\StockRegistryStorage $stockRegistryStorage */
|
||||
$stockRegistryStorage = $objectManager->get(\Magento\CatalogInventory\Model\StockRegistryStorage::class);
|
||||
$stockRegistryStorage->clean();
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', false);
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\Catalog\Model\Product\Attribute\Source\Status;
|
||||
use Magento\Catalog\Model\Product\Type;
|
||||
use Magento\Catalog\Model\Product\Visibility;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
Bootstrap::getInstance()->reinitialize();
|
||||
|
||||
/** @var ProductRepositoryInterface $productRepository */
|
||||
$productRepository = Bootstrap::getObjectManager()
|
||||
->create(ProductRepositoryInterface::class);
|
||||
|
||||
$howManyProducts = 5;
|
||||
|
||||
foreach (range(1, $howManyProducts) as $productId) {
|
||||
$product = Bootstrap::getObjectManager()->create(Product::class);
|
||||
$product->setTypeId(Type::TYPE_SIMPLE)
|
||||
->setAttributeSetId(4)
|
||||
->setWebsiteIds([1])
|
||||
->setName('Cool short' . $productId)
|
||||
->setSku('cool_shorts_' . $productId)
|
||||
->setPrice(42)
|
||||
->setShortDescription("Some description about shorts")
|
||||
->setTaxClassId(0)
|
||||
->setDescription('Some description about <b>shorts</b>')
|
||||
->setVisibility(Visibility::VISIBILITY_BOTH)
|
||||
->setStatus(Status::STATUS_ENABLED)
|
||||
->setStockData(
|
||||
[
|
||||
'use_config_manage_stock' => 1,
|
||||
'qty' => 100,
|
||||
'is_qty_decimal' => 0,
|
||||
'is_in_stock' => 1,
|
||||
]
|
||||
);
|
||||
|
||||
$productRepository->save($product);
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
/** @var \Magento\Framework\Registry $registry */
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$registry = $objectManager->get(\Magento\Framework\Registry::class);
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', true);
|
||||
|
||||
/** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $collection */
|
||||
$collection = $objectManager->create(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
|
||||
$collection->addAttributeToSelect('id')->load();
|
||||
if ($collection->count() > 0) {
|
||||
$collection->delete();
|
||||
}
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', false);
|
||||
@@ -0,0 +1,446 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<requests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Search/etc/search_request_merged.xsd">
|
||||
<request query="one_match" index="catalogsearch_fulltext">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="boolQuery" name="one_match" boost="2">
|
||||
<queryReference clause="must" ref="fulltext_search_query"/>
|
||||
</query>
|
||||
|
||||
<query xsi:type="matchQuery" name="fulltext_search_query" value="$fulltext_search_query$" boost="5">
|
||||
<match field="data_index"/>
|
||||
</query>
|
||||
</queries>
|
||||
<from>0</from>
|
||||
<size>10</size>
|
||||
</request>
|
||||
<request query="one_aggregations" index="catalogsearch_fulltext">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="boolQuery" name="one_aggregations" boost="2">
|
||||
<queryReference clause="must" ref="fulltext_search_query"/>
|
||||
</query>
|
||||
|
||||
<query xsi:type="matchQuery" name="fulltext_search_query" value="$fulltext_search_query$" boost="5">
|
||||
<match field="data_index"/>
|
||||
</query>
|
||||
</queries>
|
||||
<aggregations>
|
||||
<bucket xsi:type="termBucket" name="weight_bucket" field="weight">
|
||||
<metrics>
|
||||
<metric type="count"/>
|
||||
</metrics>
|
||||
</bucket>
|
||||
<bucket xsi:type="rangeBucket" name="price_bucket" field="price">
|
||||
<metrics>
|
||||
<metric type="count"/>
|
||||
</metrics>
|
||||
<ranges>
|
||||
<range from="" to="14"/>
|
||||
<range from="14" to="18"/>
|
||||
<range from="18" to=""/>
|
||||
</ranges>
|
||||
</bucket>
|
||||
<bucket xsi:type="dynamicBucket" method="manual" name="dynamic_price" field="price" />
|
||||
</aggregations>
|
||||
<from>0</from>
|
||||
<size>10</size>
|
||||
</request>
|
||||
<request query="one_wildcard" index="catalogsearch_fulltext">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="filteredQuery" name="one_wildcard" boost="2">
|
||||
<filterReference clause="must" ref="wildcard_filter"/>
|
||||
</query>
|
||||
</queries>
|
||||
<filters>
|
||||
<filter xsi:type="wildcardFilter" name="wildcard_filter" value="$wildcard_filter$" field="name"/>
|
||||
</filters>
|
||||
<from>0</from>
|
||||
<size>10</size>
|
||||
</request>
|
||||
<request query="one_match_filters" index="catalogsearch_fulltext">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="boolQuery" name="one_match_filters" boost="2">
|
||||
<queryReference clause="must" ref="fulltext_search_query"/>
|
||||
<queryReference clause="must" ref="filtered_query"/>
|
||||
<queryReference clause="must" ref="filtered_query_rm"/>
|
||||
<queryReference clause="must" ref="filtered_query_filter_rm"/>
|
||||
</query>
|
||||
<query xsi:type="matchQuery" name="fulltext_search_query" value="$fulltext_search_query$" boost="5">
|
||||
<match field="data_index"/>
|
||||
</query>
|
||||
<query xsi:type="filteredQuery" name="filtered_query">
|
||||
<filterReference clause="must" ref="pid"/>
|
||||
</query>
|
||||
<query xsi:type="filteredQuery" name="filtered_query_rm">
|
||||
<queryReference clause= "must" ref="fulltext_search_query_rm"/>
|
||||
</query>
|
||||
<query xsi:type="filteredQuery" name="filtered_query_filter_rm">
|
||||
<filterReference clause="must" ref="bool_filter_rm"/>
|
||||
</query>
|
||||
<query xsi:type="matchQuery" value="$not_bind$" name="fulltext_search_query_rm">
|
||||
<match field="some"/>
|
||||
</query>
|
||||
</queries>
|
||||
<filters>
|
||||
<filter xsi:type="boolFilter" name="bool_filter_rm">
|
||||
<filterReference clause="must" ref="term_rm"/>
|
||||
<filterReference clause="must" ref="range_rm"/>
|
||||
</filter>
|
||||
<filter name="range_rm" xsi:type="rangeFilter" field="price" from="$not_bind$" to="$not_bind$"/>
|
||||
<filter name="term_rm" xsi:type="termFilter" field="price" value="$not_bind$"/>
|
||||
<filter xsi:type="boolFilter" name="pid">
|
||||
<filterReference clause="should" ref="pidm"/>
|
||||
<filterReference clause="should" ref="pidsh"/>
|
||||
</filter>
|
||||
<filter name="pidm" xsi:type="rangeFilter" field="price" from="$pidm_from$" to="$pidm_to$"/>
|
||||
<filter name="pidsh" xsi:type="termFilter" field="price" value="$pidsh$"/>
|
||||
</filters>
|
||||
<from>0</from>
|
||||
<size>10</size>
|
||||
</request>
|
||||
<request query="range_filter" index="catalogsearch_fulltext">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="filteredQuery" name="range_filter">
|
||||
<filterReference clause="must" ref="range_filter"/>
|
||||
</query>
|
||||
</queries>
|
||||
<filters>
|
||||
<filter name="range_filter"
|
||||
xsi:type="rangeFilter"
|
||||
field="price"
|
||||
from="$range_filter_from$"
|
||||
to="$range_filter_to$"/>
|
||||
</filters>
|
||||
<from>0</from>
|
||||
<size>10</size>
|
||||
</request>
|
||||
<request query="range_filter_without_from_field" index="catalogsearch_fulltext">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="filteredQuery" name="range_filter_without_from_field">
|
||||
<filterReference clause="must" ref="range_filter_without_from_field"/>
|
||||
</query>
|
||||
</queries>
|
||||
<filters>
|
||||
<filter name="range_filter_without_from_field"
|
||||
xsi:type="rangeFilter"
|
||||
field="price"
|
||||
to="$range_filter_to$"/>
|
||||
</filters>
|
||||
<from>0</from>
|
||||
<size>10</size>
|
||||
</request>
|
||||
<request query="range_filter_without_to_field" index="catalogsearch_fulltext">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="filteredQuery" name="range_filter_without_to_field">
|
||||
<filterReference clause="must" ref="range_filter_without_to_field"/>
|
||||
</query>
|
||||
</queries>
|
||||
<filters>
|
||||
<filter name="range_filter_without_to_field"
|
||||
xsi:type="rangeFilter"
|
||||
field="price"
|
||||
from="$range_filter_from$"/>
|
||||
</filters>
|
||||
<from>0</from>
|
||||
<size>10</size>
|
||||
</request>
|
||||
<request query="term_filter" index="catalogsearch_fulltext">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="filteredQuery" name="term_filter">
|
||||
<filterReference clause="must" ref="term_filter"/>
|
||||
</query>
|
||||
</queries>
|
||||
<filters>
|
||||
<filter name="term_filter" xsi:type="termFilter" field="price" value="$request.price$"/>
|
||||
</filters>
|
||||
<from>0</from>
|
||||
<size>10</size>
|
||||
</request>
|
||||
<request query="bool_filter" index="catalogsearch_fulltext">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="filteredQuery" name="bool_filter">
|
||||
<filterReference clause="must" ref="bool_filter"/>
|
||||
</query>
|
||||
</queries>
|
||||
<filters>
|
||||
<filter xsi:type="boolFilter" name="bool_filter">
|
||||
<filterReference clause="must" ref="must_range_filter1"/>
|
||||
<filterReference clause="should" ref="should_term_filter1"/>
|
||||
<filterReference clause="should" ref="should_term_filter2"/>
|
||||
<filterReference clause="should" ref="should_term_filter3"/>
|
||||
<filterReference clause="should" ref="should_term_filter4"/>
|
||||
<filterReference clause="not" ref="not_term_filter1"/>
|
||||
<filterReference clause="not" ref="not_term_filter2"/>
|
||||
</filter>
|
||||
<filter name="must_range_filter1"
|
||||
xsi:type="rangeFilter"
|
||||
field="price"
|
||||
from="$must_range_filter1_from$"
|
||||
to="$must_range_filter1_to$"/>
|
||||
<filter name="should_term_filter1"
|
||||
xsi:type="termFilter"
|
||||
field="price"
|
||||
value="$should_term_filter1$"/>
|
||||
<filter name="should_term_filter2"
|
||||
xsi:type="termFilter"
|
||||
field="price"
|
||||
value="$should_term_filter2$"/>
|
||||
<filter name="should_term_filter3"
|
||||
xsi:type="termFilter"
|
||||
field="price"
|
||||
value="$should_term_filter3$"/>
|
||||
<filter name="should_term_filter4"
|
||||
xsi:type="termFilter"
|
||||
field="price"
|
||||
value="$should_term_filter4$"/>
|
||||
<filter name="not_term_filter1"
|
||||
xsi:type="termFilter"
|
||||
field="price"
|
||||
value="$not_term_filter1$"/>
|
||||
<filter name="not_term_filter2"
|
||||
xsi:type="termFilter"
|
||||
field="price"
|
||||
value="$not_term_filter2$"/>
|
||||
</filters>
|
||||
<from>0</from>
|
||||
<size>10</size>
|
||||
</request>
|
||||
<request query="bool_filter_with_nested_bool_filter" index="catalogsearch_fulltext">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="filteredQuery" name="bool_filter_with_nested_bool_filter">
|
||||
<filterReference clause="must" ref="bool_filter_with_nested_bool_filter"/>
|
||||
</query>
|
||||
</queries>
|
||||
<filters>
|
||||
<filter xsi:type="boolFilter" name="bool_filter_with_nested_bool_filter">
|
||||
<filterReference clause="not" ref="not_range_filter"/>
|
||||
<filterReference clause="not" ref="not_bool_filter"/>
|
||||
</filter>
|
||||
<filter xsi:type="boolFilter" name="not_bool_filter">
|
||||
<filterReference clause="not" ref="nested_not_term_filter"/>
|
||||
</filter>
|
||||
<filter name="not_range_filter"
|
||||
xsi:type="rangeFilter"
|
||||
field="price"
|
||||
from="$not_range_filter_from$"
|
||||
to="$not_range_filter_to$"/>
|
||||
<filter name="nested_not_term_filter"
|
||||
xsi:type="termFilter"
|
||||
field="price"
|
||||
value="$nested_not_term_filter$"/>
|
||||
</filters>
|
||||
<from>0</from>
|
||||
<size>10</size>
|
||||
</request>
|
||||
<request query="bool_filter_with_range_in_nested_negative_filter" index="catalogsearch_fulltext">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="filteredQuery" name="bool_filter_with_range_in_nested_negative_filter">
|
||||
<filterReference clause="must" ref="bool_filter_with_range_in_nested_negative_filter"/>
|
||||
</query>
|
||||
</queries>
|
||||
<filters>
|
||||
<filter xsi:type="boolFilter" name="bool_filter_with_range_in_nested_negative_filter">
|
||||
<filterReference clause="not" ref="not_bool_filter"/>
|
||||
</filter>
|
||||
<filter xsi:type="boolFilter" name="not_bool_filter">
|
||||
<filterReference clause="must" ref="nested_must_range_filter"/>
|
||||
</filter>
|
||||
<filter name="nested_must_range_filter"
|
||||
xsi:type="rangeFilter"
|
||||
field="price"
|
||||
from="$nested_must_range_filter_from$"
|
||||
to="$nested_must_range_filter_to$"/>
|
||||
</filters>
|
||||
<from>0</from>
|
||||
<size>10</size>
|
||||
</request>
|
||||
<request query="advanced_search_test" index="catalogsearch_fulltext">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="boolQuery" name="advanced_search_test" boost="1">
|
||||
<queryReference clause="should" ref="name_query"/>
|
||||
<queryReference clause="should" ref="description_query"/>
|
||||
<queryReference clause="should" ref="query_filter"/>
|
||||
</query>
|
||||
<query xsi:type="matchQuery" name="name_query" value="$name_query$">
|
||||
<match field="data_index"/>
|
||||
</query>
|
||||
<query xsi:type="matchQuery" name="description_query" value="$description_query$">
|
||||
<match field="data_index"/>
|
||||
</query>
|
||||
<query xsi:type="filteredQuery" name="query_filter">
|
||||
<filterReference clause="must" ref="filter"/>
|
||||
</query>
|
||||
</queries>
|
||||
<filters>
|
||||
<filter xsi:type="boolFilter" name="filter">
|
||||
<filterReference clause="must" ref="price_filter"/>
|
||||
</filter>
|
||||
<filter name="price_filter" xsi:type="rangeFilter" field="price" from="$request.from_price$" to="$request.to_price$"/>
|
||||
</filters>
|
||||
<from>0</from>
|
||||
<size>10</size>
|
||||
</request>
|
||||
<request query="filterable_custom_attributes" index="catalogsearch_fulltext">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="boolQuery" name="filterable_custom_attributes" boost="1">
|
||||
<queryReference clause="must" ref="category"/>
|
||||
<queryReference clause="must" ref="price"/>
|
||||
<queryReference clause="must" ref="select_attribute"/>
|
||||
<queryReference clause="must" ref="multiselect_attribute"/>
|
||||
</query>
|
||||
<query xsi:type="filteredQuery" name="category">
|
||||
<filterReference clause="must" ref="category_filter"/>
|
||||
</query>
|
||||
<query xsi:type="filteredQuery" name="price">
|
||||
<filterReference clause="must" ref="price_filter"/>
|
||||
</query>
|
||||
<query xsi:type="filteredQuery" name="select_attribute">
|
||||
<filterReference clause="must" ref="select_attribute_filter"/>
|
||||
</query>
|
||||
<query xsi:type="filteredQuery" name="multiselect_attribute">
|
||||
<filterReference clause="must" ref="multiselect_attribute_filter"/>
|
||||
</query>
|
||||
</queries>
|
||||
<filters>
|
||||
<filter xsi:type="termFilter" name="category_filter" field="category_ids" value="$category_ids$"/>
|
||||
<filter xsi:type="rangeFilter" name="price_filter" field="price" from="$price.from$" to="$price.to$"/>
|
||||
<filter xsi:type="termFilter" name="select_attribute_filter" field="select_attribute" value="$select_attribute$"/>
|
||||
<filter xsi:type="termFilter" name="multiselect_attribute_filter" field="multiselect_attribute" value="$multiselect_attribute$"/>
|
||||
</filters>
|
||||
<aggregations>
|
||||
<bucket name="price_bucket" field="price" xsi:type="dynamicBucket" method="$price_dynamic_algorithm$">
|
||||
<metrics>
|
||||
<metric type="count"/>
|
||||
</metrics>
|
||||
</bucket>
|
||||
<bucket name="category_bucket" field="category_ids" xsi:type="termBucket">
|
||||
<metrics>
|
||||
<metric type="count"/>
|
||||
</metrics>
|
||||
</bucket>
|
||||
</aggregations>
|
||||
<from>0</from>
|
||||
<size>10</size>
|
||||
</request>
|
||||
<request query="advanced_search_date_field" index="catalogsearch_fulltext">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="boolQuery" name="advanced_search_date_field" boost="1">
|
||||
<queryReference clause="should" ref="query_filter"/>
|
||||
</query>
|
||||
<query xsi:type="filteredQuery" name="query_filter">
|
||||
<filterReference clause="must" ref="filter"/>
|
||||
</query>
|
||||
</queries>
|
||||
<filters>
|
||||
<filter xsi:type="boolFilter" name="filter">
|
||||
<filterReference clause="must" ref="date_filter"/>
|
||||
</filter>
|
||||
<filter name="date_filter" xsi:type="rangeFilter" field="date_attribute" from="$date.from$" to="$date.to$"/>
|
||||
</filters>
|
||||
<from>0</from>
|
||||
<size>10</size>
|
||||
</request>
|
||||
<request query="filter_out_of_stock_child" index="catalogsearch_fulltext">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="boolQuery" name="filter_out_of_stock_child" boost="1">
|
||||
<queryReference clause="must" ref="test_configurable"/>
|
||||
<queryReference clause="must" ref="visibility"/>
|
||||
</query>
|
||||
<query xsi:type="filteredQuery" name="test_configurable">
|
||||
<filterReference clause="must" ref="test_configurable_filter"/>
|
||||
</query>
|
||||
<query xsi:type="filteredQuery" name="visibility">
|
||||
<filterReference clause="must" ref="visibility_filter"/>
|
||||
</query>
|
||||
</queries>
|
||||
<filters>
|
||||
<filter xsi:type="termFilter" name="test_configurable_filter" field="test_configurable" value="$test_configurable$"/>
|
||||
<filter xsi:type="termFilter" name="visibility_filter" field="visibility" value="$visibility$"/>
|
||||
</filters>
|
||||
<aggregations/>
|
||||
<from>0</from>
|
||||
<size>10</size>
|
||||
</request>
|
||||
<request query="search_boost" index="catalogsearch_fulltext">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="boolQuery" name="search_boost" boost="1">
|
||||
<queryReference clause="should" ref="search_boost_query"/>
|
||||
</query>
|
||||
<query xsi:type="matchQuery" name="search_boost_query" value="$query$" boost="1">
|
||||
<match field="name"/>
|
||||
<match field="description"/>
|
||||
</query>
|
||||
</queries>
|
||||
<from>0</from>
|
||||
<size>10</size>
|
||||
</request>
|
||||
<request query="search_boost_name" index="catalogsearch_fulltext">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default"/>
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="boolQuery" name="search_boost_name" boost="1">
|
||||
<queryReference clause="should" ref="search_boost_query"/>
|
||||
</query>
|
||||
<query xsi:type="matchQuery" name="search_boost_query" value="$query$" boost="20">
|
||||
<match field="name"/>
|
||||
<match field="description"/>
|
||||
</query>
|
||||
</queries>
|
||||
<from>0</from>
|
||||
<size>10</size>
|
||||
</request>
|
||||
</requests>
|
||||
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<requests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Search/etc/search_request_merged.xsd">
|
||||
<request query="suggested_search_container" index="product">
|
||||
<dimensions>
|
||||
<dimension name="scope" value="default" />
|
||||
</dimensions>
|
||||
<queries>
|
||||
<query xsi:type="boolQuery" name="suggested_search_container" boost="2">
|
||||
<queryReference clause="must" ref="fulltext_search_query" />
|
||||
<queryReference clause="should" ref="fulltext_search_query2" />
|
||||
</query>
|
||||
|
||||
<query xsi:type="matchQuery" name="fulltext_search_query" value="default_value" boost="5">
|
||||
<match field="title" boost="2" />
|
||||
<match field="description" />
|
||||
</query>
|
||||
|
||||
<query xsi:type="filteredQuery" name="fulltext_search_query2">
|
||||
<filterReference clause="must" ref="promoted" />
|
||||
</query>
|
||||
</queries>
|
||||
<filters>
|
||||
<filter xsi:type="boolFilter" name="promoted">
|
||||
<filterReference clause="must" ref="price_name" />
|
||||
<filterReference clause="should" ref="price_name1" />
|
||||
</filter>
|
||||
<filter xsi:type="rangeFilter" field="promoted_boost" name="price_name" from="10" to="100" />
|
||||
<filter xsi:type="termFilter" name="price_name1" field="price_name" value="$name" />
|
||||
</filters>
|
||||
<aggregations>
|
||||
<bucket xsi:type="termBucket" name="category_bucket" field="category">
|
||||
<metrics>
|
||||
<metric type="sum" />
|
||||
<metric type="count" />
|
||||
<metric type="min" />
|
||||
<metric type="max" />
|
||||
</metrics>
|
||||
</bucket>
|
||||
<bucket xsi:type="rangeBucket" name="price_bucket" field="price">
|
||||
<metrics>
|
||||
<metric type="sum" />
|
||||
<metric type="count" />
|
||||
<metric type="min" />
|
||||
<metric type="max" />
|
||||
</metrics>
|
||||
<ranges>
|
||||
<range from="" to="50" />
|
||||
<range from="50" to="100" />
|
||||
<range from="100" to=""/>
|
||||
</ranges>
|
||||
</bucket>
|
||||
<bucket xsi:type="dynamicBucket" method="auto" name="dynamic_bucket" field="price" />
|
||||
</aggregations>
|
||||
<from>10</from>
|
||||
<size>10</size>
|
||||
</request>
|
||||
</requests>
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
return [
|
||||
"suggested_search_container" => [
|
||||
"dimensions" => [
|
||||
"scope" => [
|
||||
"name" => "scope",
|
||||
"value" => "default",
|
||||
],
|
||||
],
|
||||
"queries" => [
|
||||
"suggested_search_container" => [
|
||||
"name" => "suggested_search_container",
|
||||
"boost" => "2",
|
||||
"queryReference" => [
|
||||
[
|
||||
"clause" => "must",
|
||||
"ref" => "fulltext_search_query",
|
||||
],
|
||||
[
|
||||
"clause" => "should",
|
||||
"ref" => "fulltext_search_query2"
|
||||
],
|
||||
],
|
||||
"type" => "boolQuery",
|
||||
],
|
||||
"fulltext_search_query" => [
|
||||
"name" => "fulltext_search_query",
|
||||
"boost" => "5",
|
||||
"value" => "default_value",
|
||||
"match" => [
|
||||
[
|
||||
"field" => "title",
|
||||
"boost" => "2",
|
||||
],
|
||||
[
|
||||
"field" => "description"
|
||||
],
|
||||
],
|
||||
"type" => "matchQuery",
|
||||
],
|
||||
"fulltext_search_query2" => [
|
||||
"name" => "fulltext_search_query2",
|
||||
"filterReference" => [
|
||||
[
|
||||
'clause' => 'must',
|
||||
"ref" => "promoted",
|
||||
],
|
||||
],
|
||||
"type" => "filteredQuery",
|
||||
],
|
||||
],
|
||||
"filters" => [
|
||||
"promoted" => [
|
||||
"name" => "promoted",
|
||||
"filterReference" => [
|
||||
[
|
||||
"clause" => "must",
|
||||
"ref" => "price_name",
|
||||
],
|
||||
[
|
||||
"clause" => "should",
|
||||
"ref" => "price_name1"
|
||||
],
|
||||
],
|
||||
"type" => "boolFilter",
|
||||
],
|
||||
"price_name" => [
|
||||
"field" => "promoted_boost",
|
||||
"name" => "price_name",
|
||||
"from" => "10",
|
||||
"to" => "100",
|
||||
"type" => "rangeFilter",
|
||||
],
|
||||
"price_name1" => [
|
||||
"name" => "price_name1",
|
||||
"field" => "price_name",
|
||||
"value" => "\$name",
|
||||
"type" => "termFilter",
|
||||
],
|
||||
],
|
||||
"aggregations" => [
|
||||
"category_bucket" => [
|
||||
"name" => "category_bucket",
|
||||
"field" => "category",
|
||||
"metric" => [
|
||||
[
|
||||
"type" => "sum",
|
||||
],
|
||||
[
|
||||
"type" => "count",
|
||||
],
|
||||
[
|
||||
"type" => "min",
|
||||
],
|
||||
[
|
||||
"type" => "max",
|
||||
],
|
||||
],
|
||||
"type" => "termBucket",
|
||||
],
|
||||
"price_bucket" => [
|
||||
"name" => "price_bucket",
|
||||
"field" => "price",
|
||||
"metric" => [
|
||||
[
|
||||
"type" => "sum",
|
||||
],
|
||||
[
|
||||
"type" => "count",
|
||||
],
|
||||
[
|
||||
"type" => "min",
|
||||
],
|
||||
[
|
||||
"type" => "max",
|
||||
],
|
||||
],
|
||||
"range" => [
|
||||
[
|
||||
"from" => "",
|
||||
"to" => "50",
|
||||
],
|
||||
[
|
||||
"from" => "50",
|
||||
"to" => "100",
|
||||
],
|
||||
[
|
||||
"from" => "100",
|
||||
"to" => "",
|
||||
],
|
||||
],
|
||||
"type" => "rangeBucket",
|
||||
],
|
||||
'dynamic_bucket' => [
|
||||
'name' => 'dynamic_bucket',
|
||||
'field' => 'price',
|
||||
'method' => 'auto',
|
||||
'type' => 'dynamicBucket'
|
||||
]
|
||||
],
|
||||
"from" => "10",
|
||||
"size" => "10",
|
||||
"query" => "suggested_search_container",
|
||||
"index" => "product",
|
||||
]
|
||||
];
|
||||
+249
@@ -0,0 +1,249 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
return [
|
||||
'bool_query' => [
|
||||
'dimensions' => [
|
||||
'scope' =>
|
||||
[
|
||||
'name' => 'scope',
|
||||
'value' => 'default_override',
|
||||
],
|
||||
],
|
||||
'queries' => [
|
||||
'bool_query' => [
|
||||
'name' => 'bool_query',
|
||||
'boost' => '10',
|
||||
'queryReference' => [
|
||||
0 => [
|
||||
'clause' => 'must',
|
||||
'ref' => 'must_query',
|
||||
],
|
||||
1 => [
|
||||
'clause' => 'should',
|
||||
'ref' => 'should_query',
|
||||
],
|
||||
2 => [
|
||||
'clause' => 'not',
|
||||
'ref' => 'not_query',
|
||||
],
|
||||
],
|
||||
'type' => 'boolQuery',
|
||||
],
|
||||
'match_query' => [
|
||||
'value' => '$match_term_override$',
|
||||
'name' => 'match_query',
|
||||
'match' => [
|
||||
0 => [
|
||||
'field' => 'match_field',
|
||||
],
|
||||
1 => [
|
||||
'field' => '*',
|
||||
],
|
||||
2 => [
|
||||
'field' => 'match_field_3',
|
||||
],
|
||||
],
|
||||
'type' => 'matchQuery',
|
||||
],
|
||||
'must_query' => [
|
||||
'name' => 'must_query',
|
||||
'filterReference' => [
|
||||
0 => [
|
||||
'clause' => 'must',
|
||||
'ref' => 'must_filter',
|
||||
],
|
||||
],
|
||||
'type' => 'filteredQuery',
|
||||
],
|
||||
'should_query' => [
|
||||
'name' => 'should_query',
|
||||
'filterReference' => [
|
||||
0 => [
|
||||
'clause' => 'should',
|
||||
'ref' => 'should_filter',
|
||||
],
|
||||
],
|
||||
'type' => 'filteredQuery',
|
||||
],
|
||||
'not_query' => [
|
||||
'name' => 'not_query',
|
||||
'filterReference' => [
|
||||
0 => [
|
||||
'clause' => 'not',
|
||||
'ref' => 'not_filter',
|
||||
],
|
||||
],
|
||||
'type' => 'filteredQuery',
|
||||
],
|
||||
'match_query_2' => [
|
||||
'value' => '$match_term_override$',
|
||||
'name' => 'match_query_2',
|
||||
'match' => [
|
||||
0 => [
|
||||
'field' => 'match_field_4',
|
||||
],
|
||||
],
|
||||
'type' => 'matchQuery',
|
||||
],
|
||||
],
|
||||
'filters' => [
|
||||
'must_filter' => [
|
||||
'name' => 'must_filter',
|
||||
'field' => 'field_1_override',
|
||||
'value' => '$value_1_override$',
|
||||
'type' => 'termFilter',
|
||||
],
|
||||
'should_filter' => [
|
||||
'name' => 'should_filter',
|
||||
'field' => 'field_2_override',
|
||||
'from' => '$value_2_override.from$',
|
||||
'to' => '$value_2_override.to$',
|
||||
'type' => 'rangeFilter',
|
||||
],
|
||||
'not_filter' => [
|
||||
'name' => 'not_filter',
|
||||
'field' => 'field_3_override',
|
||||
'value' => '$field_3_override$',
|
||||
'type' => 'wildcardFilter',
|
||||
],
|
||||
],
|
||||
'aggregations' => [
|
||||
'bucket_1' => [
|
||||
'name' => 'bucket_1',
|
||||
'field' => 'field_1_override',
|
||||
'method' => '$field_1_dynamic_algorithm_override$',
|
||||
'metric' => [
|
||||
0 =>
|
||||
[
|
||||
'type' => 'count',
|
||||
],
|
||||
],
|
||||
'type' => 'dynamicBucket',
|
||||
],
|
||||
'bucket_2' => [
|
||||
'name' => 'bucket_2',
|
||||
'field' => 'field_2_override',
|
||||
'metric' => [
|
||||
0 =>
|
||||
[
|
||||
'type' => 'count',
|
||||
],
|
||||
],
|
||||
'type' => 'termBucket',
|
||||
],
|
||||
'bucket_3' => [
|
||||
'name' => 'bucket_3',
|
||||
'field' => 'field_2_override',
|
||||
'range' => [
|
||||
0 =>
|
||||
[
|
||||
'from' => '$value_2_override.from$',
|
||||
'to' => 'value_2_override.to$',
|
||||
],
|
||||
],
|
||||
'type' => 'rangeBucket',
|
||||
],
|
||||
],
|
||||
'from' => '0',
|
||||
'size' => '10000',
|
||||
'query' => 'bool_query',
|
||||
'index' => 'bool_query_index_override',
|
||||
],
|
||||
'filter_query' => [
|
||||
'dimensions' => [
|
||||
'scope' =>
|
||||
[
|
||||
'name' => 'scope',
|
||||
'value' => 'default_override',
|
||||
],
|
||||
],
|
||||
'queries' => [
|
||||
'filter_query' => [
|
||||
'name' => 'filter_query',
|
||||
'filterReference' => [
|
||||
0 =>
|
||||
[
|
||||
'clause' => 'must',
|
||||
'ref' => 'bool_filter',
|
||||
],
|
||||
],
|
||||
'type' => 'filteredQuery',
|
||||
],
|
||||
],
|
||||
'filters' => [
|
||||
'bool_filter' => [
|
||||
'name' => 'bool_filter',
|
||||
'filterReference' => [
|
||||
0 => [
|
||||
'clause' => 'must',
|
||||
'ref' => 'must_filter',
|
||||
],
|
||||
1 => [
|
||||
'clause' => 'should',
|
||||
'ref' => 'should_filter',
|
||||
],
|
||||
2 => [
|
||||
'clause' => 'not',
|
||||
'ref' => 'not_filter',
|
||||
],
|
||||
],
|
||||
'type' => 'boolFilter',
|
||||
],
|
||||
'must_filter' => [
|
||||
'name' => 'must_filter',
|
||||
'field' => 'field_1',
|
||||
'value' => '$value_1$',
|
||||
'type' => 'termFilter',
|
||||
],
|
||||
'should_filter' => [
|
||||
'name' => 'should_filter',
|
||||
'field' => 'field_2',
|
||||
'from' => '$value_2.from$',
|
||||
'to' => '$value_2.to$',
|
||||
'type' => 'rangeFilter',
|
||||
],
|
||||
'not_filter' => [
|
||||
'name' => 'not_filter',
|
||||
'field' => 'field_3',
|
||||
'value' => '$field_3$',
|
||||
'type' => 'wildcardFilter',
|
||||
],
|
||||
],
|
||||
'from' => '0',
|
||||
'size' => '10000',
|
||||
'query' => 'filter_query',
|
||||
'index' => 'filter_query_index_override',
|
||||
'aggregations' => [],
|
||||
],
|
||||
'new_match_query' => [
|
||||
'dimensions' => [
|
||||
'scope' =>
|
||||
[
|
||||
'name' => 'scope',
|
||||
'value' => 'new',
|
||||
],
|
||||
],
|
||||
'queries' => [
|
||||
'new_match_query' => [
|
||||
'value' => '$match_term$',
|
||||
'name' => 'new_match_query',
|
||||
'match' => [
|
||||
0 =>
|
||||
[
|
||||
'field' => 'new_match_field',
|
||||
],
|
||||
],
|
||||
'type' => 'matchQuery',
|
||||
],
|
||||
],
|
||||
'filters' => [],
|
||||
'from' => '0',
|
||||
'size' => '10000',
|
||||
'query' => 'new_match_query',
|
||||
'index' => 'new_query_index',
|
||||
'aggregations' => [],
|
||||
],
|
||||
];
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*
|
||||
*/
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
|
||||
/** @var ProductRepositoryInterface $productRepository */
|
||||
$productRepository = $objectManager->create(ProductRepositoryInterface::class);
|
||||
|
||||
/** @var $productWithMatchInTitle \Magento\Catalog\Model\Product */
|
||||
$productWithMatchInTitle = $objectManager->create(\Magento\Catalog\Model\Product::class);
|
||||
$productWithMatchInTitle->isObjectNew(true);
|
||||
$productWithMatchInTitle->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
|
||||
->setId(1221)
|
||||
->setAttributeSetId(4)
|
||||
->setWebsiteIds([1])
|
||||
->setName('Antarctica Lorem ipsum dolor sit amet, consectetur adipiscing elit')
|
||||
->setSku('search_weight_1')
|
||||
->setPrice(12)
|
||||
->setWeight(1)
|
||||
->setDescription('Lorem ipsum dolor sit amet, consectetur adipiscing elit')
|
||||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
|
||||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
|
||||
->setCategoryIds([2])
|
||||
->setStockData(
|
||||
[
|
||||
'use_config_manage_stock' => 1,
|
||||
'qty' => 100,
|
||||
'is_qty_decimal' => 0,
|
||||
'is_in_stock' => 1,
|
||||
]
|
||||
);
|
||||
|
||||
$productRepository->save($productWithMatchInTitle);
|
||||
|
||||
$productWithMatchInDescription = $objectManager->create(\Magento\Catalog\Model\Product::class);
|
||||
$productWithMatchInDescription->isObjectNew(true);
|
||||
$productWithMatchInDescription->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
|
||||
->setId(1222)
|
||||
->setAttributeSetId(4)
|
||||
->setWebsiteIds([1])
|
||||
->setName('Lorem ipsum dolor sit amet, consectetur adipiscing elit')
|
||||
->setSku('search_weight_2')
|
||||
->setPrice(12)
|
||||
->setWeight(1)
|
||||
->setDescription('Lorem ipsum antarctica dolor sit amet, consectetur antarctica adipiscing elit')
|
||||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
|
||||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
|
||||
->setCategoryIds([2])
|
||||
->setStockData(
|
||||
[
|
||||
'use_config_manage_stock' => 1,
|
||||
'qty' => 100,
|
||||
'is_qty_decimal' => 0,
|
||||
'is_in_stock' => 1,
|
||||
]
|
||||
);
|
||||
|
||||
$productRepository->save($productWithMatchInDescription);
|
||||
|
||||
/** @var \Magento\Catalog\Api\ProductAttributeRepositoryInterface $productAttributeRepository */
|
||||
$productAttributeRepository = $objectManager->get(
|
||||
\Magento\Catalog\Api\ProductAttributeRepositoryInterface::class
|
||||
);
|
||||
|
||||
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $nameAttribute */
|
||||
$nameAttribute = $productAttributeRepository->get('name');
|
||||
$nameAttribute->setSearchWeight(1);
|
||||
$productAttributeRepository->save($nameAttribute);
|
||||
|
||||
$descriptionAttribute = $productAttributeRepository->get('description');
|
||||
$descriptionAttribute->setSearchWeight(1);
|
||||
$productAttributeRepository->save($descriptionAttribute);
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @var \Magento\Framework\Registry $registry */
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$registry = $objectManager->get(\Magento\Framework\Registry::class);
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', true);
|
||||
|
||||
/** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $collection */
|
||||
$collection = $objectManager->create(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
|
||||
$collection->addAttributeToSelect('id')->load();
|
||||
if ($collection->count() > 0) {
|
||||
$collection->delete();
|
||||
}
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', false);
|
||||
|
||||
/** @var \Magento\Catalog\Api\ProductAttributeRepositoryInterface $productAttributeRepository */
|
||||
$productAttributeRepository = $objectManager->get(
|
||||
\Magento\Catalog\Api\ProductAttributeRepositoryInterface::class
|
||||
);
|
||||
|
||||
$nameAttribute = $productAttributeRepository->get('name');
|
||||
$nameAttribute->setSearchWeight(5);
|
||||
$productAttributeRepository->save($nameAttribute);
|
||||
|
||||
$descriptionAttribute = $productAttributeRepository->get('description');
|
||||
$descriptionAttribute->setSearchWeight(1);
|
||||
$productAttributeRepository->save($descriptionAttribute);
|
||||
Reference in New Issue
Block a user