From 100dcaa40dcf7c7ae3982f97993a29933dd96d13 Mon Sep 17 00:00:00 2001 From: Thomas Hampe Date: Sun, 5 Mar 2017 11:27:36 +0100 Subject: [PATCH] Added product compare functionality --- .../PerformanceTweaks/Model/Log/Visitor.php | 36 +++++++++++++++++ .../PerformanceTweaks/Model/Session.php | 39 +++++++++++++++++++ .../PerformanceTweaks/etc/config.xml | 5 +++ 3 files changed, 80 insertions(+) create mode 100644 app/code/community/FireGento/PerformanceTweaks/Model/Log/Visitor.php create mode 100644 app/code/community/FireGento/PerformanceTweaks/Model/Session.php diff --git a/app/code/community/FireGento/PerformanceTweaks/Model/Log/Visitor.php b/app/code/community/FireGento/PerformanceTweaks/Model/Log/Visitor.php new file mode 100644 index 0000000..fe31212 --- /dev/null +++ b/app/code/community/FireGento/PerformanceTweaks/Model/Log/Visitor.php @@ -0,0 +1,36 @@ + + * @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3) + */ +class FireGento_PerformanceTweaks_Model_Log_Visitor extends Mage_Log_Model_Visitor +{ + + /** + * Returns a "fake" visitor id for product compare + * + * @return int + */ + public function getId() + { + if (!$this->getData('visitor_id')) { + /** @var FireGento_PerformanceTweaks_Model_Session $session */ + $session = Mage::getModel('firegento_performancetweaks/session'); + $this->setId($session->getVisitorId()); + } + return parent::getId(); + } + + public function getVisitorId() + { + return $this->getId(); + } + + +} \ No newline at end of file diff --git a/app/code/community/FireGento/PerformanceTweaks/Model/Session.php b/app/code/community/FireGento/PerformanceTweaks/Model/Session.php new file mode 100644 index 0000000..32da487 --- /dev/null +++ b/app/code/community/FireGento/PerformanceTweaks/Model/Session.php @@ -0,0 +1,39 @@ + + * @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3) + */ +class FireGento_PerformanceTweaks_Model_Session extends Mage_Core_Model_Session_Abstract +{ + + + public function __construct() + { + $this->init('firegento_performancetweaks'); + } + + public function getVisitorId() + { + if (!$this->hasData('visitor_id')) { + $this->setData('visitor_id', $this->_generateVisitorId()); + } + return $this->getData('visitor_id'); + } + + protected function _generateVisitorId() + { + return $this->getSessionId() ? crc32($this->getSessionId()) : null; + } + +} \ No newline at end of file diff --git a/app/code/community/FireGento/PerformanceTweaks/etc/config.xml b/app/code/community/FireGento/PerformanceTweaks/etc/config.xml index 1c48ae1..2eec4fc 100755 --- a/app/code/community/FireGento/PerformanceTweaks/etc/config.xml +++ b/app/code/community/FireGento/PerformanceTweaks/etc/config.xml @@ -25,6 +25,11 @@ FireGento_PerformanceTweaks_Model_Catalog_Resource_Product_Type_Configurable_Product_Collection + + + FireGento_PerformanceTweaks_Model_Log_Visitor + + FireGento_PerformanceTweaks_Model_Eav_Entity_Attribute_Source_Table