This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- assuming Magento 1.6.1 data model | |
SELECT DISTINCT customer_email, | |
COUNT(*) AS purchases, | |
(SELECT LEFT(created_at,11) FROM `sales_flat_order` WHERE customer_email = a.customer_email ORDER BY created_at DESC LIMIT 0,1) AS last_purchase, | |
(SELECT COUNT(*) FROM sales_flat_order_item WHERE product_type = 'simple' AND sku LIKE '%IB%' AND order_id IN (SELECT entity_id FROM `sales_flat_order` WHERE customer_email = a.customer_email)) AS icebreaker, | |
(SELECT COUNT(*) FROM sales_flat_order_item WHERE product_type = 'simple' AND sku LIKE '%TNF%' AND order_id IN (SELECT entity_id FROM `sales_flat_order` WHERE customer_email = a.customer_email)) AS the_north_face, | |
(SELECT COUNT(*) FROM sales_flat_order_item WHERE product_type = 'simple' AND sku LIKE '%MHW%' AND order_id IN (SELECT entity_id FROM `sales_flat_order` WHERE customer_email = a.customer_email)) AS mountain_hardwear, | |
(SELECT COUNT(*) FROM sales_flat_order_item WHERE product_type = 'simple' AND sku LIKE '%MAR%' AND order_id IN (SELECT entity_id FROM `sales |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
jQuery.cookie = function(name, value, options) { | |
// @author Klaus Hartl/[email protected] | |
if (typeof value != 'undefined') { | |
options = options || {}; | |
if (value === null) { | |
value = ''; | |
options.expires = -1; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$productPrice = $_product->getPrice(); | |
$coupon_code = trim(Mage::getSingleton("checkout/session")->getData("coupon_code")); | |
if ($coupon_code != '') { | |
/*** Warning - if you choose to use this code, you should probably not | |
* use the direct SQL query below, and instead use the SalesRule/Rule | |
* resource collection, which you can access by calling | |
* Mage::getModel('salesrule/rule')->getResourceCollection() | |
* | |
* This example was written a long time ago and the direct SQL query was |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<frontend> | |
<events> | |
<checkout_cart_product_add_after> | |
<observers> | |
<ApplyCoupon_apply> | |
<type>singleton</type> | |
<class>ApplyCoupon/Observer</class> | |
<method>applyCouponEvent</method> | |
</ApplyCoupon_apply> | |
</observers> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function applyCouponEvent($observer){ | |
$coupon_code = trim(Mage::getSingleton("checkout/session")->getData("coupon_code")); | |
if ($coupon_code != ''){ | |
Mage::getSingleton('checkout/cart')->getQuote()->setCouponCode($coupon_code)->save(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function indexAction() { | |
$coupon_code = $this->getRequest()->getParam('coupon_code'); | |
if ($coupon_code != '') { | |
Mage::getSingleton("checkout/session")->setData("coupon_code",$coupon_code); | |
Mage::getSingleton('checkout/cart')->getQuote()->setCouponCode($coupon_code)->save(); | |
Mage::getSingleton('core/session')->addSuccess($this->__('Coupon was automatically applied')); | |
} | |
else { | |
Mage::getSingleton("checkout/session")->setData("coupon_code",""); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<lightspeed> | |
<global> | |
REDACTED | |
</global> | |
<session> | |
REDACTED | |
</session> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function getServer() | |
{ | |
if(!$this->_server){ | |
$type = strtolower(Mage::getConfig()->getNode('lightspeed/cache/type')); | |
if ($type == "memcached"){ | |
$this->_server = Mage::getModel("lightspeed/server_memcache"); | |
}elseif ($type == "redis"){ | |
$this->_server = Mage::getModel("lightspeed/server_redis"); | |
}else{ | |
$this->_server = Mage::getModel("lightspeed/server_files"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class TinyBrick_LightSpeed_Model_Server_Redis { | |
protected $_server; | |
protected $_enabled = false; | |
public function getServer() { | |
if (!$this->_server) { | |
require_once($_SERVER['DOCUMENT_ROOT'] . '/lib/Credis/Client.php'); | |
require_once($_SERVER['DOCUMENT_ROOT'] . '/lib/Zend/Cache/Backend.php'); | |
require_once($_SERVER['DOCUMENT_ROOT'] . '/lib/Zend/Cache/Backend/Interface.php'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case 'redis': | |
return unserialize(self::$cacheData['server']->load($key)); | |
break; |