Skip to content

Commit 93ed52a

Browse files
committed
Temp commit
1 parent 3a15d99 commit 93ed52a

File tree

10 files changed

+168
-16
lines changed

10 files changed

+168
-16
lines changed

Block/Configuration.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,13 @@ public function getConfiguration()
233233
'isAddToCartEnabledInFBT' => $config->isAddToCartEnabledInFrequentlyBoughtTogether(),
234234
'isAddToCartEnabledInRelatedProduct' => $config->isAddToCartEnabledInRelatedProducts(),
235235
'isAddToCartEnabledInTrendsItem' => $config->isAddToCartEnabledInTrendsItem(),
236+
'isAddToCartEnabledInLookingSimilar' => $config->isAddToCartEnabledInLookingSimilar(),
236237
'FBTTitle' => __($config->getFBTTitle()),
237238
'relatedProductsTitle' => __($config->getRelatedProductsTitle()),
238239
'trendingItemsTitle' => __($config->getTrendingItemsTitle()),
239240
'addToCartParams' => $addToCartParams,
241+
'isLookingSimilarEnabledOnPDP' => $config->isLookingSimilarEnabledOnPDP(),
242+
'lookingSimilarTitle' => __($config->getLookingSimilarTitle())
240243
],
241244
'extensionVersion' => $config->getExtensionVersion(),
242245
'applicationId' => $config->getApplicationID(),

Helper/ConfigHelper.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ class ConfigHelper
135135
protected const IS_ADDTOCART_ENABLED_IN_FREQUENTLY_BOUGHT_TOGETHER = 'algoliasearch_recommend/recommend/frequently_bought_together/is_addtocart_enabled';
136136
protected const IS_ADDTOCART_ENABLED_IN_RELATED_PRODUCTS = 'algoliasearch_recommend/recommend/related_product/is_addtocart_enabled';
137137
protected const IS_ADDTOCART_ENABLED_IN_TRENDS_ITEM = 'algoliasearch_recommend/recommend/trends_item/is_addtocart_enabled';
138+
protected const IS_ADDTOCART_ENABLED_IN_LOOKING_SIMILAR = 'algoliasearch_recommend/recommend/looking_similar/is_addtocart_enabled';
139+
protected const LOOKING_SIMILAR_TITLE = 'algoliasearch_recommend/recommend/looking_similar/title';
138140
protected const USE_VIRTUAL_REPLICA_ENABLED = 'algoliasearch_instant/instant/use_virtual_replica';
139141
protected const AUTOCOMPLETE_KEYBORAD_NAVIAGATION = 'algoliasearch_autocomplete/autocomplete/navigator';
140142
protected const FREQUENTLY_BOUGHT_TOGETHER_TITLE = 'algoliasearch_recommend/recommend/frequently_bought_together/title';
@@ -831,6 +833,42 @@ public function getTrendingItemsFacetValue($storeId = null)
831833
);
832834
}
833835

