BlueknowRecommender - Version 1.0.0

Version Notes

Release 1.0.0.

Download this release

Release Info

Developer Magento Core Team
Extension BlueknowRecommender
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (45) hide show
  1. app/code/community/Blueknow/Recommender/Block/Base.php +55 -0
  2. app/code/community/Blueknow/Recommender/Block/Cart/Recommender.php +46 -0
  3. app/code/community/Blueknow/Recommender/Block/Checkout/Tracker.php +48 -0
  4. app/code/community/Blueknow/Recommender/Block/Customer/Tracker.php +48 -0
  5. app/code/community/Blueknow/Recommender/Block/Product/Base.php +39 -0
  6. app/code/community/Blueknow/Recommender/Block/Product/Recommender.php +28 -0
  7. app/code/community/Blueknow/Recommender/Block/Product/Tracker.php +21 -0
  8. app/code/community/Blueknow/Recommender/Helper/Category.php +43 -0
  9. app/code/community/Blueknow/Recommender/Helper/Currency.php +50 -0
  10. app/code/community/Blueknow/Recommender/Helper/Data.php +43 -0
  11. app/code/community/Blueknow/Recommender/Helper/Price.php +42 -0
  12. app/code/community/Blueknow/Recommender/Model/Cart.php +38 -0
  13. app/code/community/Blueknow/Recommender/Model/Checkout.php +77 -0
  14. app/code/community/Blueknow/Recommender/Model/Checkout/Order.php +131 -0
  15. app/code/community/Blueknow/Recommender/Model/Checkout/Product.php +109 -0
  16. app/code/community/Blueknow/Recommender/Model/Configuration.php +223 -0
  17. app/code/community/Blueknow/Recommender/Model/Currency.php +64 -0
  18. app/code/community/Blueknow/Recommender/Model/Customer.php +42 -0
  19. app/code/community/Blueknow/Recommender/Model/Observer.php +44 -0
  20. app/code/community/Blueknow/Recommender/Model/Product.php +181 -0
  21. app/code/community/Blueknow/Recommender/Model/Session.php +46 -0
  22. app/code/community/Blueknow/Recommender/Model/Source/Numberofrecommendations.php +31 -0
  23. app/code/community/Blueknow/Recommender/documentation/Blueknow_Recommender_1.0.0_Gui/314/201a_de_Instalacio/314/201n.pdf +0 -0
  24. app/code/community/Blueknow/Recommender/documentation/Blueknow_Recommender_1.0.0_Installation_Guide.pdf +0 -0
  25. app/code/community/Blueknow/Recommender/documentation/README.txt +66 -0
  26. app/code/community/Blueknow/Recommender/etc/config.xml +126 -0
  27. app/code/community/Blueknow/Recommender/etc/system.xml +122 -0
  28. app/code/community/Blueknow/Recommender/sql/recommender_setup/uninstall.sql +17 -0
  29. app/design/frontend/default/default/layout/blueknow_recommender.xml +65 -0
  30. app/design/frontend/default/default/template/blueknow/cart/recommender.phtml +37 -0
  31. app/design/frontend/default/default/template/blueknow/cart/recommender_widget.phtml +78 -0
  32. app/design/frontend/default/default/template/blueknow/checkout/tracker.phtml +45 -0
  33. app/design/frontend/default/default/template/blueknow/common/recommender_renderer.phtml +49 -0
  34. app/design/frontend/default/default/template/blueknow/common/recommender_widget_footer.phtml +30 -0
  35. app/design/frontend/default/default/template/blueknow/customer/tracker.phtml +31 -0
  36. app/design/frontend/default/default/template/blueknow/product/recommender.phtml +33 -0
  37. app/design/frontend/default/default/template/blueknow/product/recommender_widget.phtml +67 -0
  38. app/design/frontend/default/default/template/blueknow/product/tracker.phtml +60 -0
  39. app/etc/modules/Blueknow_Recommender.xml +31 -0
  40. app/locale/de_DE/Blueknow_recommender.csv +14 -0
  41. app/locale/en_US/Blueknow_recommender.csv +14 -0
  42. app/locale/es_ES/Blueknow_recommender.csv +14 -0
  43. app/locale/fr_FR/Blueknow_recommender.csv +14 -0
  44. app/locale/pt_PT/Blueknow_recommender.csv +14 -0
  45. package.xml +20 -0
