diff --git a/Block/Product/ProductList/Related.php b/Block/Product/ProductList/Related.php
index 431b4c0..831f354 100644
--- a/Block/Product/ProductList/Related.php
+++ b/Block/Product/ProductList/Related.php
@@ -9,9 +9,6 @@
namespace Tun2U\AutoRelated\Block\Product\ProductList;
-use Magento\Framework\ObjectManagerInterface;
-use Tun2U\AutoRelated\Model\Collection;
-
class Related extends \Magento\Catalog\Block\Product\ProductList\Related
{
@@ -45,9 +42,10 @@ public function __construct(
\Magento\Catalog\Model\Product\Visibility $catalogProductVisibility,
\Magento\Checkout\Model\Session $checkoutSession,
\Magento\Framework\Module\Manager $moduleManager,
- array $data = [],
- ObjectManagerInterface $helperFactory,
- Collection $collection
+ \Magento\Framework\ObjectManagerInterface $helperFactory,
+ \Tun2U\AutoRelated\Model\Collection $collection,
+ \Tun2U\AutoRelated\Helper\Data $helper,
+ array $data = []
) {
$this->_helper = $helperFactory;
$this->_registry = $context->getRegistry();
@@ -63,8 +61,12 @@ public function __construct(
$data
);
+ $this->setBlockType('related');
+
+ $this->helper = $helper;
+
// Only cache if we have something thats keyable..
- $_time = $this->_helper->get('Tun2U\AutoRelated\Helper\Data')->get_cache_lifetime();
+ $_time = $this->helper->get_cache_lifetime();
if ($_time > 0 && $cacheKey = $this->_cacheKey()) {
$this->addData(array(
@@ -75,6 +77,16 @@ 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');
@@ -90,7 +102,7 @@ protected function _prepareData()
{
parent::_prepareData();
- $_enabled = $this->_helper->get('Tun2U\AutoRelated\Helper\Data')->get_enabled();
+ $_enabled = $this->helper->get_enabled();
if ($_enabled && count($this->getItems()) == 0) {
$_products = $this->_collection->getRelatedProducts();
@@ -99,6 +111,10 @@ protected function _prepareData()
}
}
+ foreach ($this->_itemCollection as $product) {
+ $product->setDoNotUseCategoryId(true);
+ }
+
return $this;
}
diff --git a/composer.json b/composer.json
index 3e81814..7d788b6 100644
--- a/composer.json
+++ b/composer.json
@@ -1,10 +1,10 @@
{
- "name": "tun2u/module-auto-related",
+ "name": "tun2u/m2-autorelated",
"description": "Auto generate related products for Magento 2",
"keywords": ["magento2","autorelated","related","products"],
"homepage": "https://github.com/Tun2U/M2-AutoRelated",
"type": "magento2-module",
- "version": "1.0.2",
+ "version": "1.0.3",
"minimum-stability": "stable",
"license": "GPL-3.0",
"authors": [
diff --git a/etc/di.xml b/etc/di.xml
index 15ffde4..6a3d72f 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -10,4 +10,5 @@
-->
+
diff --git a/etc/module.xml b/etc/module.xml
index ac3c954..b21a5c5 100644
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -9,5 +9,8 @@
*/
-->
-
+
+
+
+
\ No newline at end of file