Skip to content

Commit

Permalink
v.1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
alep93 committed Oct 29, 2019
1 parent f67d103 commit 8a116f8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 30 deletions.
32 changes: 8 additions & 24 deletions Block/Product/ProductList/Related.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

namespace Tun2U\AutoRelated\Block\Product\ProductList;

use Magento\Framework\ObjectManagerInterface;
use Tun2U\AutoRelated\Model\Collection;

class Related extends \Magento\Catalog\Block\Product\ProductList\Related
{

Expand Down Expand Up @@ -42,10 +45,9 @@ public function __construct(
\Magento\Catalog\Model\Product\Visibility $catalogProductVisibility,
\Magento\Checkout\Model\Session $checkoutSession,
\Magento\Framework\Module\Manager $moduleManager,
\Magento\Framework\ObjectManagerInterface $helperFactory,
\Tun2U\AutoRelated\Model\Collection $collection,
\Tun2U\AutoRelated\Helper\Data $helper,
array $data = []
array $data = [],
ObjectManagerInterface $helperFactory,
Collection $collection
) {
$this->_helper = $helperFactory;
$this->_registry = $context->getRegistry();
Expand All @@ -61,12 +63,8 @@ public function __construct(
$data
);

$this->setBlockType('related');

$this->helper = $helper;

// Only cache if we have something thats keyable..
$_time = $this->helper->get_cache_lifetime();
$_time = $this->_helper->get('Tun2U\AutoRelated\Helper\Data')->get_cache_lifetime();

if ($_time > 0 && $cacheKey = $this->_cacheKey()) {
$this->addData(array(
Expand All @@ -77,16 +75,6 @@ public function __construct(
}
}

public function getHelper()
{
// Amasty Cart
if ($this->moduleManager->isOutputEnabled('Amasty_Cart')) {
return $this->_helper->get('Amasty\Cart\Helper\Data');
}

return $this->helper;
}

protected function _cacheKey()
{
$product = $this->_registry->registry('product');
Expand All @@ -102,7 +90,7 @@ protected function _prepareData()
{
parent::_prepareData();

$_enabled = $this->helper->get_enabled();
$_enabled = $this->_helper->get('Tun2U\AutoRelated\Helper\Data')->get_enabled();

if ($_enabled && count($this->getItems()) == 0) {
$_products = $this->_collection->getRelatedProducts();
Expand All @@ -111,10 +99,6 @@ protected function _prepareData()
}
}

foreach ($this->_itemCollection as $product) {
$product->setDoNotUseCategoryId(true);
}

return $this;
}

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"keywords": ["magento2","autorelated","related","products"],
"homepage": "https://github.com/Tun2U/M2-AutoRelated",
"type": "magento2-module",
"version": "1.0.3",
"version": "1.0.4",
"minimum-stability": "stable",
"license": "GPL-3.0",
"authors": [
Expand Down
1 change: 0 additions & 1 deletion etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<preference for="Magento\Catalog\Block\Product\ProductList\Related" type="Tun2U\AutoRelated\Block\Product\ProductList\Related" />
<preference for="Amasty\Cart\Block\Product\Related" type="Tun2U\AutoRelated\Block\Product\ProductList\Related" />
</config>
5 changes: 1 addition & 4 deletions etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,5 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Tun2U_AutoRelated" setup_version="1.0.3" />
<sequence>
<module name="Amasty_Cart" />
</sequence>
<module name="Tun2U_AutoRelated" setup_version="1.0.4" />
</config>

0 comments on commit 8a116f8

Please sign in to comment.