836+
/**
837+
* Determines whether Looking Similar enabled on PDP
838+
*
839+
* @param $storeId
840+
* @return int
841+
*/
842+
public function isLookingSimilarEnabledOnPDP($storeId = null)
843+
{
844+
return (int)$this->configInterface->getValue(
845+
self::IS_LOOKING_SIMILAR_ENABLED_ON_PDP,
846+
ScopeInterface::SCOPE_STORE,
847+
$storeId
848+
);
849+
}
850+
851+
public function getLookingSimilarTitle($storeId = null)
852+
{
853+
return $this->configInterface->getValue(
854+
self::LOOKING_SIMILAR_TITLE,
855+
ScopeInterface::SCOPE_STORE, $storeId
856+
);
857+
}
858+
859+
/**
860+
* @param $storeId
861+
* @return int
862+
*/
863+
public function isLookingSimilarEnabledOnShoppingCart($storeId = null)
864+
{
865+
return (int)$this->configInterface->getValue(
866+
self::IS_LOOKING_SIMILAR_ENABLED_ON_SHOPPING_CART,
867+
ScopeInterface::SCOPE_STORE,
868+
$storeId
869+
);
870+
}
871+
834872
/**
835873
* @param $storeId
836874
* @return int
@@ -884,6 +922,21 @@ public function isAddToCartEnabledInTrendsItem($storeId = null)
884922
return $this->configInterface->isSetFlag(self::IS_ADDTOCART_ENABLED_IN_TRENDS_ITEM, ScopeInterface::SCOPE_STORE, $storeId);
885923
}
886924

925+
/**
926+
* Determines whether add to cart is enabled in Looking Similar
927+
*
928+
* @param $storeId
929+
* @return bool
930+
*/
931+
public function isAddToCartEnabledInLookingSimilar($storeId = null)
932+
{
933+
return $this->configInterface->isSetFlag(
934+
self::IS_ADDTOCART_ENABLED_IN_LOOKING_SIMILAR,
935+
ScopeInterface::SCOPE_STORE,
936+
$storeId
937+
);
938+
}
939+
887940
/**
888941
* @param $storeId
889942
* @return string

view/frontend/layout/catalog_product_view.xml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
8+
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
910
<body>
1011
<referenceContainer name="content.aside">
11-
<block name="algolia.product.view" template="Algolia_AlgoliaSearch::recommend/products.phtml" >
12-
<arguments>
13-
<argument name="view_model" xsi:type="object">Algolia\AlgoliaSearch\ViewModel\Recommend\ProductView</argument>
14-
</arguments>
12+
<block name="algolia.product.view" template="Algolia_AlgoliaSearch::recommend/products.phtml">
13+
<arguments>
14+
<argument name="view_model" xsi:type="object">
15+
Algolia\AlgoliaSearch\ViewModel\Recommend\ProductView
16+
</argument>
17+
</arguments>
1518
</block>
1619
</referenceContainer>
1720
</body>
18-
</page>
21+
</page>

view/frontend/templates/recommend/products.phtml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
<?php
2-
/** @var \Algolia\AlgoliaSearch\ViewModel\Recommend\ProductView $block */
2+
use Algolia\AlgoliaSearch\ViewModel\Recommend\ProductView;
3+
use Magento\Framework\View\Element\Template;
4+
5+
/**
6+
* @var ProductView $viewModel
7+
* @var Template $block
8+
*/
39
$viewModel = $block->getViewModel();
4-
$recommendConfig = $viewModel->getAlgoliaRecommendConfiguration();
10+
$recommendConfig = $viewModel->getAlgoliaRecommendConfiguration();
511

6-
if (!empty($recommendConfig['enabledFBT']) || !empty($recommendConfig['enabledRelated']) || !empty($recommendConfig['isTrendItemsEnabledInPDP'])):
12+
if (!empty($recommendConfig['enabledFBT'])
13+
|| !empty($recommendConfig['enabledRelated'])
14+
|| !empty($recommendConfig['isTrendItemsEnabledInPDP'])
15+
|| !empty($recommendConfig['isLookingSimilarEnabledOnPDP'])):
716
$product = $viewModel->getProduct(); ?>
817
<div id="frequentlyBoughtTogether" class="recommend-component"></div>
918
<div id="relatedProducts" class="recommend-component"></div>
1019
<div id="trendItems" class="trendsItem recommend-component"></div>
20+
<div id="looking-similar" class="looking-similar recommend-component"></div>
1121
<script type="text/x-magento-init">
1222
{
1323
"*": {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div id="frequentlyBoughtTogether" class="recommend-component"></div>
2+
<script type="text/x-magento-init">
3+
{
4+
"#frequentlyBoughtTogether": {
5+
"Algolia_AlgoliaSearch/recommend" : {
6+
"algoliObjectId" : ["<?= $product->getId() ?>"]
7+
}
8+
},
9+
"[data-role=tocart-form]": {
10+
"catalogAddToCart": {}
11+
}
12+
}
13+
</script>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div id="relatedProducts" class="recommend-component"></div>
2+
<script type="text/x-magento-init">
3+
{
4+
"#relatedProducts": {
5+
"Algolia_AlgoliaSearch/recommend" : {
6+
"algoliObjectId" : ["<?= $product->getId() ?>"]
7+
}
8+
},
9+
"[data-role=tocart-form]": {
10+
"catalogAddToCart": {}
11+
}
12+
}
13+
</script>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
use Magento\Framework\View\Element\Template;
3+
4+
/**
5+
* @var Template $block
6+
*/
7+
$parentBlock = $block->getParentBlock();
8+
$product = $parentBlock->getData('product');
9+
?>
10+
<div id="trendItems" class="trendsItem recommend-component"></div>
11+
<script type="text/x-magento-init">
12+
{
13+
"*": {
14+
"Algolia_AlgoliaSearch/recommend" : {
15+
"algoliObjectId" : ["<?= $product->getId() ?>"]
16+
}
17+
},
18+
"[data-role=tocart-form]": {
19+
"catalogAddToCart": {}
20+
}
21+
}
22+
</script>

view/frontend/web/internals/recommend-js.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)