Skip to content

Commit

Permalink
Merge pull request #61 from EmicoEcommerce/beta
Browse files Browse the repository at this point in the history
Merge beta into master
  • Loading branch information
ah-net authored Dec 17, 2024
2 parents 3c74d84 + f37a088 commit a5b45f7
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"hyva-themes/magento2-compat-module-fallback": "*",
"hyva-themes/magento2-default-theme": "^1.2",
"php": "^8.1",
"tweakwise/magento2-tweakwise": ">=8.0.0."
"tweakwise/magento2-tweakwise": ">=8.3.0."
},
"autoload": {
"files": [
Expand Down
25 changes: 25 additions & 0 deletions src/view/frontend/templates/analytics.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/** @var \Tweakwise\Magento2Tweakwise\Block\Catalog\PersonalMerchandisingAnalytics $block */
/** @var Escaper $escaper */

use Magento\Framework\Escaper;

/** @var \Tweakwise\Magento2Tweakwise\ViewModel\PersonalMerchandisingAnalytics $viewModel */
$viewModel = $block->getData('viewModel');
$analyticsType = $block->getData('analyticsType');
$value = $analyticsType === 'product' ? $viewModel->getProductKey() : $viewModel->getSearchQuery();
?>

<div x-data="{
value: '<?= $escaper->escapeHtmlAttr($value); ?>',
type: '<?= $escaper->escapeHtmlAttr($analyticsType); ?>'
}" x-init="() => {
Tweakwise_Hyva_Analytics({
value: value,
type: type
}).init();
}">
</div>

<script src="<?= $escaper->escapeHtmlAttr($block->getViewFileUrl('Tweakwise_TweakwiseHyva::js/analytics.js')); ?>"></script>
10 changes: 9 additions & 1 deletion src/view/frontend/templates/layer/navigation-form.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use Magento\Framework\View\Element\Template;
currentXhr: null,
fetchController: null,
ajaxCache: true,
urlStategy: null,
initForm(initialValues) {
const filterOptions = initialValues.tweakwiseNavigationForm;

Expand Down Expand Up @@ -145,7 +146,14 @@ use Magento\Framework\View\Element\Template;
const href = aElement.getAttribute('href');
if (this.seoEnabled) {
const seoHref = aElement.dataset.seoHref;
return seoHref ? seoHref : href;
href = seoHref ? seoHref : href;
}

if (this.urlStategy === 'queryparameter') {
let url = new URL(href, window.location.origin);
url.search = this.getFilterParameters();

return url.toString();
}

return href;
Expand Down
2 changes: 1 addition & 1 deletion src/view/frontend/templates/product/layered/default.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ $hasAlternateSortOrder = $block->hasAlternateSortOrder();
data-original-sort="<?= $escaper->escapeHtmlAttr($index); ?>"
<?php endif; ?>
>
<a <?= $escaper->escapeHtmlAttr($block->renderAnchorHtmlTagAttributes($item)); ?> class="flex w-full py-1 mb-1 hover:text-black">
<a <?= /* @noEscape */ $block->renderAnchorHtmlTagAttributes($item); ?> class="flex w-full py-1 mb-1 hover:text-black">
<?php $cssId = $item->getCssId(); ?>
<?php if ($block->showCheckbox()): ?>
<label for="<?= $escaper->escapeHtmlAttr($cssId) ?>" class="block m-0 font-normal flex w-full">
Expand Down
19 changes: 19 additions & 0 deletions src/view/frontend/web/js/analytics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function Tweakwise_Hyva_Analytics(config) {
return {
value: config.value,
type: config.type,
init() {
let bodyData = { type: this.type };
bodyData.value = this.value;

fetch('/tweakwise/ajax/analytics', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest'
},
body: JSON.stringify(bodyData)
}).catch(error => console.error('Tweakwise API call failed:', error));
}
}
}

0 comments on commit a5b45f7

Please sign in to comment.