Skip to content

Commit b0a68e1

Browse files
authored
Merge pull request #20 from landofcoder/feature4
fix tag url
2 parents a61984f + 63147ce commit b0a68e1

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

Helper/Data.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,17 @@ class Data extends AbstractHelper
3636
*/
3737

3838
protected $scopeConfig;
39+
public $_storeManager;
3940
const XML_PATH_TAG = 'lofproductags/';
40-
public function __construct(Context $context,ScopeConfigInterface $scopeConfig)
41+
public function __construct(
42+
Context $context,
43+
ScopeConfigInterface $scopeConfig,
44+
\Magento\Store\Model\StoreManagerInterface $storeManager
45+
)
4146
{
4247
parent::__construct($context);
4348
$this->scopeConfig=$scopeConfig;
49+
$this->_storeManager=$storeManager;
4450
}
4551

4652
/**
@@ -55,5 +61,12 @@ public function getConfigValue($field, $storeId = null)
5561
public function getGeneralConfig($code, $storeId = null)
5662
{
5763
return $this->getConfigValue(self::XML_PATH_TAG .'general/'. $code, $storeId);
58-
}
64+
}
65+
public function getTagUrl($tag_identifier=""){
66+
$route = $this->getGeneralConfig("route");
67+
$route = $route?$route:"lofproducttags";
68+
$url = $route."/".$tag_identifier;
69+
$base_url = $this->_storeManager->getStore()->getBaseUrl();
70+
return $base_url.$url;
71+
}
5972
}

Model/Tag.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,5 @@ public function getProductsPosition()
6262
public function getRelatedReadonly(){
6363
return false;
6464
}
65+
6566
}

view/frontend/templates/tag/product/listProduct.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ if($tags && $tags->getSize()){
1313
<div class="block-content">
1414
<ul style="padding: 0px;" class="list-tags">
1515
<?php foreach($tags as $tag): ?>
16-
<li style="list-style-type: none; float: left; margin:5px 10px; border: 1px solid #000000; border-radius: 5px; padding: 5px;"><a href="<?php echo $tag->getIdentifier(); ?>">
16+
<li style="list-style-type: none; float: left; margin:5px 10px; border: 1px solid #000000; border-radius: 5px; padding: 5px;"><a href="<?php
17+
echo $this->getTagHelper()->getTagUrl($tag->getIdentifier()); ?>">
1718
<style>
1819
li:hover{
1920
background-color: #e4e4e4;

view/frontend/templates/tag/product/tags.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if($tags && $tags->getSize()){
1313
<div class="block-content">
1414
<ul style="padding: 0px;" class="list-tags">
1515
<?php foreach($tags as $tag): ?>
16-
<li style="list-style-type: none; float: left; margin:5px 10px; border: 1px solid #000000; border-radius: 5px; padding: 5px;"><a href="<?php echo $tag->getIdentifier(); ?>">
16+
<li style="list-style-type: none; float: left; margin:5px 10px; border: 1px solid #000000; border-radius: 5px; padding: 5px;"><a href="<?php echo $this->getTagHelper()->getTagUrl($tag->getIdentifier()); ?>">
1717
<style>
1818
li:hover{
1919
background-color: #e4e4e4;

0 commit comments

Comments
 (0)