Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare products functionality #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php


/**
* FireGento_PerformanceTweaks_Model_Log_Visitor
*
* @category FireGento
* @package FireGento_PerformanceTweaks
* @author Thomas Hampe <[email protected]>
* @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();
}


}
39 changes: 39 additions & 0 deletions app/code/community/FireGento/PerformanceTweaks/Model/Session.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* Created by PhpStorm.
* User: thomas
* Date: 05.03.17
* Time: 10:49
*/

/**
* FireGento_PerformanceTweaks_Model_Session
*
* @category FireGento
* @package FireGento_PerformanceTweaks
* @author Thomas Hampe <[email protected]>
* @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;
}

}
5 changes: 5 additions & 0 deletions app/code/community/FireGento/PerformanceTweaks/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
<product_type_configurable_product_collection>FireGento_PerformanceTweaks_Model_Catalog_Resource_Product_Type_Configurable_Product_Collection</product_type_configurable_product_collection>
</rewrite>
</catalog_resource>
<log>
<rewrite>
<visitor>FireGento_PerformanceTweaks_Model_Log_Visitor</visitor>
</rewrite>
</log>
<eav>
<rewrite>
<entity_attribute_source_table>FireGento_PerformanceTweaks_Model_Eav_Entity_Attribute_Source_Table</entity_attribute_source_table>
Expand Down