Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-elasticsearch
SearchAdapter
DocumentFactory.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Elasticsearch\SearchAdapter
;
7
8
use
Magento\Framework\ObjectManagerInterface
;
9
use
Magento\Framework\Search\EntityMetadata
;
10
use
Magento\Framework\Api\AttributeInterface
;
11
use
Magento\Framework\Api\AttributeValue
;
12
use
Magento\Framework\Api\CustomAttributesDataInterface
;
13
use
Magento\Framework\Api\Search\Document
;
14
use
Magento\Framework\Api\Search\DocumentInterface
;
15
21
class
DocumentFactory
22
{
30
protected
$objectManager
;
31
35
private
$entityMetadata;
36
41
public
function
__construct
(
ObjectManagerInterface
$objectManager
,
EntityMetadata
$entityMetadata)
42
{
43
$this->objectManager =
$objectManager
;
44
$this->entityMetadata = $entityMetadata;
45
}
46
54
public
function
create($rawDocument)
55
{
57
$attributes
= [];
58
$documentId =
null
;
59
$entityId = $this->entityMetadata->getEntityId();
60
foreach
($rawDocument as $fieldName =>
$value
) {
61
if
($fieldName === $entityId) {
62
$documentId =
$value
;
63
}
elseif
($fieldName ===
'_score'
) {
64
$attributes
[
'score'
] =
new
AttributeValue(
65
[
66
AttributeInterface::ATTRIBUTE_CODE
=> $fieldName,
67
AttributeInterface::VALUE
=>
$value
,
68
]
69
);
70
}
71
}
72
73
return
new
Document(
74
[
75
DocumentInterface::ID
=> $documentId,
76
CustomAttributesDataInterface::CUSTOM_ATTRIBUTES
=>
$attributes
,
77
]
78
);
79
}
80
}
Magento\Framework\Search\EntityMetadata
Definition:
EntityMetadata.php:14
Magento\Elasticsearch\SearchAdapter\DocumentFactory\$objectManager
$objectManager
Definition:
DocumentFactory.php:30
Magento\Elasticsearch\SearchAdapter\DocumentFactory
Definition:
DocumentFactory.php:21
elseif
elseif(isset( $params[ 'redirect_parent']))
Definition:
iframe.phtml:17
Magento\Framework\Api\AttributeInterface
Definition:
AttributeInterface.php:15
Magento\Framework\ObjectManagerInterface
Definition:
ObjectManagerInterface.php:12
Magento\Framework\Api\Search\DocumentInterface
Definition:
DocumentInterface.php:14
Magento\Framework\Api\CustomAttributesDataInterface\CUSTOM_ATTRIBUTES
const CUSTOM_ATTRIBUTES
Definition:
CustomAttributesDataInterface.php:20
Magento\Framework\Api\AttributeValue
Definition:
AttributeValue.php:12
$value
$value
Definition:
gender.phtml:16
Magento\Framework\Api\AttributeInterface\ATTRIBUTE_CODE
const ATTRIBUTE_CODE
Definition:
AttributeInterface.php:20
$attributes
$attributes
Definition:
matrix.phtml:13
Magento\Framework\Api\CustomAttributesDataInterface
Definition:
CustomAttributesDataInterface.php:15
Magento\Framework\Api\Search\DocumentInterface\ID
const ID
Definition:
DocumentInterface.php:16
Magento\Framework\Api\AttributeInterface\VALUE
const VALUE
Definition:
AttributeInterface.php:21
Magento\Elasticsearch\SearchAdapter\DocumentFactory\__construct
__construct(ObjectManagerInterface $objectManager, EntityMetadata $entityMetadata)
Definition:
DocumentFactory.php:41
Magento\Elasticsearch\SearchAdapter
Definition:
AdapterTest.php:6
Magento\Framework\Api\Search\Document
Definition:
Document.php:14