Skip to content

Commit 23747b1

Browse files
authored
Merge pull request #44 from landofcoder/develop
Develop
2 parents 482bc6d + f664ff8 commit 23747b1

File tree

27 files changed

+244
-123
lines changed

27 files changed

+244
-123
lines changed

Api/Data/TagProductLinkInterface.php

100644100755
File mode changed.

Block/AbstractWidget.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
/**
3+
* Copyright (c) 2019 Landofcoder
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all
13+
* copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
* SOFTWARE.
22+
*/
23+
24+
namespace Lof\ProductTags\Block;
25+
26+
class AbstractWidget extends \Magento\Framework\View\Element\Template
27+
{
28+
protected $resultPageFactory;
29+
30+
protected $_tagFactory;
31+
32+
protected $_tagcollection;
33+
34+
protected $_tagHelper;
35+
36+
public function __construct(
37+
\Magento\Framework\View\Element\Template\Context $context,
38+
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
39+
\Lof\ProductTags\Model\TagFactory $tagFactory,
40+
\Lof\ProductTags\Helper\Data $tagdata,
41+
array $data = []
42+
) {
43+
$this->resultPageFactory = $resultPageFactory;
44+
$this->_tagFactory = $tagFactory;
45+
$this->_tagHelper = $tagdata;
46+
parent::__construct($context, $data);
47+
}
48+
49+
function getLimit(){
50+
$default_limit = $this->_tagHelper->getGeneralConfig('number_tags_sidebar');
51+
if($this->hasData("number_tags")){
52+
$limit = (int)$this->getData("number_tags");
53+
}else {
54+
$limit = $default_limit;
55+
}
56+
$limit = $limit?(int)$limit:10;
57+
return $limit;
58+
}
59+
60+
function getTagHelper(){
61+
return $this->_tagHelper;
62+
}
63+
64+
public function getTagCollection()
65+
{
66+
if(!$this->_tagcollection){
67+
$limit = $this->getLimit();
68+
$tag = $this->_tagFactory->create();
69+
$collection = $tag->getCollection();
70+
$collection->addFieldToFilter("status", 1);
71+
$collection->setOrder("tag_id","DESC");
72+
$collection->setPageSize($limit);
73+
//$collection->setLimit($limit);
74+
$this->_tagcollection = $collection;
75+
}
76+
return $this->_tagcollection;
77+
}
78+
}

Block/Adminhtml/Tags/Edit/DeleteButton.php

100644100755
File mode changed.

Block/Tag/Product/Sidebar.php

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,10 @@
2222
*/
2323

2424
namespace Lof\ProductTags\Block\Tag\Product;
25+
use Lof\ProductTags\Block\AbstractWidget;
2526

26-
class Sidebar extends \Magento\Framework\View\Element\Template
27+
class Sidebar extends AbstractWidget
2728
{
28-
protected $resultPageFactory;
29-
30-
protected $_tagFactory;
31-
32-
protected $_tagcollection;
33-
34-
protected $_tagHelper;
35-
36-
public function __construct(
37-
\Magento\Framework\View\Element\Template\Context $context,
38-
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
39-
\Lof\ProductTags\Model\TagFactory $tagFactory,
40-
\Lof\ProductTags\Helper\Data $tagdata,
41-
array $data = []
42-
) {
43-
$this->resultPageFactory = $resultPageFactory;
44-
$this->_tagFactory = $tagFactory;
45-
$this->_tagHelper = $tagdata;
46-
parent::__construct($context, $data);
47-
}
4829
public function _toHtml(){
4930
if(!$this->_tagHelper->getGeneralConfig('enabled')) return;
5031
if(!$this->_tagHelper->getGeneralConfig('enable_tag_sidebar')) return;
@@ -54,22 +35,5 @@ public function _toHtml(){
5435
}
5536
return "";
5637
}
57-
function getTagHelper(){
58-
return $this->_tagHelper;
59-
}
60-
public function getTagCollection()
61-
{
62-
if(!$this->_tagcollection){
63-
$limit = $this->_tagHelper->getGeneralConfig('number_tags_sidebar');
64-
$limit = $limit?(int)$limit:10;
65-
$tag = $this->_tagFactory->create();
66-
$collection = $tag->getCollection();
67-
$collection->addFieldToFilter("status", 1);
68-
$collection->setOrder("tag_id","DESC");
69-
$collection->setPageSize($limit);
70-
//$collection->setLimit($limit);
71-
$this->_tagcollection = $collection;
72-
}
73-
return $this->_tagcollection;
74-
}
38+
7539
}

Block/Widget/LofproductTags.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,19 @@
2323

2424
namespace Lof\ProductTags\Block\Widget;
2525

26-
use Magento\Framework\View\Element\Template;
26+
use Lof\ProductTags\Block\AbstractWidget;
2727
use Magento\Widget\Block\BlockInterface;
2828

29-
class LofproductTags extends Template implements BlockInterface
29+
class LofproductTags extends AbstractWidget implements BlockInterface
3030
{
3131

3232
protected $_template = "widget/lofproducttags.phtml";
3333

34+
public function _toHtml(){
35+
$_tag_collection = $this->getTagCollection();
36+
if($_tag_collection && $_tag_collection->getSize()){
37+
return parent::_toHtml();
38+
}
39+
}
40+
3441
}

Controller/Adminhtml/Tag/Delete.php

100644100755
File mode changed.

Controller/Adminhtml/Tag/MassDelete.php

100644100755
File mode changed.

Controller/Adminhtml/Tag/Save.php

100644100755
File mode changed.

Controller/Router.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@ public function __construct(
2727
}
2828
public function match(\Magento\Framework\App\RequestInterface $request)
2929
{
30+
die("Awetae");
3031
if (!$this->dispatched) {
32+
3133
$identifier = trim($request->getPathInfo(), '/');
3234
$origUrlKey = $identifier;
3335
$condition = new DataObject(['url_key' => $identifier, 'continue' => true]);
3436
$this->eventManager->dispatch(
3537
'lof_producttags_controller_router_match_before',
3638
['router' => $this, 'condition' => $condition]
3739
);
40+
3841
$urlKey = $condition->getUrlKey();
3942
if ($condition->getRedirectUrl()) {
4043
$this->response->setRedirect($condition->getRedirectUrl());
@@ -74,6 +77,12 @@ public function match(\Magento\Framework\App\RequestInterface $request)
7477

7578
}
7679
}
80+
$request->setDispatched(true);
81+
$this->dispatched = true;
82+
return $this->actionFactory->create(
83+
'Magento\Framework\App\Action\Forward',
84+
['request' => $request]
85+
);
7786
}
7887
}
7988
}

Model/Data/TagProductLink.php

100644100755
File mode changed.

0 commit comments

Comments
 (0)