Skip to content

Commit

Permalink
Release/3.13.5 (#1570)
Browse files Browse the repository at this point in the history
* Bugfix/MAGE-948: DOM selector check (#1550)

* MAGE-3 Checking on exists element fix (#1516)

Co-authored-by: andreishichko <[email protected]>

* MAGE-948: use if statement over ternary

* MAGE-948: remove optional chaining

---------

Co-authored-by: sgeleon <[email protected]>
Co-authored-by: andreishichko <[email protected]>

* MAGE-947: restrict recommend CSS to algolia managed blocks (#1553)

* MAGE-947: restrict recommend CSS to algolia managed blocks

* MAGE-947: add css identifer to all rules

* MAGE-949: add fallback for secureRenderer (#1556)

* Removed polyfill.io from csp_whitelist, was forgotten in MAGE-822

* MAGE-901: showing title for empty recommendation issue addressed

* MAGE-901: code updated as per code review suggestions

* MAGE-958: release number increased and change log updated

* MAGE-958: change log updated.

---------

Co-authored-by: Damien Couchez <[email protected]>
Co-authored-by: sgeleon <[email protected]>
Co-authored-by: andreishichko <[email protected]>
Co-authored-by: Pieter Hoste <[email protected]>
Co-authored-by: Eric Wright <[email protected]>
  • Loading branch information
6 people authored Jul 12, 2024
1 parent 1a26fce commit 72622b6
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 62 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# CHANGE LOG

## 3.13.5

### Updates
- Polyfill.io removed from CSP whitelist - Thank you @hostep
- Hide Recommend Titles when not in use
- Incorporate community fix for higher specificity CSS selectors on Recommend - Thank you @sgeleon

### Bug Fixes
- Incorporate community fix for missing DOM element selector - Thank you @sgeleon

## 3.13.4

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Algolia Search & Discovery extension for Magento 2
==================================================

![Latest version](https://img.shields.io/badge/latest-3.13.4-green)
![Latest version](https://img.shields.io/badge/latest-3.13.5-green)
![Magento 2](https://img.shields.io/badge/Magento-2.4.x-orange)

![PHP](https://img.shields.io/badge/PHP-8.2%2C8.1%2C7.4-blue)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Algolia Search & Discovery extension for Magento 2",
"type": "magento2-module",
"license": ["MIT"],
"version": "3.13.4",
"version": "3.13.5",
"require": {
"magento/framework": "~102.0|~103.0",
"algolia/algoliasearch-client-php": "3.3.2",
Expand Down
5 changes: 0 additions & 5 deletions etc/csp_whitelist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
<csp_whitelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Csp:etc/csp_whitelist.xsd">
<policies>
<policy id="script-src">
<values>
<value id="polyfill" type="host">polyfill.io</value>
</values>
</policy>
<policy id="connect-src">
<values>
<value id="algolia-api" type="host">*.algolia.net</value>
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Algolia_AlgoliaSearch" setup_version="3.13.4">
<module name="Algolia_AlgoliaSearch" setup_version="3.13.5">
<sequence>
<module name="Magento_Theme"/>
<module name="Magento_Backend"/>
Expand Down
33 changes: 23 additions & 10 deletions view/frontend/templates/internals/configuration.phtml
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
<?php

/** @var \Algolia\AlgoliaSearch\Block\Configuration $block */
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */

$configuration = $block->getConfiguration();

?>
if (class_exists('\Magento\Framework\View\Helper\SecureHtmlRenderer')) : ?>
<?php
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
if ($configuration['instant']['enabled'] === true && $configuration['isSearchPage'] === true) {
$css = /* @noEscape */ $secureRenderer->renderTag('style', [], $configuration['instant']['selector'] . ' {display:none}', false);
/* @noEscape */ echo $secureRenderer->renderTag('script', [], 'document.write(\'' . $css . '\');' , false);
}
?>

<?php
if ($configuration['instant']['enabled'] === true && $configuration['isSearchPage'] === true) {
$css = /* @noEscape */ $secureRenderer->renderTag('style', [], $configuration['instant']['selector'] . ' {display:none}', false);
/* @noEscape */ echo $secureRenderer->renderTag('script', [], 'document.write(\'' . $css . '\');' , false);
}
?>

<?= /* @noEscape */ $secureRenderer->renderTag('script', [], "window.algoliaConfig = " . json_encode($configuration) . ';' , false); ?>
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], "window.algoliaConfig = " . json_encode($configuration) . ';' , false); ?>
<?php else: ?>
<script>
<?php
if ($configuration['instant']['enabled'] === true && $configuration['isSearchPage'] === true) :
$css = '<style type="text/css">' . $configuration['instant']['selector'] . ' {display:none}</style>';
?>
// Hide the instant-search selector ASAP to remove flickering. Will be re-displayed later with JS.
document.write('<?php /* @noEscape */ echo $css; ?>');
<?php
endif;
?>

window.algoliaConfig = <?php /* @noEscape */ echo json_encode($configuration); ?>;
</script>
<?php endif; ?>
32 changes: 19 additions & 13 deletions view/frontend/templates/layer/view.phtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
<?php
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
?>

<?php if ($block->canShowBlock()) : ?>
<div class="block filter algolia-filter-list" id="layered-filter-block" data-mage-init='{"collapsible":{"openedState": "active", "collapsible": true, "active": false, "collateral": { "openedState": "filter-active", "element": "body" } }}'>
<?php $filtered = count($block->getLayer()->getState()->getFilters()) ?>
Expand Down Expand Up @@ -34,15 +30,25 @@
<?php if ($wrapOptions) : ?>
</div>
<?php else : ?>
<?php $scriptString = <<<script
require([
'jquery'
], function ($) {
$('#layered-filter-block').addClass('filter-no-options');
});
script;
?>
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false); ?>
<?php if (class_exists('\Magento\Framework\View\Helper\SecureHtmlRenderer')) : ?>
<?php
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
$scriptString = "require([
'jquery'
], function ($) {
$('#layered-filter-block').addClass('filter-no-options');
});";

/* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false); ?>
<?php else : ?>
<script>
require([
'jquery'
], function ($) {
$('#layered-filter-block').addClass('filter-no-options');
});
</script>
<?php endif; ?>
<?php endif; ?>
</div>
</div>
Expand Down
8 changes: 5 additions & 3 deletions view/frontend/templates/recommend/cart/recommend_items.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ $recommendConfig = $viewModel->getAlgoliaRecommendConfiguration();
if (!empty($recommendConfig['enabledRelatedInCart']) || !empty($recommendConfig['enabledFBTInCart']) || !empty($recommendConfig['isTrendItemsEnabledInCartPage'])):
$cartItems = $viewModel->getAllCartItems();
?>
<div id="frequentlyBoughtTogether" class="recommend-component"></div>
<div id="relatedProducts" class="recommend-component"></div>
<div id="trendItems" class="trendsItem recommend-component"></div>
<div id="algoliaRecommend">
<div id="frequentlyBoughtTogether" class="recommend-component"></div>
<div id="relatedProducts" class="recommend-component"></div>
<div id="trendItems" class="trendsItem recommend-component"></div>
</div>
<script type="text/x-magento-init">
{
"*": {
Expand Down
8 changes: 5 additions & 3 deletions view/frontend/templates/recommend/products.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ $recommendConfig = $viewModel->getAlgoliaRecommendConfiguration();

if (!empty($recommendConfig['enabledFBT']) || !empty($recommendConfig['enabledRelated']) || !empty($recommendConfig['isTrendItemsEnabledInPDP'])):
$product = $viewModel->getProduct(); ?>
<div id="frequentlyBoughtTogether" class="recommend-component"></div>
<div id="relatedProducts" class="recommend-component"></div>
<div id="trendItems" class="trendsItem recommend-component"></div>
<div id="algoliaRecommend">
<div id="frequentlyBoughtTogether" class="recommend-component"></div>
<div id="relatedProducts" class="recommend-component"></div>
<div id="trendItems" class="trendsItem recommend-component"></div>
</div>
<script type="text/x-magento-init">
{
"*": {
Expand Down
6 changes: 4 additions & 2 deletions view/frontend/templates/recommend/widget/trends-item.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
$isEnabled = $block->isTrendingItemEnabled();
if ($isEnabled):
$trendConstainer = 'trendItems' . $block->generateUniqueToken(); ?>
<div id="<?= $trendConstainer ?>" class="trendsItem recommend-component"></div>
<div id="algoliaRecommend">
<div id="<?= $trendConstainer ?>" class="trendsItem recommend-component"></div>
</div>
<script type="text/x-magento-init">
{
"*": {
Expand All @@ -23,4 +25,4 @@ if ($isEnabled):
}
}
</script>
<?php endif; ?>
<?php endif; ?>
8 changes: 5 additions & 3 deletions view/frontend/web/internals/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ define(['jquery', 'algoliaBundle'], function ($, algoliaBundle) {
return acc;
}, {});

window.algolia = {
window.algolia = {
deprecatedHooks: [
'beforeAutocompleteProductSourceOptions',
'beforeAutocompleteSources'
Expand Down Expand Up @@ -85,7 +85,7 @@ define(['jquery', 'algoliaBundle'], function ($, algoliaBundle) {
htmlspecialcharsEncode: string => {
const regex = new RegExp(`[${Object.keys(SPECIAL_CHAR_ENCODE_MAP).join('')}]`, 'g');
return string.replace(regex, (m) => SPECIAL_CHAR_ENCODE_MAP[m]);
}
}
};

window.isMobile = function () {
Expand Down Expand Up @@ -629,7 +629,9 @@ define(['jquery', 'algoliaBundle'], function ($, algoliaBundle) {
var input = $(this).closest('#algolia-searchbox').find('input');

input.val('');
input.get(0).dispatchEvent(new Event('input'));
if (input.length) {
input.get(0).dispatchEvent(new Event('input'));
}

handleInputCrossAutocomplete(input);
});
Expand Down
51 changes: 34 additions & 17 deletions view/frontend/web/internals/recommend.css
Original file line number Diff line number Diff line change
@@ -1,33 +1,42 @@
.recommend-item .product-img {
#algoliaRecommend .recommend-item .product-img {
width: 180px;
}
.auc-Recommend-list {
#algoliaRecommend .auc-Recommend-list {
display: flex;
justify-content: space-evenly;
list-style: none;
}
.recommend-item .product-name {
#algoliaRecommend .recommend-item .product-name {
height: 50px;
width: 110px;
margin: 0 auto;
}
.recommend-component {
#algoliaRecommend .recommend-component {
margin-bottom: 80px;
}
#relatedProducts .auc-Recommend-list, #frequentlyBoughtTogether .auc-Recommend-list, .trendsItem .auc-Recommend-list{
#algoliaRecommend #relatedProducts .auc-Recommend-list,
#algoliaRecommend #frequentlyBoughtTogether .auc-Recommend-list,
#algoliaRecommend .trendsItem .auc-Recommend-list {
flex-wrap: wrap;
justify-content: flex-start;
}
#relatedProducts li, #frequentlyBoughtTogether li, .trendsItem li {
#algoliaRecommend #relatedProducts li,
#algoliaRecommend #frequentlyBoughtTogether li,
#algoliaRecommend .trendsItem li {
display: flex;
justify-content: center;
width: 16.66666667%;
}
#relatedProducts li a, #frequentlyBoughtTogether li a, .trendsItem li a {
#algoliaRecommend #relatedProducts li a,
#algoliaRecommend #frequentlyBoughtTogether li a,
#algoliaRecommend .trendsItem li a {
color: inherit;
display: block;
}
#relatedProducts .product-name, #frequentlyBoughtTogether .product-name, #trendItems .product-name, .trendsItem .product-name{
#algoliaRecommend #relatedProducts .product-name,
#algoliaRecommend #frequentlyBoughtTogether .product-name,
#algoliaRecommend #trendItems .product-name,
#algoliaRecommend .trendsItem .product-name{
text-align: center;
width: 150px;
text-overflow: ellipsis;
Expand All @@ -40,37 +49,45 @@
-webkit-box-orient: vertical;
display: -webkit-box;
}
#trendItems a, #trendItems a:hover, .trendsItem a, .trendsItem a:hover{
#algoliaRecommend #trendItems a,
#algoliaRecommend #trendItems a:hover,
#algoliaRecommend .trendsItem a,
#algoliaRecommend .trendsItem a:hover{
color:#333;
}
.auc-Recommend-item .product-details {
#algoliaRecommend .auc-Recommend-item .product-details {
text-align: center;
}
#trendItems .auc-Recommend-list{
#algoliaRecommend #trendItems .auc-Recommend-list{
flex-wrap: wrap;
justify-content: flex-start;
}
.product-details .recommend-item .action.primary, .action-primary{
#algoliaRecommend .product-details .recommend-item .action.primary,
#algoliaRecommend .action-primary{
background: #f4f4f4;
border: 1px solid #f4f4f4;
color: #666666;
}
.product-details .recommend-item .action.primary:hover, .action-primary:hover {
#algoliaRecommend .product-details .recommend-item .action.primary:hover,
#algoliaRecommend .action-primary:hover {
border-color: #1979c3;
background: #1979c3;
color: #FFFFFF;
}
@media (min-width: 768px) and (max-width: 1023px) {
#relatedProducts li, #frequentlyBoughtTogether li, #trendItems li {
#algoliaRecommend #relatedProducts li,
#algoliaRecommend #frequentlyBoughtTogether li,
#algoliaRecommend #trendItems li {
width: 33.33333333%;
}
}
@media (max-width: 767px) {
#relatedProducts li, #frequentlyBoughtTogether li, #trendItems li {
#algoliaRecommend #relatedProducts li,
#algoliaRecommend #frequentlyBoughtTogether li,
#algoliaRecommend #trendItems li {
width: 50%;
}
}
h3.auc-Recommend-title {
padding: 20p;
#algoliaRecommend h3.auc-Recommend-title {
padding-bottom: 20px;
}
15 changes: 12 additions & 3 deletions view/frontend/web/recommend.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ define([
position: index + 1,
}));
},
headerComponent({html}) {
headerComponent({html, recommendations}) {
if (!recommendations.length) {
return '';
}
return recommendProductsHtml.getHeaderHtml(html,algoliaConfig.recommend.FBTTitle);
},
itemComponent({item, html}) {
Expand All @@ -55,7 +58,10 @@ define([
position: index + 1,
}));
},
headerComponent({html}) {
headerComponent({html, recommendations}) {
if (!recommendations.length) {
return '';
}
return recommendProductsHtml.getHeaderHtml(html,algoliaConfig.recommend.relatedProductsTitle);
},
itemComponent({item, html}) {
Expand All @@ -79,7 +85,10 @@ define([
position: index + 1,
}));
},
headerComponent({html}) {
headerComponent({html, recommendations}) {
if (!recommendations.length) {
return '';
}
return recommendProductsHtml.getHeaderHtml(html,algoliaConfig.recommend.trendingItemsTitle);
},
itemComponent({item, html}) {
Expand Down

1 comment on commit 72622b6

@abdulrafaywaqar
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

11% 1 sec 147.0 MiBPHP Parse error: syntax error, unexpected 'CurrentCategory' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /vendor/algolia/algoliasearch-magento-2/Block/Algolia.php on line 102

/** @var CurrentCategory  */

protected CurrentCategory $currentCategory;

Please sign in to comment.