app/code/community/Blueknow/Recommender/Block/Base.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Base block.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Block_Base extends Mage_Core_Block_Template {
20
+
21
+ /**
22
+ * Configuration domain object.
23
+ * @var Blueknow_Recommender_Model_Configuration
24
+ */
25
+ protected $_configuration;
26
+
27
+ public function _beforeToHtml() {
28
+ parent::_beforeToHtml();
29
+ $this->_configuration = Mage::getModel('blueknow_recommender/Configuration');
30
+ }
31
+
32
+ public function _toHtml() {
33
+ //the block is rendered only if module is enabled
34
+ if ($this->_configuration->isEnabled()) {
35
+ return parent::_toHtml();
36
+ }
37
+ return '';
38
+ }
39
+
40
+ /**
41
+ * Get Blueknow service configuration.
42
+ * @return Blueknow_Recommender_Model_Configuration
43
+ */
44
+ public function getConfig() {
45
+ return $this->_configuration;
46
+ }
47
+
48
+ /**
49
+ * Get current session.
50
+ * @return Blueknow_Recommender_Model_Session
51
+ */
52
+ protected function _getSession() {
53
+ return Mage::getSingleton('blueknow_recommender/session');
54
+ }
55
+ }
app/code/community/Blueknow/Recommender/Block/Cart/Recommender.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shopping cart recommender block.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Block_Cart_Recommender extends Blueknow_Recommender_Block_Base {
20
+
21
+ /**
22
+ * Cart domain object.
23
+ * @var Blueknow_Recommender_Model_Cart
24
+ */
25
+ protected $_cart;
26
+
27
+ public function _beforeToHtml() {
28
+ parent::_beforeToHtml();
29
+ $this->_cart = Mage::getModel('blueknow_recommender/Cart');
30
+ }
31
+
32
+ public function _toHtml() {
33
+ //the block is rendered only if up-sell is enabled and there are one or more products inside shopping cart
34
+ if ($this->_configuration->isUpSellEnabled() && count($this->_cart->getProducts()) > 0) {
35
+ return parent::_toHtml();
36
+ }
37
+ return '';
38
+ }
39
+
40
+ /**
41
+ * Get current shopping cart.
42
+ */
43
+ public function getCart() {
44
+ return $this->_cart;
45
+ }
46
+ }
app/code/community/Blueknow/Recommender/Block/Checkout/Tracker.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Checkout tracker block.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Block_Checkout_Tracker extends Blueknow_Recommender_Block_Base {
20
+
21
+ /**
22
+ * Checkout domain object.
23
+ * @var Blueknow_Recommender_Model_Checkout
24
+ */
25
+ protected $_checkout;
26
+
27
+ public function _beforeToHtml() {
28
+ parent::_beforeToHtml();
29
+ $this->_checkout = Mage::getModel('blueknow_recommender/Checkout');
30
+ }
31
+
32
+ public function _toHtml() {
33
+ $orders = $this->_checkout->getOrders();
34
+ //the block is rendered only if there are one or more orders
35
+ if (!empty($orders)) {
36
+ return parent::_toHtml();
37
+ }
38
+ return '';
39
+ }
40
+
41
+ /**
42
+ * Get current checkout considering both one page and multishipping checkout.
43
+ * @return Blueknow_Recommender_Model_Checkout
44
+ */
45
+ public function getCheckout() {
46
+ return $this->_checkout;
47
+ }
48
+ }
app/code/community/Blueknow/Recommender/Block/Customer/Tracker.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Customer tracker block.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Block_Customer_Tracker extends Blueknow_Recommender_Block_Base {
20
+
21
+ /**
22
+ * Customer domain object.
23
+ * @var Blueknow_Recommender_Model_Customer
24
+ */
25
+ protected $_customer;
26
+
27
+ public function _beforeToHtml() {
28
+ parent::_beforeToHtml();
29
+ $this->_customer = Mage::getModel('blueknow_recommender/Customer');
30
+ }
31
+
32
+ public function _toHtml() {
33
+ //the block is rendered only on first customer login (once per session)
34
+ if ($this->_getSession()->isNewLogin()) {
35
+ Mage::dispatchEvent('customer_login_tracked');
36
+ return parent::_toHtml();
37
+ }
38
+ return '';
39
+ }
40
+
41
+ /**
42
+ * Get current customer (user) logged.
43
+ * @return Blueknow_Recommender_Model_Customer
44
+ */
45
+ public function getCustomer() {
46
+ return $this->_customer;
47
+ }
48
+ }
app/code/community/Blueknow/Recommender/Block/Product/Base.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Base product block.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Block_Product_Base extends Blueknow_Recommender_Block_Base {
20
+
21
+ /**
22
+ * Product domain object.
23
+ * @var Blueknow_Recommender_Model_Product
24
+ */
25
+ protected $_product;
26
+
27
+ public function _beforeToHtml() {
28
+ parent::_beforeToHtml();
29
+ $this->_product = Mage::getModel('blueknow_recommender/Product');
30
+ }
31
+
32
+ /**
33
+ * Get current product.
34
+ * @return Blueknow_Recommender_Model_Product
35
+ */
36
+ public function getProduct() {
37
+ return $this->_product;
38
+ }
39
+ }
app/code/community/Blueknow/Recommender/Block/Product/Recommender.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Product recommender block.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Block_Product_Recommender extends Blueknow_Recommender_Block_Product_Base {
20
+
21
+ public function _toHtml() {
22
+ //the block is rendered only if cross-sell is enabled (recommendations in product detail page)
23
+ if ($this->_configuration->isCrossSellEnabled()) {
24
+ return parent::_toHtml();
25
+ }
26
+ return '';
27
+ }
28
+ }
app/code/community/Blueknow/Recommender/Block/Product/Tracker.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Product tracker block.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Block_Product_Tracker extends Blueknow_Recommender_Block_Product_Base {
20
+ //empty
21
+ }
app/code/community/Blueknow/Recommender/Helper/Category.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Product category helper.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Helper_Category extends Mage_Core_Helper_Abstract {
20
+
21
+ /**
22
+ * Return current category path or get it from current category and creating array of categories paths.
23
+ * @return array Items defined as ('id', 'name') pair.
24
+ */
25
+ public function getCategoryPath() {
26
+ $path = array();
27
+ if ($category = Mage::registry('current_category')) {
28
+ $pathInStore = $category->getPathInStore();
29
+ $pathIds = array_reverse(explode(',', $pathInStore));
30
+ $categories = $category->getParentCategories();
31
+ //add category path
32
+ foreach ($pathIds as $categoryId) {
33
+ if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
34
+ $path['category' . $categoryId] = array(
35
+ 'id' => $categoryId,
36
+ 'name' => addslashes($categories[$categoryId]->getName())
37
+ );
38
+ }
39
+ }
40
+ }
41
+ return $path;
42
+ }
43
+ }
app/code/community/Blueknow/Recommender/Helper/Currency.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Currency helper.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Helper_Currency extends Mage_Core_Helper_Abstract {
20
+
21
+ /**
22
+ * Get current currency.
23
+ * @return Blueknow_Recommender_Model_Currency.
24
+ */
25
+ public function getCurrentCurrency() {
26
+ $code = Mage::app()->getStore()->getCurrentCurrencyCode();
27
+ return $this->_getCurrency($code);
28
+ }
29
+
30
+ /**
31
+ * Get default currency.
32
+ * @return Blueknow_Recommender_Model_Currency.
33
+ */
34
+ public function getDefaultCurrency() {
35
+ $code = Mage::app()->getStore()->getDefaultCurrencyCode();
36
+ return $this->_getCurrency($code);
37
+ }
38
+
39
+ /**
40
+ * Get currency from ISO code.
41
+ * @param string $code
42
+ */
43
+ protected function _getCurrency($code) {
44
+ $zcurrency = Mage::app()->getLocale()->currency($code);
45
+ $tcurrency = Mage::getModel('blueknow_recommender/Currency');
46
+ $tcurrency->setCode($zcurrency->getShortName());
47
+ $tcurrency->setSymbol($zcurrency->getSymbol());
48
+ return $tcurrency;
49
+ }
50
+ }
app/code/community/Blueknow/Recommender/Helper/Data.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Base helper.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Helper_Data extends Mage_Core_Helper_Abstract {
20
+
21
+ /**
22
+ * Default number of characters for truncation.
23
+ * @var int
24
+ */
25
+ const DEFAULT_TRUNCATION_LENGTH = 255;
26
+
27
+ /**
28
+ * Default character sequence to use at the end of the truncation.
29
+ * @var string
30
+ */
31
+ const DEFAULT_TRUNCATION_ETC = '...';
32
+
33
+ /**
34
+ * Single-simple-line transformation: no multiple line, no embedded HTML code. Also a truncation is applied.
35
+ * @param string $string
36
+ */
37
+ public function ssline($string) {
38
+ $string_helper = Mage::helper('core/string');
39
+ $string = trim(addslashes(preg_replace("#(\r\n|\n|\r)#s", ' ', strip_tags($string))));
40
+ $reminder = '';
41
+ return $string_helper->truncate($string, self::DEFAULT_TRUNCATION_LENGTH, self::DEFAULT_TRUNCATION_ETC, $reminder, FALSE);
42
+ }
43
+ }
app/code/community/Blueknow/Recommender/Helper/Price.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Product price helper.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Helper_Price extends Mage_Core_Helper_Abstract {
20
+
21
+ /**
22
+ * Get final price of a given product including taxes and currency conversion.
23
+ * @param Mage_Catalog_Model_Product $product
24
+ */
25
+ public function getFinalPrice($product) {
26
+ //additional helpers
27
+ $taxHelper = Mage::helper('tax');
28
+ $coreHelper = Mage::helper('core');
29
+ $weeeHelper = Mage::helper('weee');
30
+ //prices options
31
+ $finalPrice = $taxHelper->getPrice($product, $product->getFinalPrice(), true); //final price including taxes
32
+ if ($finalPrice <= 0) {
33
+ //when no price found, minimal price is loaded
34
+ $minimalPrice = $product->getMinimalPrice() ? $product->getMinimalPrice() : Mage::getModel('bundle/Product_Price')->getPrices($product, 'min');
35
+ $finalPrice = $taxHelper->getPrice($product, $minimalPrice, true); //final price including taxes
36
+ }
37
+ //tax amount
38
+ $weeeTaxAmount = $weeeHelper->getAmount($product);
39
+ //price with taxes and currency conversion applied
40
+ return $coreHelper->currency($finalPrice + $weeeTaxAmount, false, false);
41
+ }
42
+ }
app/code/community/Blueknow/Recommender/Model/Cart.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shopping cart object model.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Model_Cart extends Varien_Object {
20
+
21
+ /**
22
+ * Products (identifiers) inside shopping cart.
23
+ * @var array
24
+ */
25
+ private $_products;
26
+
27
+ /**
28
+ * Get products form current shopping cart.
29
+ * @return array
30
+ */
31
+ public function getProducts() {
32
+ if (!$this->_products) { //empty cart is directly returned
33
+ $cart = Mage::helper('checkout/cart')->getCart();
34
+ $this->_products = $cart ? $cart->getProductIds() : array();
35
+ }
36
+ return $this->_products;
37
+ }
38
+ }
app/code/community/Blueknow/Recommender/Model/Checkout.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Checkout object model.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Model_Checkout extends Varien_Object {
20
+
21
+ /**
22
+ * Collection of orders.
23
+ * @var array of Blueknow_Recommender_Model_Checkout_Order
24
+ */
25
+ private $_orders = array();
26
+
27
+ /**
28
+ * Get last successfull orders from current session.
29
+ * @return array of Blueknow_Recommender_Model_Checkout_Order
30
+ */
31
+ public function getOrders() {
32
+ if (empty($this->_orders)) {
33
+ //get last quote identifier
34
+ $quoteId = Mage::getSingleton('checkout/session')->getLastQuoteId();
35
+ if ($quoteId) {
36
+ $store = Mage::app()->getStore();
37
+ //orders registry
38
+ $ordersId = array();
39
+ //get quote
40
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
41
+ //load orders (one or more orders according to the type of shipping used: single or mutiple)
42
+ $orders = Mage::getResourceModel('sales/order_collection')->addAttributeToFilter('quote_id', $quoteId)->load();
43
+ //orders iteration
44
+ foreach ($orders as $order) {
45
+ $orderId = $order->getIncrementId();
46
+ if (in_array($orderId, $ordersId)) {
47
+ continue; //order already processed
48
+ }
49
+ //register order
50
+ $ordersId[] = $orderId;
51
+ //create our own order
52
+ $bOrder = Mage::getModel('blueknow_recommender/Checkout_Order');
53
+ $bOrder->setId($orderId);
54
+ $bOrder->setTotal($store->roundPrice($order->getBaseGrandTotal()));
55
+ $bOrder->setTax($store->roundPrice($order->getBaseTaxAmount()));
56
+ $bOrder->setShipping($store->roundPrice($order->getBaseShippingAmount()));
57
+ foreach ($order->getAllItems() as $item) {
58
+ if ($item->getParentItemId()) {
59
+ continue;
60
+ }
61
+ $bProduct = Mage::getModel('blueknow_recommender/Checkout_Product');
62
+ $bProduct->setId($item->getProductId());
63
+ $bProduct->setPrice($store->roundPrice($item->getBasePrice()));
64
+ $bProduct->setQuantity(intval($item->getQtyOrdered()));
65
+ //get saleable information
66
+ $bProduct->setSaleable(Mage::getModel('catalog/product')->load($item->getProductId())->isSaleable());
67
+ //add product
68
+ $bOrder->addProduct($bProduct);
69
+ }
70
+ //add order
71
+ $this->_orders[] = $bOrder;
72
+ }
73
+ }
74
+ }
75
+ return $this->_orders;
76
+ }
77
+ }
app/code/community/Blueknow/Recommender/Model/Checkout/Order.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Order object model.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Model_Checkout_Order extends Varien_Object {
20
+
21
+ /**
22
+ * Order identifier.
23
+ * @var string
24
+ */
25
+ private $_id;
26
+
27
+ /**
28
+ * Total amount including taxes and shipping.
29
+ * @var number|string
30
+ */
31
+ private $_total;
32
+
33
+ /**
34
+ * Taxes amount.
35
+ * @var number|string
36
+ */
37
+ private $_tax;
38
+
39
+ /**
40
+ * Shipping amount.
41
+ * @var number|string
42
+ */
43
+ private $_shipping;
44
+
45
+ /**
46
+ * List of ordered products.
47
+ * @var Blueknow_Recommender_Model_Checkout_Product
48
+ */
49
+ private $_products = array();
50
+
51
+ /**
52
+ * Get order identifier.
53
+ * @return string
54
+ */
55
+ public function getId() {
56
+ return $this->_id;
57
+ }
58
+
59
+ /**
60
+ * Set order identifier.
61
+ * @param string $id
62
+ */
63
+ public function setId($id) {
64
+ $this->_id = $id;
65
+ }
66
+
67
+ /**
68
+ * Get total amount.
69
+ * @return number|string
70
+ */
71
+ public function getTotal() {
72
+ return $this->_total;
73
+ }
74
+
75
+ /**
76
+ * Set total amount.
77
+ * @param number|string $total
78
+ */
79
+ public function setTotal($total) {
80
+ $this->_total = $total;
81
+ }
82
+
83
+ /**
84
+ * Get taxes amount.
85
+ * @return number|string
86
+ */
87
+ public function getTax() {
88
+ return $this->_tax;
89
+ }
90
+
91
+ /**
92
+ * Set taxes amount.
93
+ * @param number|string $tax
94
+ */
95
+ public function setTax($tax) {
96
+ $this->_tax = $tax;
97
+ }
98
+
99
+ /**
100
+ * Get shipping amount.
101
+ * @return number|string
102
+ */
103
+ public function getShipping() {
104
+ return $this->_shipping;
105
+ }
106
+
107
+ /**
108
+ * Set shipping amount.
109
+ * @param number|string $shipping
110
+ */
111
+ public function setShipping($shipping) {
112
+ $this->_shipping = $shipping;
113
+ }
114
+
115
+ /**
116
+ * Get ordered products.
117
+ * @return array
118
+ * @see Blueknow_Recommender_Model_Checkout_Product
119
+ */
120
+ public function getProducts() {
121
+ return $this->_products;
122
+ }
123
+
124
+ /**
125
+ * Add a new product to the current order.
126
+ * @param Blueknow_Recommender_Model_Checkout_Product $product
127
+ */
128
+ public function addProduct($product) {
129
+ $this->_products[] = $product;
130
+ }
131
+ }
app/code/community/Blueknow/Recommender/Model/Checkout/Product.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ordered product object model.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Model_Checkout_Product extends Varien_Object {
20
+
21
+ /**
22
+ * Ordered product identifier.
23
+ * @var string
24
+ */
25
+ private $_id;
26
+
27
+ /**
28
+ * Ordered product price. It could be different from orginal product price due to discounts or something like this.
29
+ * @var number|string
30
+ */
31
+ private $_price;
32
+
33
+ /**
34
+ * Ordered product quantity.
35
+ * @var number
36
+ */
37
+ private $_quantity;
38
+
39
+ /**
40
+ * Product is-saleable flag.
41
+ * @var bool
42
+ */
43
+ private $_saleable;
44
+
45
+ /**
46
+ * Get ordered product identifier.
47
+ * @return string
48
+ */
49
+ public function getId() {
50
+ return $this->_id;
51
+ }
52
+
53
+ /**
54
+ * Set ordered product identifier.
55
+ * @param string $id
56
+ */
57
+ public function setId($id) {
58
+ $this->_id = $id;
59
+ }
60
+
61
+ /**
62
+ * Get ordered product price.
63
+ * @return number|string
64
+ */
65
+ public function getPrice() {
66
+ return $this->_price;
67
+ }
68
+
69
+ /**
70
+ * Set ordered product price. It should include taxes and currency conversion applied.
71
+ * Unitary price. No currency symbol.
72
+ * @param number|string $price
73
+ */
74
+ public function setPrice($price) {
75
+ $this->_price = $price;
76
+ }
77
+
78
+ /**
79
+ * Get ordered product quantity.
80
+ * @return number|string.
81
+ */
82
+ public function getQuantity() {
83
+ return $this->_quantity;
84
+ }
85
+
86
+ /**
87
+ * Set ordered product quantity.
88
+ * @param number|string $qty
89
+ */
90
+ public function setQuantity($qty) {
91
+ $this->_quantity = $qty;
92
+ }
93
+
94
+ /**
95
+ * Get if product is saleable (in stock)
96
+ * @return bool
97
+ */
98
+ public function isSaleable() {
99
+ return $this->_saleable;
100
+ }
101
+
102
+ /**
103
+ * Set if product is saleable (in stock) after to be ordered (successfull transaction).
104
+ * @param bool $saleable
105
+ */
106
+ public function setSaleable($saleable) {
107
+ $this->_saleable = $saleable;
108
+ }
109
+ }
app/code/community/Blueknow/Recommender/Model/Configuration.php ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Blueknow Recommender configuration object model.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Model_Configuration extends Varien_Object {
20
+
21
+ /*Configuration XML paths*/
22
+
23
+ const XML_PATH_BLUEKNOW_ENABLED = 'blueknow/recommender/enabled';
24
+ const XML_PATH_BLUEKNOW_BK_NUMBER = 'blueknow/recommender/bk_number';
25
+ const XML_PATH_BLUEKNOW_CROSS_SELL_ENABLED = 'blueknow/item_to_item/enabled';
26
+ const XML_PATH_BLUEKNOW_CROSS_SELL_NOR = 'blueknow/item_to_item/nor';
27
+ const XML_PATH_BLUEKNOW_UP_SELL_ENABLED = 'blueknow/item_to_basket/enabled';
28
+ const XML_PATH_BLUEKNOW_UP_SELL_NOR = 'blueknow/item_to_basket/nor';
29
+
30
+ /**
31
+ * Blueknow Recommender extension descriptor/identifier.
32
+ * @var string
33
+ */
34
+ private $_descriptor;
35
+
36
+ /**
37
+ * Service-is-enabled flag.
38
+ * @var bool
39
+ */
40
+ private $_enabled;
41
+
42
+ /**
43
+ * BK number assigned to eCommerce.
44
+ * @var string
45
+ */
46
+ private $_bkNumber;
47
+
48
+ /**
49
+ * Cross-sell-is-enabled flag.
50
+ * @var bool
51
+ */
52
+ private $_crossSellEnabled;
53
+
54
+ /**
55
+ * Number of cross-sell recommendations to request.
56
+ * @var number
57
+ */
58
+ private $_crossSellNOR;
59
+
60
+ /**
61
+ * Up-sell-is-enabled flag.
62
+ * @var bool
63
+ */
64
+ private $_upSellEnabled;
65
+
66
+ /**
67
+ * Number of up-sell recommendations to request.
68
+ * @var number
69
+ */
70
+ private $_upSellNOR;
71
+
72
+ /**
73
+ * Base URL where resource are loaded from (JavaScript APIs, logos, and so on).
74
+ * @var string
75
+ */
76
+ private $_baseUrl;
77
+
78
+ /**
79
+ * Current language ISO name (http://en.wikipedia.org/wiki/ISO_639).
80
+ * @var string
81
+ */
82
+ private $_language;
83
+
84
+ /**
85
+ * Current currency.
86
+ * @var Blueknow_Recommender_Model_Currency.
87
+ */
88
+ private $_currentCurrency;
89
+
90
+ /**
91
+ * Default/base currency.
92
+ * @var Blueknow_Recommender_Model_Currency.
93
+ */
94
+ private $_defaultCurrency;
95
+
96
+ /**
97
+ * Get service-is-enabled flag from configuration.
98
+ * @return bool
99
+ */
100
+ public function isEnabled() {
101
+ if (empty($this->_enabled)) {
102
+ $bkNumber = $this->getBKNumber();
103
+ $this->_enabled = Mage::getStoreConfigFlag(self::XML_PATH_BLUEKNOW_ENABLED) && !empty($bkNumber);
104
+ }
105
+ return $this->_enabled;
106
+ }
107
+
108
+ /**
109
+ * Get BK number from configuration.
110
+ * @return string
111
+ */
112
+ public function getBKNumber() {
113
+ if (empty($this->_bkNumber)) {
114
+ $this->_bkNumber = Mage::getStoreConfig(self::XML_PATH_BLUEKNOW_BK_NUMBER);
115
+ }
116
+ return $this->_bkNumber;
117
+ }
118
+
119
+ /**
120
+ * Get cross-sell-is-enabled flag from configuration.
121
+ * @return bool
122
+ */
123
+ public function isCrossSellEnabled() {
124
+ if (empty($this->_crossSellEnabled)) {
125
+ $this->_crossSellEnabled = Mage::getStoreConfigFlag(self::XML_PATH_BLUEKNOW_CROSS_SELL_ENABLED);
126
+ }
127
+ return $this->_crossSellEnabled;
128
+ }
129
+
130
+ /**
131
+ * Get number of cross-sell recommendations from configuration.
132
+ * @return number
133
+ */
134
+ public function getCrossSellNOR() {
135
+ if (empty($this->_crossSellNOR)) {
136
+ $this->_crossSellNOR = Mage::getStoreConfig(self::XML_PATH_BLUEKNOW_CROSS_SELL_NOR);
137
+ }
138
+ return $this->_crossSellNOR;
139
+ }
140
+
141
+ /**
142
+ * Get up-sell-is-enabled flag from configuration.
143
+ * @return bool
144
+ */
145
+ public function isUpSellEnabled() {
146
+ if (empty($this->_upSellEnabled)) {
147
+ $this->_upSellEnabled = Mage::getStoreConfigFlag(self::XML_PATH_BLUEKNOW_UP_SELL_ENABLED);
148
+ }
149
+ return $this->_upSellEnabled;
150
+ }
151
+
152
+ /**
153
+ * Get number of up-sell recommendations from configuration.
154
+ * @return number
155
+ */
156
+ public function getUpSellNOR() {
157
+ if (empty($this->_upSellNOR)) {
158
+ $this->_upSellNOR = Mage::getStoreConfig(self::XML_PATH_BLUEKNOW_UP_SELL_NOR);
159
+ }
160
+ return $this->_upSellNOR;
161
+ }
162
+
163
+ /**
164
+ * Get base URL where resources are loaded from.
165
+ * @return string
166
+ */
167
+ public function getBaseURL() {
168
+ if (empty($this->_baseUrl)) {
169
+ $protocol = Mage::app()->getStore()->isCurrentlySecure() ? 'https' : 'http';
170
+ $this->_baseUrl = $protocol . '://static.blueknow.com';
171
+ }
172
+ return $this->_baseUrl;
173
+ }
174
+
175
+ /**
176
+ * Get currency language ISO name.
177
+ * @return string
178
+ */
179
+ public function getLanguage() {
180
+ if (empty($this->_language)) {
181
+ $isoCode = Mage::app()->getLocale()->getLocale();
182
+ $parts = explode('_', $isoCode);
183
+ $language = $parts[0];
184
+ $this->_language = strtoupper($language);
185
+ }
186
+ return $this->_language;
187
+ }
188
+
189
+ /**
190
+ * Get current currency.
191
+ * @return Blueknow_Recommender_Model_Currency.
192
+ */
193
+ public function getCurrentCurrency() {
194
+ if (!$this->_currentCurrency) {
195
+ $this->_currentCurrency = Mage::helper('blueknow_recommender/Currency')->getCurrentCurrency();
196
+ }
197
+ return $this->_currentCurrency;
198
+ }
199
+
200
+ /**
201
+ * Get default currency.
202
+ * @return Blueknow_Recommender_Model_Currency.
203
+ */
204
+ public function getDefaultCurrency() {
205
+ if (!$this->_defaultCurrency) {
206
+ $this->_defaultCurrency = Mage::helper('blueknow_recommender/Currency')->getDefaultCurrency();
207
+ }
208
+ return $this->_defaultCurrency;
209
+ }
210
+
211
+ /**
212
+ * Get module descriptor.
213
+ * @return string
214
+ */
215
+ public function getDescriptor() {
216
+ if (empty($this->_descriptor)) {
217
+ $descriptor = Mage::getConfig()->getModuleConfig('Blueknow_Recommender')->version;
218
+ $descriptor = str_replace('.', '_', $descriptor);
219
+ $this->_descriptor = 'mag_' . $descriptor;
220
+ }
221
+ return $this->_descriptor;
222
+ }
223
+ }
app/code/community/Blueknow/Recommender/Model/Currency.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Currency object model.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Model_Currency extends Varien_Object {
20
+
21
+ /**
22
+ * Currency ISO code (http://es.wikipedia.org/wiki/ISO_4217).
23
+ * @var string
24
+ */
25
+ private $_code;
26
+
27
+ /**
28
+ * Currency symbol.
29
+ * @var string
30
+ */
31
+ private $_symbol;
32
+
33
+ /**
34
+ * Get currency ISO code.
35
+ * @return string
36
+ */
37
+ public function getCode() {
38
+ return $this->_code;
39
+ }
40
+
41
+ /**
42
+ * Set currency ISO code. It must be a valid ISO 4217 code name.
43
+ * @param string $code
44
+ */
45
+ public function setCode($code) {
46
+ $this->_code = $code;
47
+ }
48
+
49
+ /**
50
+ * Get currency symbol.
51
+ * @return string
52
+ */
53
+ public function getSymbol() {
54
+ return $this->_symbol;
55
+ }
56
+
57
+ /**
58
+ * Set currency symbol (e.g. EURO, �, eur)
59
+ * @param string $symbol
60
+ */
61
+ public function setSymbol($symbol) {
62
+ $this->_symbol = $symbol;
63
+ }
64
+ }
app/code/community/Blueknow/Recommender/Model/Customer.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Customer object model.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Model_Customer extends Varien_Object {
20
+
21
+ /**
22
+ * Customer identifier.
23
+ * @var mixed|null
24
+ */
25
+ private $_customerId;
26
+
27
+ /**
28
+ * Get the identifier of the current user logged, if any.
29
+ * @return mixed|null
30
+ */
31
+ public function getIdentifier() {
32
+ if (empty($this->_customerId)) {
33
+ $session = Mage::getSingleton('customer/session');
34
+ if ($session->isLoggedIn()) {
35
+ $this->_customerId = $session->getCustomer()->getId();
36
+ } else {
37
+ $this->_customerId = null; //not logged
38
+ }
39
+ }
40
+ return $this->_customerId;
41
+ }
42
+ }
app/code/community/Blueknow/Recommender/Model/Observer.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Blueknow Recommender observer.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Model_Observer {
20
+
21
+ /**
22
+ * Activate new-login flag from Blueknow Recommender session scope.
23
+ * @param Varien_Event_Observer $observer
24
+ */
25
+ public function setNewLoginWhenCustomerLogIn(Varien_Event_Observer $observer) {
26
+ $this->_getSession()->setNewLogin();
27
+ }
28
+
29
+ /**
30
+ * Deactivate new-login flag from Blueknow Recommender session scope.
31
+ * @param Varien_Event_Observer $observer
32
+ */
33
+ public function unsetNewLoginAfterTracking(Varien_Event_Observer $observer) {
34
+ $this->_getSession()->unsetNewLogin();
35
+ }
36
+
37
+ /**
38
+ * Retrieve Blueknow Recommender session object.
39
+ * @return Mage_Core_Model_Session_Abstract
40
+ */
41
+ protected function _getSession() {
42
+ return Mage::getSingleton('blueknow_recommender/session');
43
+ }
44
+ }
app/code/community/Blueknow/Recommender/Model/Product.php ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Product object model.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Model_Product extends Varien_Object {
20
+
21
+ const DATA_PRODUCT = 'current_product';
22
+
23
+ /**
24
+ * Determine if current product is available.
25
+ * @var bool
26
+ */
27
+ private $_hasProduct;
28
+
29
+ /**
30
+ * Product identifier.
31
+ * @var string
32
+ */
33
+ private $_id;
34
+
35
+ /**
36
+ * Product name.
37
+ * @var string
38
+ */
39
+ private $_name;
40
+
41
+ /**
42
+ * Product single-line description.
43
+ * @var string
44
+ */
45
+ private $_description;
46
+
47
+ /**
48
+ * Product absolute URL.
49
+ * @var string
50
+ */
51
+ private $_url;
52
+
53
+ /**
54
+ * Product image absolute URL.
55
+ * @var string
56
+ */
57
+ private $_imageUrl;
58
+
59
+ /**
60
+ * Product price including taxes and currency conversion. No currency symbol.
61
+ * @var number|string
62
+ */
63
+ private $_price;
64
+
65
+ /**
66
+ * Determine if product is in stock (saleable).
67
+ * @var bool
68
+ */
69
+ private $_inStock;
70
+
71
+ /**
72
+ * Categories (and subcategories) where product is placed.
73
+ * @var array of pairs ('id', 'name')
74
+ */
75
+ private $_categories;
76
+
77
+ public function __construct() {
78
+ parent::__construct();
79
+ $this->_getProduct(); //loading of current product
80
+ $this->_hasProduct = $this->hasData(self::DATA_PRODUCT) && $this->getData(self::DATA_PRODUCT) instanceof Mage_Catalog_Model_Product;
81
+ }
82
+
83
+ /**
84
+ * Get current product identifier.
85
+ * @return string
86
+ */
87
+ public function getIdentifier() {
88
+ if (empty($this->_id) && $this->_hasProduct) {
89
+ $this->_id = $this->_getProduct()->getId();
90
+ }
91
+ return $this->_id;
92
+ }
93
+
94
+ /**
95
+ * Get current product name.
96
+ * @return string
97
+ */
98
+ public function getName() {
99
+ if (empty($this->_name) && $this->_hasProduct) {
100
+ $this->_name = $this->_getProduct()->getName();
101
+ }
102
+ return $this->_name;
103
+ }
104
+
105
+ /**
106
+ * Get current product description (single line, no HTML tags).
107
+ * @return string
108
+ */
109
+ public function getDescription() {
110
+ if (empty($this->_description) && $this->_hasProduct) {
111
+ $this->_description = Mage::helper('blueknow_recommender')->ssline($this->_getProduct()->getDescription());
112
+ }
113
+ return $this->_description;
114
+ }
115
+
116
+ /**
117
+ * Get current product absolute URL.
118
+ * @return string
119
+ */
120
+ public function getUrl() {
121
+ if (empty($this->_url) && $this->_hasProduct) {
122
+ $this->_url = $this->_getProduct()->getProductUrl();
123
+ }
124
+ return $this->_url;
125
+ }
126
+
127
+ /**
128
+ * Get current product image absolute URL.
129
+ * @return string
130
+ */
131
+ public function getImageUrl() {
132
+ if (empty($this->_imageUrl) && $this->_hasProduct) {
133
+ $this->_imageUrl = Mage::helper('catalog/product')->getSmallImageUrl($this->_getProduct()); //it internally deals with no-image products
134
+ }
135
+ return $this->_imageUrl;
136
+ }
137
+
138
+ /**
139
+ * Get current product price, within currency conversion applied and including taxes. No currency symbol.
140
+ * return number|string
141
+ */
142
+ public function getPrice() {
143
+ if (empty($this->_price) && $this->_hasProduct) {
144
+ $this->_price = Mage::helper('blueknow_recommender/Price')->getFinalPrice($this->_getProduct());
145
+ }
146
+ return $this->_price;
147
+ }
148
+
149
+ /**
150
+ * Determine if current product is saleable (in stock).
151
+ * @return bool
152
+ */
153
+ public function isSaleable() {
154
+ if (empty($this->_inStock) && $this->_hasProduct) {
155
+ $this->_inStock = $this->_getProduct()->isSaleable();
156
+ }
157
+ return $this->_inStock;
158
+ }
159
+
160
+ /**
161
+ * Get categories (and subcategories) where current product is placed. Every category is defined by the pair (id, name).
162
+ * @return array
163
+ */
164
+ public function getCategories() {
165
+ if (empty($this->_categories)) {
166
+ $this->_categories = Mage::helper('blueknow_recommender/category')->getCategoryPath();
167
+ }
168
+ return $this->_categories;
169
+ }
170
+
171
+ /**
172
+ * Get current Product.
173
+ * @return Mage_Catalog_Model_Product
174
+ */
175
+ protected function _getProduct() {
176
+ if (!$this->hasData(self::DATA_PRODUCT) || !$this->getData(self::DATA_PRODUCT) instanceof Mage_Catalog_Model_Product) {
177
+ $this->setData(self::DATA_PRODUCT, Mage::helper('catalog')->getProduct());
178
+ }
179
+ return $this->getData(self::DATA_PRODUCT);
180
+ }
181
+ }
app/code/community/Blueknow/Recommender/Model/Session.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Blueknow Recommender session.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Model_Session extends Mage_Core_Model_Session_Abstract {
20
+
21
+ public function __construct() {
22
+ $this->init('blueknow_recommender');
23
+ }
24
+
25
+ /**
26
+ * Activate the new-login flag.
27
+ */
28
+ public function setNewLogin() {
29
+ $this->setData('newLogin', true);
30
+ }
31
+
32
+ /**
33
+ * Deactivate the new-login flag.
34
+ */
35
+ public function unsetNewLogin() {
36
+ $this->setData('newLogin', false);
37
+ }
38
+
39
+ /**
40
+ * Get the new-login flag.
41
+ * @return bool
42
+ */
43
+ public function isNewLogin() {
44
+ return $this->getData('newLogin');
45
+ }
46
+ }
app/code/community/Blueknow/Recommender/Model/Source/Numberofrecommendations.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Config Number of recommedantions source.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category Blueknow
12
+ * @package Blueknow_Recommender
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ class Blueknow_Recommender_Model_Source_Numberofrecommendations {
20
+
21
+ /**
22
+ * Get options for number of recommendations selector. It defines the rang 3-20.
23
+ * @return array
24
+ */
25
+ public function toOptionArray() {
26
+ for ($i=3; $i<=20; $i++) {
27
+ $options[$i] = array('value' => $i, 'label' => $i);
28
+ }
29
+ return $options;
30
+ }
31
+ }
app/code/community/Blueknow/Recommender/documentation/Blueknow_Recommender_1.0.0_Gui/314/201a_de_Instalacio/314/201n.pdf ADDED
Binary file
app/code/community/Blueknow/Recommender/documentation/Blueknow_Recommender_1.0.0_Installation_Guide.pdf ADDED
Binary file
app/code/community/Blueknow/Recommender/documentation/README.txt ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Blueknow Recommender for Magento.
3
+ *
4
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
5
+ * @license GNU General Public License
6
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
7
+ *
8
+ */
9
+
10
+ About the module
11
+ ================
12
+
13
+ * Name: Blueknow Recommender for Magento eCommerce platform (v1.4.x).
14
+ * Description: Personalized product recommendations for your eCommerce: cross-sell and up-sell.
15
+ * Version: 1.0.0.
16
+
17
+ NOTE: this module has been successfully tested on Magento 1.4.x. If your eCommerce runs under an older version, please contact with us at support@blueknow.com.
18
+
19
+ Important notes
20
+ ===============
21
+
22
+ * Once add-on is installed, your clients won't get personalized recommendations until at least 24 hours after.
23
+ * If some language you need is not supported, create it! Your new language file should be under %MAGENTO_HOME%/app/locale/<your_locale>/Blueknow_Recommender.csv.
24
+ Take other language file as example to define your new one.
25
+ * If you modified an older version of this add-on, be careful not to loose your changes (widget templates, and so on).
26
+ * If you are using cache in your eCommerce, some functionalities added by this add-on may not work. Refresh it from Magento's Admin Panel.
27
+ * Errors? Problems? Bugs? Contributions? Let us know at support@blueknow.com.
28
+
29
+ How to install
30
+ ==============
31
+
32
+ To install Blueknow Recommender in your Magento distribution:
33
+
34
+ (Remote) Use Magento Connect from Magento's Admin Panel: System > Magento Connect > Magento Connect Manager.
35
+ (Local) Use PEAR: %MAGENTO_HOME%/pear install Blueknow_Recommender-1.0.0.tgz.
36
+
37
+ Modify the shopping cart template of your Magento installation:
38
+
39
+ 1. Affected file: app/design/frontend/default/defaul/template/checkout/cart.phtml.
40
+ 2. Code to be added (feel free with its location): <?php echo $this->getChildHtml('blueknow.cart.recommender.widget') ?>
41
+
42
+ After installing the extension, you will need to configure it from your Magento's Admin Panel: System > Configuration > Services > Blueknow Recommender.
43
+
44
+ Optionally, you can review the default recommendations widget template provided for changing it according your needs:
45
+
46
+ 1. Template for product detail cross-sell recommendations widget .... %MAGENTO_HOME%/app/design/frontend/default/default/template/blueknow/product/recommender_widget.phtml.
47
+ 2. Template for shopping cart up-sell recommendations widget ........ %MAGENTO_HOME%/app/design/frontend/default/default/template/blueknow/cart/recommender_widget.phtml.
48
+
49
+ Once configuration is complete, Blueknow Tracker will start tracking behavioral events (visits, purchases...) and 24 hours later your clients
50
+ will be receiving personalized recommendations.
51
+
52
+ If you need more information about this module, how to obtain a BK number for your eCommerce for free, or about the service in general, please visit our
53
+ public site at http://www.blueknow.com or contact with our Customer support department (support@blueknow.com).
54
+
55
+ Change log
56
+ ==========
57
+
58
+ * Version 1.0.0
59
+
60
+ - Tracking of users' products views.
61
+ - Tracking of discontinued products.
62
+ - Tracking of users' logins.
63
+ - Tracking of users' purchases.
64
+ - Tracking of discontinued products after a purchase.
65
+ - Cross-sell recommendations in product detail page.
66
+ - Up-sell recommendations in shopping cart page.
app/code/community/Blueknow/Recommender/etc/config.xml ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * Module configuration file.
5
+ *
6
+ * DISCLAIMER
7
+ *
8
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
9
+ * extension to newer versions in the future. If you wish to customize it for
10
+ * your needs please save your changes before upgrading.
11
+ *
12
+ * @category Blueknow
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ -->
20
+ <config>
21
+ <modules>
22
+ <Blueknow_Recommender>
23
+ <version>1.0.0</version>
24
+ </Blueknow_Recommender>
25
+ </modules>
26
+ <global>
27
+ <models>
28
+ <blueknow_recommender>
29
+ <class>Blueknow_Recommender_Model</class>
30
+ </blueknow_recommender>
31
+ </models>
32
+ <blocks>
33
+ <blueknow_recommender>
34
+ <class>Blueknow_Recommender_Block</class>
35
+ </blueknow_recommender>
36
+ </blocks>
37
+ <helpers>
38
+ <blueknow_recommender>
39
+ <class>Blueknow_Recommender_Helper</class>
40
+ </blueknow_recommender>
41
+ </helpers>
42
+ </global>
43
+ <default>
44
+ <blueknow>
45
+ <recommender>
46
+ <enabled>1</enabled>
47
+ </recommender>
48
+ <item_to_item>
49
+ <enabled>1</enabled>
50
+ <nor>4</nor>
51
+ </item_to_item>
52
+ <item_to_basket>
53
+ <enabled>1</enabled>
54
+ <nor>7</nor>
55
+ </item_to_basket>
56
+ </blueknow>
57
+ </default>
58
+ <frontend>
59
+ <layout>
60
+ <updates>
61
+ <blueknow_recommender>
62
+ <file>blueknow_recommender.xml</file>
63
+ </blueknow_recommender>
64
+ </updates>
65
+ </layout>
66
+ <translate>
67
+ <modules>
68
+ <blueknow_recommender>
69
+ <files>
70
+ <default>Blueknow_Recommender.csv</default>
71
+ </files>
72
+ </blueknow_recommender>
73
+ </modules>
74
+ </translate>
75
+ <events>
76
+ <customer_login>
77
+ <observers>
78
+ <blueknow_recommender_customer_login>
79
+ <type>model</type>
80
+ <class>Blueknow_Recommender_Model_Observer</class>
81
+ <method>setNewLoginWhenCustomerLogIn</method>
82
+ </blueknow_recommender_customer_login>
83
+ </observers>
84
+ </customer_login>
85
+ <customer_login_tracked>
86
+ <observers>
87
+ <blueknow_recommender_customer_login_tracker>
88
+ <type>model</type>
89
+ <class>Blueknow_Recommender_Model_Observer</class>
90
+ <method>unsetNewLoginAfterTracking</method>
91
+ </blueknow_recommender_customer_login_tracker>
92
+ </observers>
93
+ </customer_login_tracked>
94
+ </events>
95
+ </frontend>
96
+ <adminhtml>
97
+ <acl>
98
+ <resources>
99
+ <admin>
100
+ <children>
101
+ <system>
102
+ <children>
103
+ <config>
104
+ <children>
105
+ <blueknow module="blueknow_recommender">
106
+ <title>Blueknow Recommender</title>
107
+ </blueknow>
108
+ </children>
109
+ </config>
110
+ </children>
111
+ </system>
112
+ </children>
113
+ </admin>
114
+ </resources>
115
+ </acl>
116
+ <translate>
117
+ <modules>
118
+ <blueknow_recommender>
119
+ <files>
120
+ <default>Blueknow_Recommender.csv</default>
121
+ </files>
122
+ </blueknow_recommender>
123
+ </modules>
124
+ </translate>
125
+ </adminhtml>
126
+ </config>
app/code/community/Blueknow/Recommender/etc/system.xml ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * System configuration file.
5
+ *
6
+ * DISCLAIMER
7
+ *
8
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
9
+ * extension to newer versions in the future. If you wish to customize it for
10
+ * your needs please save your changes before upgrading.
11
+ *
12
+ * @category Blueknow
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ -->
20
+ <config>
21
+ <sections>
22
+ <blueknow module="blueknow_recommender">
23
+ <label>Blueknow Recommender</label>
24
+ <tab>service</tab>
25
+ <frontend_type>text</frontend_type>
26
+ <sort_order>999</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ <groups>
31
+ <recommender translate="label">
32
+ <label>Main configuration</label>
33
+ <frontend_type>text</frontend_type>
34
+ <sort_order>10</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ <fields>
39
+ <enabled translate="label,comment">
40
+ <label>Enable</label>
41
+ <comment><![CDATA[Activate/Deactivate Blueknow Recommender.]]></comment>
42
+ <frontend_type>select</frontend_type>
43
+ <source_model>adminhtml/system_config_source_yesno</source_model>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>1</show_in_store>
47
+ </enabled>
48
+ <bk_number translate="comment">
49
+ <label>BK number</label>
50
+ <comment><![CDATA[Unique identifier assigned to this eCommerce.<br />Do you need one? Obtain it for free at <a href='http://www.blueknow.com'>here</a>.]]></comment>
51
+ <frontend_type>text</frontend_type>
52
+ <sort_order>20</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>1</show_in_store>
56
+ </bk_number>
57
+ </fields>
58
+ </recommender>
59
+ <item_to_item translate="label">
60
+ <label>Cross-sell recommendations</label>
61
+ <frontend_type>text</frontend_type>
62
+ <sort_order>20</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>1</show_in_store>
66
+ <fields>
67
+ <enabled translate="label,comment">
68
+ <label>Enable</label>
69
+ <comment><![CDATA[Activate/Deactivate cross-sell recommendations in product detail page.]]></comment>
70
+ <frontend_type>select</frontend_type>
71
+ <source_model>adminhtml/system_config_source_yesno</source_model>
72
+ <sort_order>10</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>1</show_in_store>
76
+ </enabled>
77
+ <nor translate="label,comment">
78
+ <label>Recommendations</label>
79
+ <comment><![CDATA[Number of cross-sell recommendations to show in product detail page.]]></comment>
80
+ <frontend_type>select</frontend_type>
81
+ <source_model>blueknow_recommender/source_numberofrecommendations</source_model>
82
+ <sort_order>20</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>1</show_in_store>
86
+ </nor>
87
+ </fields>
88
+ </item_to_item>
89
+ <item_to_basket translate="label">
90
+ <label>Up-sell recommendations</label>
91
+ <frontend_type>text</frontend_type>
92
+ <sort_order>30</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>1</show_in_store>
96
+ <fields>
97
+ <enabled translate="label,comment">
98
+ <label>Enable</label>
99
+ <comment><![CDATA[Activate/Deactivate up-sell recommendations in shopping cart page.]]></comment>
100
+ <frontend_type>select</frontend_type>
101
+ <source_model>adminhtml/system_config_source_yesno</source_model>
102
+ <sort_order>10</sort_order>
103
+ <show_in_default>1</show_in_default>
104
+ <show_in_website>1</show_in_website>
105
+ <show_in_store>1</show_in_store>
106
+ </enabled>
107
+ <nor translate="label,comment">
108
+ <label>Recommendations</label>
109
+ <comment><![CDATA[Number of up-sell recommendations to show in shopping cart page.]]></comment>
110
+ <frontend_type>select</frontend_type>
111
+ <source_model>blueknow_recommender/source_numberofrecommendations</source_model>
112
+ <sort_order>20</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>1</show_in_store>
116
+ </nor>
117
+ </fields>
118
+ </item_to_basket>
119
+ </groups>
120
+ </blueknow>
121
+ </sections>
122
+ </config>
app/code/community/Blueknow/Recommender/sql/recommender_setup/uninstall.sql ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Blueknow Recommender uninstall SQL script.
3
+ *
4
+ * DISCLAIMER
5
+ *
6
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
7
+ * extension to newer versions in the future. If you wish to customize it for
8
+ * your needs please save your changes before upgrading.
9
+ *
10
+ * @category Blueknow
11
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
12
+ * @license GNU General Public License
13
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
14
+ * @since 1.0.0
15
+ *
16
+ */
17
+ delete from core_config_data where path like 'blueknow%';
app/design/frontend/default/default/layout/blueknow_recommender.xml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * Blueknow Recommender layout configuration file.
5
+ *
6
+ * DISCLAIMER
7
+ *
8
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
9
+ * extension to newer versions in the future. If you wish to customize it for
10
+ * your needs please save your changes before upgrading.
11
+ *
12
+ * @category design
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ -->
20
+ <layout version="0.1.0">
21
+ <default>
22
+ <reference name="content">
23
+ <block type="blueknow_recommender/customer_tracker" name="blueknow.customer.tracker" as="customer_tracker" template="blueknow/customer/tracker.phtml" />
24
+ </reference>
25
+ </default>
26
+ <catalog_product_view>
27
+ <reference name="content">
28
+ <reference name="product.info.additional">
29
+ <block before="-" type="blueknow_recommender/product_recommender" name="blueknow.product.recommender.widget" as="product_recommender_widget" template="blueknow/product/recommender_widget.phtml">
30
+ <block type="blueknow_recommender/base" name="blueknow.product.recommender.widget.footer" as="product_recommender_widget_footer" template="blueknow/common/recommender_widget_footer.phtml" />
31
+ </block>
32
+ </reference>
33
+ <block type="page/html" name="blueknow.product.recommender.renderer" as="product_recommender_renderer" template="blueknow/common/recommender_renderer.phtml" />
34
+ <block type="blueknow_recommender/product_recommender" name="blueknow.product.recommender" as="product_recommender" template="blueknow/product/recommender.phtml" />
35
+ <block type="blueknow_recommender/product_tracker" name="blueknow.product.tracker" as="product_tracker" template="blueknow/product/tracker.phtml" />
36
+ </reference>
37
+ </catalog_product_view>
38
+ <checkout_cart_index>
39
+ <reference name="content">
40
+ <reference name="checkout.cart">
41
+ <!--
42
+ You will have to modify your custom checkout cart template to add up-sell recommendations.
43
+ Affected file: app/design/frontend/<interface>/<theme>/template/checkout/cart.phtml.
44
+ Code to add: <?php echo $this->getChildHtml('blueknow.cart.recommender.widget') ?>
45
+ IMPORTANT NOTE: not compatible with Magento v1.1.x.
46
+ -->
47
+ <block type="blueknow_recommender/cart_recommender" name="blueknow.cart.recommender.widget" template="blueknow/cart/recommender_widget.phtml">
48
+ <block type="blueknow_recommender/base" name="blueknow.cart.recommender.widget.footer" as="cart_recommender_widget_footer" template="blueknow/common/recommender_widget_footer.phtml" />
49
+ </block>
50
+ </reference>
51
+ <block type="page/html" name="blueknow.cart.recommender.renderer" as="cart_recommender_renderer" template="blueknow/common/recommender_renderer.phtml" />
52
+ <block type="blueknow_recommender/cart_recommender" name="blueknow.cart.recommender" as="cart_recommender" template="blueknow/cart/recommender.phtml" />
53
+ </reference>
54
+ </checkout_cart_index>
55
+ <checkout_onepage_success>
56
+ <reference name="content">
57
+ <block type="blueknow_recommender/checkout_tracker" name="blueknow.checkout.tracker" as="checkout_tracker" template="blueknow/checkout/tracker.phtml" />
58
+ </reference>
59
+ </checkout_onepage_success>
60
+ <checkout_multishipping_success>
61
+ <reference name="content">
62
+ <block type="blueknow_recommender/checkout_tracker" name="blueknow.checkout.multishipping.tracker" as="checkout_multishipping_tracker" template="blueknow/checkout/tracker.phtml" />
63
+ </reference>
64
+ </checkout_multishipping_success>
65
+ </layout>
app/design/frontend/default/default/template/blueknow/cart/recommender.phtml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Template for Blueknow_Recommender_Block_Cart_Recommmender.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category design
12
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
13
+ * @license GNU General Public License
14
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
15
+ * @since 1.0.0
16
+ *
17
+ */
18
+ ?>
19
+ <?php $bConfiguration = $this->getConfig(); ?>
20
+
21
+ <script src="<?php echo $bConfiguration->getBaseURL() ?>/bk-r.js" type="text/javascript"></script>
22
+
23
+ <script type="text/javascript">
24
+ var rec = new Blueknow.Recommender('<?php echo $bConfiguration->getBKNumber() ?>');
25
+ rec.setCurrency('<?php echo $bConfiguration->getCurrentCurrency()->getCode() ?>');
26
+ rec.setLanguage('<?php echo $bConfiguration->getLanguage() ?>');
27
+ </script>
28
+
29
+ <script type="text/javascript">
30
+ var i2b_properties = new Object();
31
+ i2b_properties.recommendations = '<?php echo $bConfiguration->getUpSellNOR() ?>';
32
+ var i2b_products = Array();
33
+ <?php foreach ($this->getCart()->getProducts() as $bProduct) { ?>
34
+ i2b_products.push('<?php echo $bProduct ?>');
35
+ <?php } //eof foreach ?>
36
+ rec.item2basket('<?php echo $bConfiguration->getDescriptor(); ?>_cart', i2b_products, i2b_properties);
37
+ </script>
app/design/frontend/default/default/template/blueknow/cart/recommender_widget.phtml ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Template for Blueknow_Recommender_Block_Cart_Recommmender.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category design
12
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
13
+ * @license GNU General Public License
14
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
15
+ * @since 1.0.0
16
+ *
17
+ */
18
+ ?>
19
+ <style type="text/css">
20
+
21
+ #blueknow-widget {
22
+ margin-top: 20px;
23
+ }
24
+
25
+ #blueknow-widget h2 {
26
+ font-weight: bold;
27
+ font-size: 15px;
28
+ color: #e26703;
29
+ }
30
+
31
+ .blueknow-products-grid {
32
+ float: left;
33
+ width: 126px !important;
34
+ height: 235px;
35
+ background-color: #fafaec;
36
+ border: 1px solid #e5dcc3;
37
+ }
38
+
39
+ .blueknow-product {
40
+ padding: 10px;
41
+ }
42
+
43
+ .blueknow-product-image {
44
+ width: 110px !important;
45
+ height: 110px !important;
46
+ }
47
+
48
+ .blueknow-product img {
49
+ border:1px solid #e5dcc3;
50
+ }
51
+
52
+ </style>
53
+
54
+ <div id="blueknow-widget"></div>
55
+
56
+ <?php $bConfiguration = $this->getConfig(); ?>
57
+
58
+ <div id="blueknow-header" style="display: none; clear: both;">
59
+ <div><h2><?php echo $this->__('Customers who bought these products also bought') ?></h2></div>
60
+ </div>
61
+
62
+ <div id="blueknow-template" style="display: none; clear: both;">
63
+ <div class="products-grid blueknow-products-grid">
64
+ <div class="blueknow-product">
65
+ <a href="#url" title="#name" class="product-image blueknow-product-image">
66
+ <img src="#image" alt="#name" title="#name" width="100" height="100" hspace="0" vspace="0" border="0" />
67
+ </a>
68
+ <h3 class="product-name"><a href="#url" title="#name">#name</a></h3>
69
+ <div class="price-box">
70
+ <span class="regular-price">
71
+ <span class="price">#price <?php echo $bConfiguration->getCurrentCurrency()->getSymbol() ?></span>
72
+ </span>
73
+ </div>
74
+ </div>
75
+ </div>
76
+ </div>
77
+
78
+ <?php echo $this->getChildHtml('cart_recommender_widget_footer') ?>
app/design/frontend/default/default/template/blueknow/checkout/tracker.phtml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Template for Blueknow_Recommender_Block_Checkout_Tracker.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category design
12
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
13
+ * @license GNU General Public License
14
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
15
+ * @since 1.0.0
16
+ *
17
+ */
18
+ ?>
19
+ <?php $bConfiguration = $this->getConfig(); ?>
20
+
21
+ <?php $bOrders = $this->getCheckout()->getOrders(); ?>
22
+
23
+ <script src="<?php echo $bConfiguration->getBaseURL() ?>/bk.js" type="text/javascript"></script>
24
+
25
+ <script type="text/javascript">
26
+ var tracker = Blueknow.getTracker('<?php echo $bConfiguration->getBKNumber() ?>');
27
+ tracker.setCurrency('<?php echo $bConfiguration->getDefaultCurrency()->getCode() ?>');
28
+ tracker.setLanguage('<?php echo $bConfiguration->getLanguage() ?>');
29
+ </script>
30
+
31
+ <script type="text/javascript">
32
+
33
+ <?php foreach ($bOrders as $bOrder) { ?>
34
+ <?php $bProducts = $bOrder->getProducts(); ?>
35
+ <?php if (empty($bProducts)) continue; ?>
36
+ <?php foreach ($bProducts as $bProduct) { ?>
37
+ tracker.addItem('<?php echo $bProduct->getId() ?>', '<?php echo $bProduct->getPrice() ?>', '<?php echo $bProduct->getQuantity() ?>');
38
+ <?php if (!$bProduct->isSaleable()) { ?>
39
+ tracker.trackDiscontinued('<?php echo $bProduct->getId() ?>');
40
+ <?php } ?>
41
+ <?php } ?>
42
+ tracker.trackPurchased('<?php echo $bOrder->getId() ?>', '<?php echo $bOrder->getTotal() ?>', '<?php echo $bOrder->getTax() ?>', '<?php echo $bOrder->getShipping() ?>');
43
+ <?php } ?>
44
+
45
+ </script>
app/design/frontend/default/default/template/blueknow/common/recommender_renderer.phtml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Basic template (Mage_Page_Block_Html).
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category design
12
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
13
+ * @license GNU General Public License
14
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
15
+ * @since 1.0.0
16
+ *
17
+ */
18
+ ?>
19
+ <script type="text/javascript">
20
+ //success function
21
+ function renderItems(items) {
22
+ if (items.length > 0) {
23
+ var widget = "";
24
+ var header = document.getElementById("blueknow-header");
25
+ widget += header ? header.innerHTML : "";
26
+ for (var i=0; i < items.length; i++) {
27
+ var item = items[i];
28
+ var templateHolder = document.getElementById("blueknow-template");
29
+ if (!templateHolder) {
30
+ break;
31
+ }
32
+ var template = templateHolder.innerHTML;
33
+ template = template.replace(/#name/g, item.name);
34
+ template = template.replace(/#url/g, item.url);
35
+ template = template.replace(/#image/g, item.image);
36
+ template = template.replace(/#price/g, item.price);
37
+ widget += template;
38
+ }
39
+ var footer = document.getElementById("blueknow-footer");
40
+ widget += footer ? footer.innerHTML : "";
41
+ var container = document.getElementById("blueknow-widget");
42
+ if (container) {
43
+ container.innerHTML = widget;
44
+ }
45
+ }
46
+ }
47
+ //error function
48
+ function processError(message) {}
49
+ </script>
app/design/frontend/default/default/template/blueknow/common/recommender_widget_footer.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Template for Blueknow_Recommender_Block_Base.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category design
12
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
13
+ * @license GNU General Public License
14
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
15
+ * @since 1.0.0
16
+ *
17
+ */
18
+ ?>
19
+ <div id="blueknow-footer" style="display: none; clear: both;">
20
+ <!-- Powered by Blueknow -->
21
+ <div style="clear: both; width: 100%; padding-top: 10px;">
22
+ <div style="float: right;">
23
+ <a href="http://www.blueknow.com" rel="nofollow" style="font-size: 11px; color: #666666; text-decoration:none;">
24
+ <img id="bk-logo" alt="Powered by Blueknow" align="left" width="18" src="<?php echo $this->getConfig()->getBaseURL() ?>/logo.png" style="border:none; margin-right: 5px;">
25
+ <span style="line-height:17px;">Powered by Blueknow</span>
26
+ </a>
27
+ </div>
28
+ <div style="clear: both; margin-bottom: 10px;"></div>
29
+ </div>
30
+ </div>
app/design/frontend/default/default/template/blueknow/customer/tracker.phtml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Template for Blueknow_Recommender_Block_Customer_Tracker.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category design
12
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
13
+ * @license GNU General Public License
14
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
15
+ * @since 1.0.0
16
+ *
17
+ */
18
+ ?>
19
+ <?php $bConfiguration = $this->getConfig(); ?>
20
+
21
+ <script src="<?php echo $bConfiguration->getBaseURL() ?>/bk.js" type="text/javascript"></script>
22
+
23
+ <script type="text/javascript">
24
+ var tracker = Blueknow.getTracker('<?php echo $bConfiguration->getBKNumber() ?>');
25
+ tracker.setCurrency('<?php echo $bConfiguration->getCurrentCurrency()->getCode() ?>');
26
+ tracker.setLanguage('<?php echo $bConfiguration->getLanguage() ?>');
27
+ </script>
28
+
29
+ <script type="text/javascript">
30
+ tracker.setUserLogged('<?php echo $this->getCustomer()->getIdentifier() ?>');
31
+ </script>
app/design/frontend/default/default/template/blueknow/product/recommender.phtml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Template for Blueknow_Recommender_Block_Product_Recommmender.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category design
12
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
13
+ * @license GNU General Public License
14
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
15
+ * @since 1.0.0
16
+ *
17
+ */
18
+ ?>
19
+ <?php $bConfiguration = $this->getConfig(); ?>
20
+
21
+ <script src="<?php echo $bConfiguration->getBaseURL() ?>/bk-r.js" type="text/javascript"></script>
22
+
23
+ <script type="text/javascript">
24
+ var rec = new Blueknow.Recommender('<?php echo $bConfiguration->getBKNumber() ?>');
25
+ rec.setCurrency('<?php echo $bConfiguration->getCurrentCurrency()->getCode() ?>');
26
+ rec.setLanguage('<?php echo $bConfiguration->getLanguage() ?>');
27
+ </script>
28
+
29
+ <script type="text/javascript">
30
+ var i2i_properties = new Object();
31
+ i2i_properties.recommendations = '<?php echo $bConfiguration->getCrossSellNOR() ?>';
32
+ rec.item2item('<?php echo $bConfiguration->getDescriptor(); ?>_product', '<?php echo $this->getProduct()->getIdentifier() ?>', i2i_properties);
33
+ </script>
app/design/frontend/default/default/template/blueknow/product/recommender_widget.phtml ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Template for Blueknow_Recommender_Block_Product_Recommmender.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category design
12
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
13
+ * @license GNU General Public License
14
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
15
+ * @since 1.0.0
16
+ *
17
+ */
18
+ ?>
19
+ <style type="text/css">
20
+
21
+ .blueknow-products-grid {
22
+ float: left;
23
+ width: 156px !important;
24
+ height: 250px;
25
+ background-color: #f6f2e7;
26
+ border: 1px solid #e5dcc3;
27
+ }
28
+
29
+ .blueknow-product {
30
+ padding: 10px;
31
+ }
32
+
33
+ .blueknow-product-image {
34
+
35
+ }
36
+
37
+ .blueknow-product img {
38
+ border:1px solid #e5dcc3;
39
+ }
40
+
41
+ </style>
42
+
43
+ <div id="blueknow-widget"></div>
44
+
45
+ <?php $bConfiguration = $this->getConfig(); ?>
46
+
47
+ <div id="blueknow-header" style="display: none; clear: both;">
48
+ <div><h2><?php echo $this->__('You may also be interested in the following products') ?></h2></div>
49
+ </div>
50
+
51
+ <div id="blueknow-template" style="display: none; clear: both;">
52
+ <div class="products-grid blueknow-products-grid">
53
+ <div class="blueknow-product">
54
+ <a href="#url" title="#name" class="product-image blueknow-product-image">
55
+ <img src="#image" alt="#name" title="#name" width="125" height="125" hspace="0" vspace="0" border="0" />
56
+ </a>
57
+ <h3 class="product-name"><a href="#url" title="#name">#name</a></h3>
58
+ <div class="price-box">
59
+ <span class="regular-price">
60
+ <span class="price">#price <?php echo $bConfiguration->getCurrentCurrency()->getSymbol() ?></span>
61
+ </span>
62
+ </div>
63
+ </div>
64
+ </div>
65
+ </div>
66
+
67
+ <?php echo $this->getChildHtml('product_recommender_widget_footer') ?>
app/design/frontend/default/default/template/blueknow/product/tracker.phtml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Template for Blueknow_Recommender_Block_Product_Tracker.
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
8
+ * extension to newer versions in the future. If you wish to customize it for
9
+ * your needs please save your changes before upgrading.
10
+ *
11
+ * @category design
12
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
13
+ * @license GNU General Public License
14
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
15
+ * @since 1.0.0
16
+ *
17
+ */
18
+ ?>
19
+ <?php $bConfiguration = $this->getConfig(); ?>
20
+
21
+ <?php $bProduct = $this->getProduct(); ?>
22
+
23
+ <script src="<?php echo $bConfiguration->getBaseURL() ?>/bk.js" type="text/javascript"></script>
24
+
25
+ <script type="text/javascript">
26
+ var tracker = Blueknow.getTracker('<?php echo $bConfiguration->getBKNumber() ?>');
27
+ tracker.setCurrency('<?php echo $bConfiguration->getCurrentCurrency()->getCode() ?>');
28
+ tracker.setLanguage('<?php echo $bConfiguration->getLanguage() ?>');
29
+ </script>
30
+
31
+ <?php if ($this->getProduct()->isSaleable()) { ?>
32
+
33
+ <script type="text/javascript">
34
+ var properties = new Object();
35
+ <?php
36
+ $level = 1;
37
+ foreach ($bProduct->getCategories() as $bCategory) {
38
+ echo 'properties.cat_L' . $level . '_id = "' . $bCategory['id'] . '"; ';
39
+ echo 'properties.cat_L' . $level . '_name = "' . $bCategory['name'] . '"; ';
40
+ $level++;
41
+ }
42
+ ?>
43
+ tracker.trackVisited(
44
+ '<?php echo $bProduct->getIdentifier() ?>',
45
+ '<?php echo $bProduct->getName() ?>',
46
+ '<?php echo $bProduct->getDescription() ?>',
47
+ '<?php echo $bProduct->getUrl() ?>',
48
+ '<?php echo $bProduct->getImageUrl() ?>',
49
+ '<?php echo $bProduct->getPrice() ?>',
50
+ properties
51
+ );
52
+ </script>
53
+
54
+ <?php } else { ?>
55
+
56
+ <script type="text/javascript">
57
+ tracker.trackDiscontinued('<?php echo $this->getProduct()->getIdentifier() ?>');
58
+ </script>
59
+
60
+ <?php } ?>
app/etc/modules/Blueknow_Recommender.xml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Main configuration file.
5
+ *
6
+ * DISCLAIMER
7
+ *
8
+ * Do not edit or add to this file if you wish to upgrade Blueknow Recommender
9
+ * extension to newer versions in the future. If you wish to customize it for
10
+ * your needs please save your changes before upgrading.
11
+ *
12
+ * @category Blueknow
13
+ * @copyright Copyright (c) 2010 Blueknow, S.L. (http://www.blueknow.com)
14
+ * @license GNU General Public License
15
+ * @author <a href="mailto:santi.ameller@blueknow.com">Santiago Ameller</a>
16
+ * @since 1.0.0
17
+ *
18
+ */
19
+ -->
20
+ <config>
21
+ <modules>
22
+ <Blueknow_Recommender>
23
+ <active>true</active>
24
+ <codePool>community</codePool>
25
+ <depends>
26
+ <Mage_Core />
27
+ <Mage_Catalog />
28
+ </depends>
29
+ </Blueknow_Recommender>
30
+ </modules>
31
+ </config>
app/locale/de_DE/Blueknow_recommender.csv ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Main configuration", "Hauptkonfiguration"
2
+ "Enable", "Aktiviert"
3
+ "Activate/Deactivate Blueknow Recommender.", "Aktivieren/Deaktivieren Blueknow Recommender."
4
+ "Unique identifier assigned to this eCommerce.<br />Do you need one? Obtain it for free at <a href='http://www.blueknow.com'>here</a>.", "Eindeutige Kennung zu diesen eCommerce zugeordnet.<br />Brauchen Sie einen? Bekommen Sie es konstenlos <a href='http://www.blueknow.com'>bei</a>."
5
+ "Cross-sell recommendations", "Cross-sell Empfehlungen"
6
+ "Activate/Deactivate cross-sell recommendations in product detail page.", "Aktivieren/deaktivieren cross-sell Empfehlungen auf der Produktseite."
7
+ "Recommendations", "Empfehlungen"
8
+ "Number of cross-sell recommendations to show in product detail page.", "Anzhal von cross-sell Empfehlungen, die auf der Produktseite angezeigt werden."
9
+ "Up-sell recommendations", "Up-sell Empfehlungen"
10
+ "Activate/Deactivate up-sell recommendations in shopping cart page.", "Aktivieren/Deaktivieren Up-sell Empfehlungen auf der Einkaufswagenseite."
11
+ "Number of up-sell recommendations to show in shopping cart page.", "Anzhal von up-sell Empfehlungen, die auf der Einkaufswagenseite angezeigt werden."
12
+
13
+ "You may also be interested in the following products", "Sie k&ouml;nnen auch Interesse an folgende Produkte haben"
14
+ "Customers who bought these products also bought", "Kunden, die diesen Artikel gekauft haben, kauften auch"
app/locale/en_US/Blueknow_recommender.csv ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Main configuration", "Main configuration"
2
+ "Enable", "Enable"
3
+ "Activate/Deactivate Blueknow Recommender.", "Activate/Deactivate Blueknow Recommender."
4
+ "Unique identifier assigned to this eCommerce.<br />Do you need one? Obtain it for free at <a href='http://www.blueknow.com'>here</a>.", "Unique identifier assigned to this eCommerce.<br />Do you need one? Obtain it for free at <a href='http://www.blueknow.com'>here</a>."
5
+ "Cross-sell recommendations", "Cross-sell recommendations"
6
+ "Activate/Deactivate cross-sell recommendations in product detail page.", "Activate/Deactivate cross-sell recommendations in product detail page."
7
+ "Recommendations", "Recommendations"
8
+ "Number of cross-sell recommendations to show in product detail page.", "Number of cross-sell recommendations to show in product detail page."
9
+ "Up-sell recommendations", "Up-sell recommendations"
10
+ "Activate/Deactivate up-sell recommendations in shopping cart page.", "Activate/Deactivate up-sell recommendations in shopping cart page."
11
+ "Number of up-sell recommendations to show in shopping cart page.", "Number of up-sell recommendations to show in shopping cart page."
12
+
13
+ "You may also be interested in the following products", "You may also be interested in the following products"
14
+ "Customers who bought these products also bought", "Customers who bought these products also bought"
app/locale/es_ES/Blueknow_recommender.csv ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Main configuration", "Configuraci&oacute;n principal"
2
+ "Enable", "Activado"
3
+ "Activate/Deactivate Blueknow Recommender.", "Activa/Desactiva Blueknow Recommender."
4
+ "Unique identifier assigned to this eCommerce.<br />Do you need one? Obtain it for free at <a href='http://www.blueknow.com'>here</a>.", "Identificador &uacute;nico asignado a este eCommerce.<br />&iquest;Necesita uno? Cons&iacute;galo gratis <a href='http://www.blueknow.com'>aqu&iacute;</a>."
5
+ "Cross-sell recommendations", "Recomendaciones cross-sell"
6
+ "Activate/Deactivate cross-sell recommendations in product detail page.", "Activa/Desactiva las recomendaciones cross-sell en la p&aacute;gina de producto."
7
+ "Recommendations", "Recomendaciones"
8
+ "Number of cross-sell recommendations to show in product detail page.", "N&uacute;mero de recomendaciones cross-sell a mostrar en la p&aacute;gina de producto."
9
+ "Up-sell recommendations", "Recomendaciones up-sell"
10
+ "Activate/Deactivate up-sell recommendations in shopping cart page.", "Activa/Desactiva las recomendaciones up-sell en la p&aacute;gina del carrito."
11
+ "Number of up-sell recommendations to show in shopping cart page.", "N&uacute;mero de recomendaciones up-sell a mostrar en la p&aacute;gina del carrito."
12
+
13
+ "You may also be interested in the following products", "Tambi&eacute;n te pueden interesar los siguientes productos"
14
+ "Customers who bought these products also bought", "Los clientes que compraron estos productos tambi&eacute;n compraron"
app/locale/fr_FR/Blueknow_recommender.csv ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Main configuration", "Configuration principale"
2
+ "Enable", "Active"
3
+ "Activate/Deactivate Blueknow Recommender.", "Activer/D&eacute;sactiver Recommender Blueknow."
4
+ "Unique identifier assigned to this eCommerce.<br />Do you need one? Obtain it for free at <a href='http://www.blueknow.com'>here</a>.", "Identificateur unique attribu&eacute; &agrave; ce eCommerce.<br />Besoin d'une? Obtenez-le gratuitement <a href='http://www.blueknow.com'>ici</a>."
5
+ "Cross-sell recommendations", "Cross-sell recommandations"
6
+ "Activate/Deactivate cross-sell recommendations in product detail page.", "Activer/D&eacute;sactiver la vente crois&eacute;e de recommandations dans la page d&eacute;taill&eacute;e du produit."
7
+ "Recommendations", "Recommandations"
8
+ "Number of cross-sell recommendations to show in product detail page.", "Nombre de cross-sell recommandations &agrave; afficher dans la page d&eacute;taill&eacute;e du produit."
9
+ "Up-sell recommendations", "Up-sell recommandations"
10
+ "Activate/Deactivate up-sell recommendations in shopping cart page.", "Activer/D&eacute;sactiver up-sell recommandations en page du panier."
11
+ "Number of up-sell recommendations to show in shopping cart page.", "Nombre de up-sell recommandations &agrave; afficher dans la page panier."
12
+
13
+ "You may also be interested in the following products", "Vous pouvez &eacute;galement &ecirc;tre int&eacute;ress&eacute; par les produits suivants"
14
+ "Customers who bought these products also bought", "Les clients qui ont achet&eacute; ces produits ont &eacute;galement achet&eacute;"
app/locale/pt_PT/Blueknow_recommender.csv ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Main configuration", "Configura&ccedil;&atilde;o principal"
2
+ "Enable", "Active"
3
+ "Activate/Deactivate Blueknow Recommender.", "Activar/Desactivar Blueknow Recommender."
4
+ "Unique identifier assigned to this eCommerce.<br />Do you need one? Obtain it for free at <a href='http://www.blueknow.com'>here</a>.", "Identificador &uacute;nico atribu&iacute;do a esta eCommerce.<br />Voc&ecirc; precisa de um? Obt&ecirc;-lo gratuitamente <a href='http://www.blueknow.com'>aqui</a>"
5
+ "Cross-sell recommendations", "Recomenda&ccedil;&otilde;es cross-sell"
6
+ "Activate/Deactivate cross-sell recommendations in product detail page.", "Activar/Desactivar recomenda&ccedil;&otilde;es cross-sell na p&aacute;gina de detalhes do produto."
7
+ "Recommendations", "Recomenda&ccedil;&otilde;es"
8
+ "Number of cross-sell recommendations to show in product detail page.", "N&uacute;mero de recomenda&ccedil;&otilde;es cross-sell para mostrar na p&aacute;gina de detalhes do produto."
9
+ "Up-sell recommendations", "Recomenda&ccedil;&otilde;es up-sell"
10
+ "Activate/Deactivate up-sell recommendations in shopping cart page.", "Activar/Desactivar recomenda&ccedil;&otilde;es up-sell na p&aacute;gina do carrinho de compras."
11
+ "Number of up-sell recommendations to show in shopping cart page.", "N&uacute;mero de recomenda&ccedil;&otilde;es up-sell para mostrar na p&aacute;gina do carrinho de compras."
12
+
13
+ "You may also be interested in the following products", "Voc&ecirc; pode tamb&eacute;m estar interessado nos seguintes produtos"
14
+ "Customers who bought these products also bought", "Os clientes que compraram estes produtos tamb&eacute;m compraram"
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>BlueknowRecommender</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>GNU General Public License</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Blueknow Recommender, personalized recommendations for your eCommerce</summary>
10
+ <description>Module that allows cross-selling in the product template and up-selling in the shopping cart. The module is based on a recommendation service similar to that used by Amazon in their own shop. The basis of recommendations are product purchases and visits by users. They are used to display the most relevant products to the user. It has been demonstrated that Blueknow recommender can increase sales between 10% and 30% and is able to recommend products in 70% of orders made.
11
+
12
+ For more information please visit http://www.blueknow.com</description>
13
+ <notes>Release 1.0.0.</notes>
14
+ <authors><author><name>Santiago Ameller</name><user>auto-converted</user><email>santi.ameller@blueknow.com</email></author></authors>
15
+ <date>2011-03-02</date>
16
+ <time>21:52:59</time>
17
+ <contents><target name="magecommunity"><dir name="Blueknow"><dir name="Recommender"><dir name="Block"><dir name="Cart"><file name="Recommender.php" hash="1e79213c3ffe5d477f7d25a36c953691"/></dir><dir name="Checkout"><file name="Tracker.php" hash="feee57fe34d5a14e186926d11dcb77d4"/></dir><dir name="Customer"><file name="Tracker.php" hash="8cdd6e7e35efe0c75f5278281d0cb739"/></dir><dir name="Product"><file name="Base.php" hash="37779f846c8f51ab8621d23eb86a491e"/><file name="Recommender.php" hash="b1a400c8cf5c807b6a55703d0d03ee3f"/><file name="Tracker.php" hash="e25aad30c4d5e903008b8b5e346f0974"/></dir><file name="Base.php" hash="38840c162843e9d72ed049e0d86480b5"/></dir><dir name="documentation"><file name="Blueknow_Recommender_1.0.0_Gui&#x301;a_de_Instalacio&#x301;n.pdf" hash="49b917bed86bf33762701c59a85a737b"/><file name="Blueknow_Recommender_1.0.0_Installation_Guide.pdf" hash="63dd9fd4b13e8f3fa61142e5d37580d5"/><file name="README.txt" hash="b771b0fe724aa1e5d88be036ee3b3c14"/></dir><dir name="etc"><file name="config.xml" hash="e5a259644cf3ae6e7f2c77df55434917"/><file name="system.xml" hash="df86c743e4609909171223ff23620289"/></dir><dir name="Helper"><file name="Category.php" hash="28e9cb1ba4760dca9d57fee7c362d92e"/><file name="Currency.php" hash="defb0558caf4b99ff51e625224435baa"/><file name="Data.php" hash="0ce272b09e25400deea10052796d8047"/><file name="Price.php" hash="dacfc3e63befe026e569c3b0f747abf3"/></dir><dir name="Model"><dir name="Checkout"><file name="Order.php" hash="528094dd22597db76f017c692043e56b"/><file name="Product.php" hash="5955c509457ae609c284f7652eeda7f1"/></dir><dir name="Source"><file name="Numberofrecommendations.php" hash="04a110e6a8e39c8c142c6982be55dd36"/></dir><file name="Cart.php" hash="5b6a6ccbe8da00048ec24dccd455304f"/><file name="Checkout.php" hash="d78caa7cf4d062de5da8def126c50a6b"/><file name="Configuration.php" hash="d027375e3d57332ba62bfe2856a149bd"/><file name="Currency.php" hash="ee88d48c3fedd180783ce8dfe5571266"/><file name="Customer.php" hash="80dd27495bd8ef3489216c9673e50863"/><file name="Observer.php" hash="4ee2d6b1f573449292a735c9f09e8bbc"/><file name="Product.php" hash="3a028849a479cd7637903515a07b28e3"/><file name="Session.php" hash="7ebb42754b21e64cff7f8c6dec561387"/></dir><dir name="sql"><dir name="recommender_setup"><file name="uninstall.sql" hash="35ccfbefcb8b6336b0caad057eb4c330"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="de_DE"><file name="Blueknow_recommender.csv" hash="39933bda483fd7189b987da6fa95b6d6"/></dir><dir name="en_US"><file name="Blueknow_recommender.csv" hash="f8ebfa0e38051a6c37ed05022cf2f6b2"/></dir><dir name="es_ES"><file name="Blueknow_recommender.csv" hash="d2c3531de843114f31a5c24f20fd03bc"/></dir><dir name="fr_FR"><file name="Blueknow_recommender.csv" hash="5125f4172e797895120c6df6c2e43a7e"/></dir><dir name="pt_PT"><file name="Blueknow_recommender.csv" hash="25bc7c02098d478169396f312cf3c031"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="blueknow_recommender.xml" hash="c1a38151dd8edf26dac6353e123fe11d"/></dir><dir name="template"><dir name="blueknow"><dir name="cart"><file name="recommender.phtml" hash="5983f4f54112d28d168a85543ffd9ae6"/><file name="recommender_widget.phtml" hash="b4efcf569d0acb9e965692f73cfb2376"/></dir><dir name="checkout"><file name="tracker.phtml" hash="982575d1c97568a33745f3e65170d1d3"/></dir><dir name="common"><file name="recommender_renderer.phtml" hash="a301063ef0d4d9c0529aba6ce8b59fa9"/><file name="recommender_widget_footer.phtml" hash="49e0aa4c1c8927f02e5d392a75e978fa"/></dir><dir name="customer"><file name="tracker.phtml" hash="ade85c48fc7a6c243c65144bf4e14808"/></dir><dir name="product"><file name="recommender.phtml" hash="cec47fca009c98020233fe99b5175873"/><file name="recommender_widget.phtml" hash="f0d9684de25ea26d14cbd41b2515c712"/><file name="tracker.phtml" hash="91ff2989519f59a991dc08d71fb414ec"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Blueknow_Recommender.xml" hash="792bec9432901b7ce09d9f40d8312b2e"/></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies/>
20
+ </package>