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
framework
Search
Adapter
Mysql
ScoreBuilder.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Framework\Search\Adapter\Mysql
;
7
16
class
ScoreBuilder
17
{
21
private
$scoreCondition =
''
;
22
26
const
WEIGHT_FIELD
=
'search_weight'
;
27
33
public
function
getScoreAlias
()
34
{
35
return
'score'
;
36
}
37
43
public
function
build
()
44
{
45
$scoreCondition = $this->scoreCondition;
46
$this->clear();
47
$scoreAlias = $this->
getScoreAlias
();
48
49
return
"({$scoreCondition}) AS {$scoreAlias}"
;
50
}
51
57
public
function
startQuery
()
58
{
59
$this->addPlus();
60
$this->scoreCondition .=
'('
;
61
}
62
69
public
function
endQuery
($boost)
70
{
71
if
(!empty($this->scoreCondition) && substr($this->scoreCondition, -1) !==
'('
) {
72
$this->scoreCondition .=
") * {$boost}"
;
73
}
else
{
74
$this->scoreCondition .=
'0)'
;
75
}
76
}
77
85
public
function
addCondition
($score, $useWeights =
true
)
86
{
87
$this->addPlus();
88
$condition =
"{$score}"
;
89
if
($useWeights) {
90
$condition =
"LEAST(($condition), 1000000) * POW(2, "
. self::WEIGHT_FIELD .
')'
;
91
}
92
$this->scoreCondition .= $condition;
93
}
94
100
private
function
addPlus()
101
{
102
if
(!empty($this->scoreCondition) && substr($this->scoreCondition, -1) !==
'('
) {
103
$this->scoreCondition .=
' + '
;
104
}
105
}
106
112
private
function
clear()
113
{
114
$this->scoreCondition =
''
;
115
}
116
}
Magento\Framework\Search\Adapter\Mysql\ScoreBuilder\getScoreAlias
getScoreAlias()
Definition:
ScoreBuilder.php:33
Magento\Framework\Search\Adapter\Mysql\ScoreBuilder\WEIGHT_FIELD
const WEIGHT_FIELD
Definition:
ScoreBuilder.php:26
Magento\Framework\Search\Adapter\Mysql\ScoreBuilder\addCondition
addCondition($score, $useWeights=true)
Definition:
ScoreBuilder.php:85
Magento\Framework\Search\Adapter\Mysql\ScoreBuilder\build
build()
Definition:
ScoreBuilder.php:43
Magento\Framework\Search\Adapter\Mysql\ScoreBuilder\endQuery
endQuery($boost)
Definition:
ScoreBuilder.php:69
Magento\Framework\Search\Adapter\Mysql\ScoreBuilder
Definition:
ScoreBuilder.php:16
Magento\Framework\Search\Adapter\Mysql
Definition:
Adapter.php:6
Magento\Framework\Search\Adapter\Mysql\ScoreBuilder\startQuery
startQuery()
Definition:
ScoreBuilder.php:57