Skip to content

Commit

Permalink
fix with new php-cs-fixer v3
Browse files Browse the repository at this point in the history
  • Loading branch information
leemyongpakvn committed Nov 8, 2023
1 parent 4607c2d commit 03e1842
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 98 deletions.
6 changes: 3 additions & 3 deletions ps_facetedsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ public function indexProductPrices($idProduct, $smart = true)
null,
null,
$currency['id_currency'],
(($specificPrice['id_group'] == 0) ? null : $specificPrice['id_group']),
($specificPrice['id_group'] == 0) ? null : $specificPrice['id_group'],
$specificPrice['from_quantity'],
false,
6,
Expand Down Expand Up @@ -825,7 +825,7 @@ public function renderAdminTemplateEdit($template = null)
// Initialize category tree component
$treeCategoriesHelper = new HelperTreeCategories('categories-treeview');
$treeCategoriesHelper
->setRootCategory((Shop::getContext() == Shop::CONTEXT_SHOP ? Category::getRootCategory()->id_category : 0))
->setRootCategory(Shop::getContext() == Shop::CONTEXT_SHOP ? Category::getRootCategory()->id_category : 0)
->setUseCheckBox(true);

// If we are editing an already existing template, we will load its data,
Expand Down Expand Up @@ -1641,7 +1641,7 @@ private function indexPricesUnbreakable($cursor, $full = false, $smart = false,

$lastIdProduct = 0;
foreach ($this->getDatabase()->executeS($query) as $product) {
$this->indexProductPrices((int) $product['id_product'], ($smart && $full));
$this->indexProductPrices((int) $product['id_product'], $smart && $full);
$lastIdProduct = $product['id_product'];
}

Expand Down
8 changes: 4 additions & 4 deletions src/Filters/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function __construct(
DataAccessor $dataAccessor,
ProductSearchQuery $query,
Provider $provider
) {
) {
$this->searchAdapter = $searchAdapter;
$this->context = $context;
$this->database = $database;
Expand Down Expand Up @@ -578,9 +578,9 @@ private function getHighlightsBlock($filter, $selectedFilters)
$timeCondition = date(
'Y-m-d 00:00:00',
strtotime(
((int) Configuration::get('PS_NB_DAYS_NEW_PRODUCT') > 0 ?
(int) Configuration::get('PS_NB_DAYS_NEW_PRODUCT') > 0 ?
'-' . ((int) Configuration::get('PS_NB_DAYS_NEW_PRODUCT') - 1) . ' days' :
'+ 1 days')
'+ 1 days'
)
);
$filteredSearchAdapter->addFilter('date_add', ["'" . $timeCondition . "'"], '>');
Expand Down Expand Up @@ -911,7 +911,7 @@ private function getFeaturesBlock($filter, $selectedFilters, $idLang)
*/
private function sortFeatureBlock($featureBlock)
{
//Natural sort
// Natural sort
foreach ($featureBlock as $key => $value) {
$temp = [];
foreach ($featureBlock[$key]['values'] as $idFeatureValue => $featureValueInfos) {
Expand Down
56 changes: 28 additions & 28 deletions src/Filters/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,36 +354,36 @@ public function createFacetedSearchFiltersFromQuery(ProductSearchQuery $query)
}
break;
case self::TYPE_EXTRAS:
if (!isset($receivedFilters[$filterLabel])) {
// No need to filter if no information
continue 2;
}
if (!isset($receivedFilters[$filterLabel])) {
// No need to filter if no information
continue 2;
}

$extrasOptions = [
$this->context->getTranslator()->trans(
'New product',
[],
'Modules.Facetedsearch.Shop'
) => 'new',
$this->context->getTranslator()->trans(
'On sale',
[],
'Modules.Facetedsearch.Shop'
) => 'sale',
$this->context->getTranslator()->trans(
'Discounted',
[],
'Modules.Facetedsearch.Shop'
) => 'discount',
];

$searchFilters[$filter['type']] = [];
foreach ($extrasOptions as $extrasOption => $optionId) {
if (isset($receivedFilters[$filterLabel]) && in_array($extrasOption, $receivedFilters[$filterLabel])) {
$searchFilters[$filter['type']][] = $optionId;
}
$extrasOptions = [
$this->context->getTranslator()->trans(
'New product',
[],
'Modules.Facetedsearch.Shop'
) => 'new',
$this->context->getTranslator()->trans(
'On sale',
[],
'Modules.Facetedsearch.Shop'
) => 'sale',
$this->context->getTranslator()->trans(
'Discounted',
[],
'Modules.Facetedsearch.Shop'
) => 'discount',
];

$searchFilters[$filter['type']] = [];
foreach ($extrasOptions as $extrasOption => $optionId) {
if (isset($receivedFilters[$filterLabel]) && in_array($extrasOption, $receivedFilters[$filterLabel])) {
$searchFilters[$filter['type']][] = $optionId;
}
break;
}
break;
case self::TYPE_FEATURE:
$features = $this->dataAccessor->getFeatures($idLang);
foreach ($features as $feature) {
Expand Down
4 changes: 2 additions & 2 deletions src/Filters/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ private function pricePostFiltering(&$matchingProductList, $selectedFilters)
return;
}

$priceFilter['min'] = (float) ($selectedFilters['price'][0]);
$priceFilter['max'] = (float) ($selectedFilters['price'][1]);
$priceFilter['min'] = (float) $selectedFilters['price'][0];
$priceFilter['max'] = (float) $selectedFilters['price'][1];

if ($this->psLayeredFilterPriceUsetax === null) {
$this->psLayeredFilterPriceUsetax = (bool) Configuration::get('PS_LAYERED_FILTER_PRICE_USETAX');
Expand Down
2 changes: 1 addition & 1 deletion src/Filters/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getFiltersForQuery(ProductSearchQuery $query, int $idShop)
{
if (empty($this->filters)) {
$this->filters = $this->database->executeS(
'SELECT type, id_value, filter_show_limit, filter_type FROM ' . _DB_PREFIX_ . 'layered_category
'SELECT type, id_value, filter_show_limit, filter_type FROM ' . _DB_PREFIX_ . 'layered_category
WHERE controller = \'' . $query->getQueryType() . '\'
AND id_category = ' . ($query->getQueryType() == 'category' ? (int) $query->getIdCategory() : 0) . '
AND id_shop = ' . $idShop . '
Expand Down
2 changes: 1 addition & 1 deletion src/Hook/FeatureValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function actionFeatureValueSave(array $params)
return;
}

//Removing all indexed language data for this attribute value id
// Removing all indexed language data for this attribute value id
$this->database->execute(
'DELETE FROM ' . _DB_PREFIX_ . 'layered_indexable_feature_value_lang_value
WHERE `id_feature_value` = ' . (int) $params['id_feature_value']
Expand Down
106 changes: 53 additions & 53 deletions src/Product/CoreSearchBackport.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ public function get177($expr)

while (!($result = $db->executeS($sql . "'" . $sql_param_search . "';", true, false))) {
if (
!$psFuzzySearch
|| $fuzzyLoop++ > $fuzzyMaxLoop
|| !($sql_param_search = Search::findClosestWeightestWord($context, $word))
) {
!$psFuzzySearch
|| $fuzzyLoop++ > $fuzzyMaxLoop
|| !($sql_param_search = Search::findClosestWeightestWord($context, $word))
) {
break;
}
}
Expand Down Expand Up @@ -204,19 +204,19 @@ public function get177($expr)
}

$results = $db->executeS(
'SELECT DISTINCT cp.`id_product` ' .
'FROM `' . _DB_PREFIX_ . 'category_product` cp ' .
(Group::isFeatureActive() ? 'INNER JOIN `' . _DB_PREFIX_ . 'category_group` cg ON cp.`id_category` = cg.`id_category`' : '') . ' ' .
'INNER JOIN `' . _DB_PREFIX_ . 'category` c ON cp.`id_category` = c.`id_category` ' .
'INNER JOIN `' . _DB_PREFIX_ . 'product` p ON cp.`id_product` = p.`id_product` ' .
Shop::addSqlAssociation('product', 'p', false) . ' ' .
'WHERE c.`active` = 1 ' .
'AND product_shop.`active` = 1 ' .
'AND product_shop.`visibility` IN ("both", "search") ' .
'AND product_shop.indexed = 1 ' . $sqlGroups,
true,
false
);
'SELECT DISTINCT cp.`id_product` ' .
'FROM `' . _DB_PREFIX_ . 'category_product` cp ' .
(Group::isFeatureActive() ? 'INNER JOIN `' . _DB_PREFIX_ . 'category_group` cg ON cp.`id_category` = cg.`id_category`' : '') . ' ' .
'INNER JOIN `' . _DB_PREFIX_ . 'category` c ON cp.`id_category` = c.`id_category` ' .
'INNER JOIN `' . _DB_PREFIX_ . 'product` p ON cp.`id_product` = p.`id_product` ' .
Shop::addSqlAssociation('product', 'p', false) . ' ' .
'WHERE c.`active` = 1 ' .
'AND product_shop.`active` = 1 ' .
'AND product_shop.`visibility` IN ("both", "search") ' .
'AND product_shop.indexed = 1 ' . $sqlGroups,
true,
false
);

$eligibleProducts = array_column($results, 'id_product');

Expand Down Expand Up @@ -262,10 +262,10 @@ public function get178($expr)

while (!($result = $db->executeS($sql . "'" . $sql_param_search . "';", true, false))) {
if (
!$psFuzzySearch
|| $fuzzyLoop++ > $fuzzyMaxLoop
|| !($sql_param_search = Search::findClosestWeightestWord($context, $word))
) {
!$psFuzzySearch
|| $fuzzyLoop++ > $fuzzyMaxLoop
|| !($sql_param_search = Search::findClosestWeightestWord($context, $word))
) {
break;
}
}
Expand Down Expand Up @@ -294,20 +294,20 @@ public function get178($expr)
}

$results = $db->executeS(
'SELECT DISTINCT cp.`id_product` ' .
'FROM `' . _DB_PREFIX_ . 'category_product` cp ' .
(Group::isFeatureActive() ? 'INNER JOIN `' . _DB_PREFIX_ . 'category_group` cg ON cp.`id_category` = cg.`id_category`' : '') . ' ' .
'INNER JOIN `' . _DB_PREFIX_ . 'category` c ON cp.`id_category` = c.`id_category` ' .
'INNER JOIN `' . _DB_PREFIX_ . 'product` p ON cp.`id_product` = p.`id_product` ' .
Shop::addSqlAssociation('product', 'p', false) . ' ' .
'WHERE c.`active` = 1 ' .
'AND product_shop.`active` = 1 ' .
'AND product_shop.`visibility` IN ("both", "search") ' .
'AND product_shop.indexed = 1 ' .
'AND cp.id_product IN (' . implode(',', $eligibleProducts2) . ')' . $sqlGroups,
true,
false
);
'SELECT DISTINCT cp.`id_product` ' .
'FROM `' . _DB_PREFIX_ . 'category_product` cp ' .
(Group::isFeatureActive() ? 'INNER JOIN `' . _DB_PREFIX_ . 'category_group` cg ON cp.`id_category` = cg.`id_category`' : '') . ' ' .
'INNER JOIN `' . _DB_PREFIX_ . 'category` c ON cp.`id_category` = c.`id_category` ' .
'INNER JOIN `' . _DB_PREFIX_ . 'product` p ON cp.`id_product` = p.`id_product` ' .
Shop::addSqlAssociation('product', 'p', false) . ' ' .
'WHERE c.`active` = 1 ' .
'AND product_shop.`active` = 1 ' .
'AND product_shop.`visibility` IN ("both", "search") ' .
'AND product_shop.indexed = 1 ' .
'AND cp.id_product IN (' . implode(',', $eligibleProducts2) . ')' . $sqlGroups,
true,
false
);

return array_column($results, 'id_product');
}
Expand Down Expand Up @@ -354,10 +354,10 @@ public function get80($expr)

while (!($result = $db->executeS($sql . "'" . $sql_param_search . "';", true, false))) {
if (
!$psFuzzySearch
|| $fuzzyLoop++ > $fuzzyMaxLoop
|| !($sql_param_search = Search::findClosestWeightestWord($context, $word))
) {
!$psFuzzySearch
|| $fuzzyLoop++ > $fuzzyMaxLoop
|| !($sql_param_search = Search::findClosestWeightestWord($context, $word))
) {
break;
}
}
Expand Down Expand Up @@ -393,20 +393,20 @@ public function get80($expr)
}

$results = $db->executeS(
'SELECT DISTINCT cp.`id_product` ' .
'FROM `' . _DB_PREFIX_ . 'category_product` cp ' .
(Group::isFeatureActive() ? 'INNER JOIN `' . _DB_PREFIX_ . 'category_group` cg ON cp.`id_category` = cg.`id_category`' : '') . ' ' .
'INNER JOIN `' . _DB_PREFIX_ . 'category` c ON cp.`id_category` = c.`id_category` ' .
'INNER JOIN `' . _DB_PREFIX_ . 'product` p ON cp.`id_product` = p.`id_product` ' .
Shop::addSqlAssociation('product', 'p', false) . ' ' .
'WHERE c.`active` = 1 ' .
'AND product_shop.`active` = 1 ' .
'AND product_shop.`visibility` IN ("both", "search") ' .
'AND product_shop.indexed = 1 ' .
'AND cp.id_product IN (' . implode(',', $eligibleProducts2Full) . ')' . $sqlGroups,
true,
false
);
'SELECT DISTINCT cp.`id_product` ' .
'FROM `' . _DB_PREFIX_ . 'category_product` cp ' .
(Group::isFeatureActive() ? 'INNER JOIN `' . _DB_PREFIX_ . 'category_group` cg ON cp.`id_category` = cg.`id_category`' : '') . ' ' .
'INNER JOIN `' . _DB_PREFIX_ . 'category` c ON cp.`id_category` = c.`id_category` ' .
'INNER JOIN `' . _DB_PREFIX_ . 'product` p ON cp.`id_product` = p.`id_product` ' .
Shop::addSqlAssociation('product', 'p', false) . ' ' .
'WHERE c.`active` = 1 ' .
'AND product_shop.`active` = 1 ' .
'AND product_shop.`visibility` IN ("both", "search") ' .
'AND product_shop.indexed = 1 ' .
'AND cp.id_product IN (' . implode(',', $eligibleProducts2Full) . ')' . $sqlGroups,
true,
false
);

return array_column($results, 'id_product');
}
Expand Down
10 changes: 5 additions & 5 deletions src/Product/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ private function addSearchFilters($selectedFilters)
$timeCondition = date(
'Y-m-d 00:00:00',
strtotime(
((int) Configuration::get('PS_NB_DAYS_NEW_PRODUCT') > 0 ?
(int) Configuration::get('PS_NB_DAYS_NEW_PRODUCT') > 0 ?
'-' . ((int) Configuration::get('PS_NB_DAYS_NEW_PRODUCT') - 1) . ' days' :
'+ 1 days')
'+ 1 days'
)
);
// Reset filter to prevent two same filters if we are on new products page
Expand Down Expand Up @@ -251,7 +251,7 @@ private function addSearchFilters($selectedFilters)
['quantity', [0], '>'],
];
}
// Cases with 2 options selected
// Cases with 2 options selected
} elseif (count($filterValues) == 2) {
// Not available and available, we show everything
if (in_array(Availability::NOT_AVAILABLE, $filterValues) && in_array(Availability::AVAILABLE, $filterValues)) {
Expand Down Expand Up @@ -404,9 +404,9 @@ private function addControllerSpecificFilters()
$timeCondition = date(
'Y-m-d 00:00:00',
strtotime(
((int) Configuration::get('PS_NB_DAYS_NEW_PRODUCT') > 0 ?
(int) Configuration::get('PS_NB_DAYS_NEW_PRODUCT') > 0 ?
'-' . ((int) Configuration::get('PS_NB_DAYS_NEW_PRODUCT') - 1) . ' days' :
'+ 1 days')
'+ 1 days'
)
);
$this->getSearchAdapter()->addFilter('date_add', ["'" . $timeCondition . "'"], '>');
Expand Down
2 changes: 1 addition & 1 deletion upgrade/upgrade-3.8.0.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function upgrade_module_3_8_0($module)
$module->registerHook('actionProductPreferencesPageStockSave');

return Db::getInstance()->execute(
'ALTER TABLE `' . _DB_PREFIX_ . 'layered_price_index`
'ALTER TABLE `' . _DB_PREFIX_ . 'layered_price_index`
CHANGE `price_min` `price_min` decimal(20,6) NOT NULL,
CHANGE `price_max` `price_max` decimal(20,6) NOT NULL;');
}

0 comments on commit 03e1842

Please sign in to comment.