|
| 1 | +<?php |
| 2 | +/** @var Magento\Framework\View\Element\Template $block */ |
| 3 | +/** @var ?Omikron\Factfinder\ViewModel\ProductBasedComponent $viewModel */ |
| 4 | +/** @var Magento\Framework\Escaper $escaper */ |
| 5 | +$viewModel = $block->getViewModel(); |
| 6 | +$product = $viewModel->getProduct(); |
| 7 | + |
| 8 | +if (!$product || !$product->getId()) { |
| 9 | + return; |
| 10 | +} |
| 11 | + |
| 12 | +$masterProductNumber = $product->getSku(); |
| 13 | + |
| 14 | +if ($product->getTypeId() === \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) { |
| 15 | + $masterProductNumber = $product->getData('sku'); |
| 16 | +} |
| 17 | + |
| 18 | +$imageUrl = $viewModel->getImageUrl($product); |
| 19 | +?> |
| 20 | + |
| 21 | +<script> |
| 22 | + document.addEventListener('ffCoreReady', ({ factfinder }) => { |
| 23 | + factfinder.components.recentlyViewed.config({ |
| 24 | + maxLength: 9, |
| 25 | + }); |
| 26 | + |
| 27 | + factfinder.components.recentlyViewed.addEntry({ |
| 28 | + Name: '<?= $escaper->escapeJs($product->getName()) ?>', |
| 29 | + Master: '<?= $escaper->escapeJs($masterProductNumber) ?>', |
| 30 | + ProductNumber: '<?= $escaper->escapeJs($product->getSku()) ?>', |
| 31 | + Deeplink: '<?= $escaper->escapeJs($product->getProductUrl()) ?>', |
| 32 | + Price: <?= (float) $product->getFinalPrice() ?>, |
| 33 | + ImageUrl: '<?= $escaper->escapeJs($imageUrl) ?>', |
| 34 | + }); |
| 35 | + }); |
| 36 | +</script> |
| 37 | + |
| 38 | + |
| 39 | +<ff-recently-viewed wait-for-update> |
| 40 | + <div class="block upsell"> |
| 41 | + <div class="block-title title"> |
| 42 | + <strong role="heading" aria-level="2"><?= $escaper->escapeHtml(__('Recently Viewed Products')) ?></strong> |
| 43 | + </div> |
| 44 | + <div class="block-content content"> |
| 45 | + |
| 46 | + <ff-record-list class="products list items product-items" subscribe="false" unresolved> |
| 47 | + <template data-role="record"> |
| 48 | + <ff-record class="item product product-item"> |
| 49 | + <div class="product-item-info" data-container="product-grid"> |
| 50 | + <a class="product-image-container" data-redirect="{{Deeplink}}" data-anchor="{{Deeplink}}" data-redirect-target="_self"> |
| 51 | + <span class="product-image-wrapper"> |
| 52 | + <img class="product-image-photo" data-image="{{ImageUrl}}" alt="{{Name}}"/> |
| 53 | + </span> |
| 54 | + </a> |
| 55 | + |
| 56 | + <div class="product details product-item-details"> |
| 57 | + <div class="product name product-item-name">{{Name}}</div> |
| 58 | + <div class="price-box price-final_price" data-role="priceBox"> |
| 59 | + <span class="price-container price-final_price tax weee"> |
| 60 | + <span data-price-amount="{{masterValues.Price}}" data-price-type="finalPrice" class="price-wrapper"> |
| 61 | + <span class="price">{{$ Price}}</span> |
| 62 | + </span> |
| 63 | + </span> |
| 64 | + </div> |
| 65 | + </div> |
| 66 | + </div> |
| 67 | + </ff-record> |
| 68 | + </template> |
| 69 | + </ff-record-list> |
| 70 | + |
| 71 | + </div> |
| 72 | + </div> |
| 73 | +</ff-recently-viewed> |
0 commit comments