Version Notes
First Stable Release
Download this release
Release Info
Developer | Ti |
Extension | Ti_Autocrossupsell |
Version | 1.0.1 |
Comparing to | |
See all releases |
Version 1.0.1
- app/code/community/Ti/Autocrossupsell/Helper/Data.php +31 -0
- app/code/community/Ti/Autocrossupsell/controllers/Checkout/OnepageController.php +107 -0
- app/code/community/Ti/Autocrossupsell/etc/adminhtml.xml +30 -0
- app/code/community/Ti/Autocrossupsell/etc/config.xml +37 -0
- app/code/community/Ti/Autocrossupsell/etc/system.xml +75 -0
- app/etc/modules/Ti_Autocrossupsell.xml +9 -0
- app/locale/de_DE/Ti_Autocrossupsell.csv +9 -0
- app/locale/en_US/Ti_Autocrossupsell.csv +11 -0
- package.xml +20 -0
app/code/community/Ti/Autocrossupsell/Helper/Data.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ti Automatic Cross & Up-sell Module
|
4 |
+
*
|
5 |
+
* @category Ti
|
6 |
+
* @package Ti_Autocrossupsell
|
7 |
+
* @copyright Copyright (c) 2012 Ti Technologies (http://www.titechnologies.in)
|
8 |
+
* @link http://www.titechnologies.in
|
9 |
+
*/
|
10 |
+
class Ti_Autocrossupsell_Helper_Data extends Mage_Core_Helper_Abstract
|
11 |
+
{
|
12 |
+
const XML_PATH_ENABLED = 'autocrossupsell/autocrossupsellsettings/enable_action';
|
13 |
+
const XML_PATH_ENABLE_UPSELL = 'autocrossupsell/autocrossupsellsettings/enable_upsell';
|
14 |
+
const XML_PATH_CATEGORY_FILTER = 'autocrossupsell/autocrossupsellsettings/category_filter';
|
15 |
+
const XML_PATH_ENABLE_CROSSELL = 'autocrossupsell/autocrossupsellsettings/enable_crossell';
|
16 |
+
|
17 |
+
|
18 |
+
public function isEnabled() {
|
19 |
+
return Mage::getStoreConfig(self::XML_PATH_ENABLED);
|
20 |
+
}
|
21 |
+
public function isCrossellEnabled() {
|
22 |
+
return Mage::getStoreConfig(self::XML_PATH_ENABLE_CROSSELL);
|
23 |
+
}
|
24 |
+
public function isUpsellEnabled() {
|
25 |
+
return Mage::getStoreConfig(self::XML_PATH_ENABLE_UPSELL);
|
26 |
+
}
|
27 |
+
public function isCategoryFilterEnabled() {
|
28 |
+
return Mage::getStoreConfig(self::XML_PATH_CATEGORY_FILTER);
|
29 |
+
}
|
30 |
+
|
31 |
+
}
|
app/code/community/Ti/Autocrossupsell/controllers/Checkout/OnepageController.php
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ti Automatic Cross & Up sells Module
|
4 |
+
*
|
5 |
+
* @category Ti
|
6 |
+
* @package Ti_Autocrossupsell
|
7 |
+
* @copyright Copyright (c) 2012 Ti Technologies (http://www.titechnologies.in)
|
8 |
+
* @link http://www.titechnologies.in
|
9 |
+
*/
|
10 |
+
|
11 |
+
|
12 |
+
require_once 'Mage/Checkout/controllers/OnepageController.php';
|
13 |
+
class Ti_Autocrossupsell_Checkout_OnepageController extends Mage_Checkout_OnepageController
|
14 |
+
{
|
15 |
+
protected $category_id = array();
|
16 |
+
public function successAction()
|
17 |
+
{
|
18 |
+
$session = $this->getOnepage()->getCheckout();
|
19 |
+
if (!$session->getLastSuccessQuoteId()) {
|
20 |
+
$this->_redirect('checkout/cart');
|
21 |
+
return;
|
22 |
+
}
|
23 |
+
|
24 |
+
|
25 |
+
$lastQuoteId = $session->getLastQuoteId();
|
26 |
+
$lastOrderId = $session->getLastOrderId();
|
27 |
+
if(Mage::helper('ti_autocrossupsell')->isEnabled() &&(Mage::helper('ti_autocrossupsell')->isUpsellEnabled()||Mage::helper('ti_autocrossupsell')->isCrossellEnabled())):
|
28 |
+
$order = Mage::getModel('sales/order')->load($lastOrderId);
|
29 |
+
$items = $order->getAllItems();
|
30 |
+
$ids=array();
|
31 |
+
foreach ($items as $itemId => $item)
|
32 |
+
{
|
33 |
+
if(!$item->getParentItemId()):
|
34 |
+
$ids[]=$item->getProductId();
|
35 |
+
if(Mage::helper('ti_autocrossupsell')->isCategoryFilterEnabled()):
|
36 |
+
$product_model = Mage::getModel('catalog/product');
|
37 |
+
$_product = $product_model->load($item->getProductId()); // $product_id is the given product id
|
38 |
+
$this->category_id [$item->getProductId()] = $product_model->getCategoryIds($_product);
|
39 |
+
endif;
|
40 |
+
endif;
|
41 |
+
}
|
42 |
+
if(count($ids)>1):
|
43 |
+
$this->addCrossel($ids);
|
44 |
+
endif;
|
45 |
+
endif;
|
46 |
+
$lastRecurringProfiles = $session->getLastRecurringProfileIds();
|
47 |
+
if (!$lastQuoteId || (!$lastOrderId && empty($lastRecurringProfiles))) {
|
48 |
+
$this->_redirect('checkout/cart');
|
49 |
+
return;
|
50 |
+
}
|
51 |
+
$session->clear();
|
52 |
+
$this->loadLayout();
|
53 |
+
$this->_initLayoutMessages('checkout/session');
|
54 |
+
Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId)));
|
55 |
+
$this->renderLayout();
|
56 |
+
}
|
57 |
+
|
58 |
+
public function addCrossel($product_ids)
|
59 |
+
{
|
60 |
+
$flagProductId = $product_ids;
|
61 |
+
$linkid = array();
|
62 |
+
foreach($product_ids as $key => $value):
|
63 |
+
unset($flagProductId[$key]);
|
64 |
+
$linkid=$flagProductId;
|
65 |
+
if(count($flagProductId)):
|
66 |
+
if(Mage::helper('ti_autocrossupsell')->isCategoryFilterEnabled()):
|
67 |
+
$linkid = $this->categoryFilter($value,$flagProductId);
|
68 |
+
endif;
|
69 |
+
endif;
|
70 |
+
if(count($linkid)):
|
71 |
+
$this->addLink($value,$linkid);
|
72 |
+
endif;
|
73 |
+
endforeach;
|
74 |
+
return;
|
75 |
+
|
76 |
+
|
77 |
+
}
|
78 |
+
public function categoryFilter($value,$array)
|
79 |
+
{
|
80 |
+
$productCatId=$this->category_id[$value];
|
81 |
+
$categorySplitArray =array();
|
82 |
+
$categorySplitArray=$array;
|
83 |
+
foreach($array as $key=>$value):
|
84 |
+
$linkProductcatId = $this->category_id[$value];
|
85 |
+
$result = array_intersect($linkProductcatId, $productCatId);
|
86 |
+
if(empty($result)):
|
87 |
+
unset($categorySplitArray[$key]);
|
88 |
+
endif;
|
89 |
+
endforeach;
|
90 |
+
return $categorySplitArray;
|
91 |
+
}
|
92 |
+
public function addLink($id,$linkid)
|
93 |
+
{
|
94 |
+
$obj = new Mage_Catalog_Model_Product_Link_Api();
|
95 |
+
foreach($linkid as $key=>$value):
|
96 |
+
if(Mage::helper('ti_autocrossupsell')->isCrossellEnabled()):
|
97 |
+
$obj->assign('cross_sell', $id, $value);
|
98 |
+
$obj->assign('cross_sell', $value, $id);
|
99 |
+
endif;
|
100 |
+
if(Mage::helper('ti_autocrossupsell')->isUpsellEnabled()):
|
101 |
+
$obj->assign('up_sell', $id, $value);
|
102 |
+
$obj->assign('up_sell', $value, $id);
|
103 |
+
endif;
|
104 |
+
endforeach;
|
105 |
+
return;
|
106 |
+
}
|
107 |
+
}
|
app/code/community/Ti/Autocrossupsell/etc/adminhtml.xml
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<acl>
|
4 |
+
<resources>
|
5 |
+
<all>
|
6 |
+
<title>Allow Everything</title>
|
7 |
+
</all>
|
8 |
+
<admin>
|
9 |
+
<children>
|
10 |
+
<Ti_Autocrossupsell>
|
11 |
+
<title>Auto cross-sells Module</title>
|
12 |
+
<sort_order>10</sort_order>
|
13 |
+
</Ti_Autocrossupsell>
|
14 |
+
<system>
|
15 |
+
<children>
|
16 |
+
<config>
|
17 |
+
<children>
|
18 |
+
<autocrossupsell translate="title" module="ti_autocrossupsell">
|
19 |
+
<title>Auto cross-sells Settings</title>
|
20 |
+
<sort_order>50</sort_order>
|
21 |
+
</autocrossupsell>
|
22 |
+
</children>
|
23 |
+
</config>
|
24 |
+
</children>
|
25 |
+
</system>
|
26 |
+
</children>
|
27 |
+
</admin>
|
28 |
+
</resources>
|
29 |
+
</acl>
|
30 |
+
</config>
|
app/code/community/Ti/Autocrossupsell/etc/config.xml
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Ti_Autocrossupsell>
|
5 |
+
<version>1.0.1</version>
|
6 |
+
</Ti_Autocrossupsell>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<helpers>
|
10 |
+
<ti_autocrossupsell>
|
11 |
+
<class>Ti_Autocrossupsell_Helper</class>
|
12 |
+
</ti_autocrossupsell>
|
13 |
+
</helpers>
|
14 |
+
</global>
|
15 |
+
<frontend>
|
16 |
+
<routers>
|
17 |
+
<checkout>
|
18 |
+
<args>
|
19 |
+
<modules>
|
20 |
+
<Ti_Autocrossupsell before="Mage_Checkout">Ti_Autocrossupsell_Checkout</Ti_Autocrossupsell>
|
21 |
+
</modules>
|
22 |
+
</args>
|
23 |
+
</checkout>
|
24 |
+
</routers>
|
25 |
+
</frontend>
|
26 |
+
<adminhtml>
|
27 |
+
<translate>
|
28 |
+
<modules>
|
29 |
+
<Ti_Autocrossupsell>
|
30 |
+
<files>
|
31 |
+
<default>Ti_Autocrossupsell.csv</default>
|
32 |
+
</files>
|
33 |
+
</Ti_Autocrossupsell>
|
34 |
+
</modules>
|
35 |
+
</translate>
|
36 |
+
</adminhtml>
|
37 |
+
</config>
|
app/code/community/Ti/Autocrossupsell/etc/system.xml
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<titechextension translate="label" module="ti_autocrossupsell">
|
5 |
+
<label>Ti Tech Extensions</label>
|
6 |
+
<sort_order>100</sort_order>
|
7 |
+
</titechextension>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<autocrossupsell translate="label" module="ti_autocrossupsell">
|
11 |
+
<label>Automatic cross-sells and upsell</label>
|
12 |
+
<tab>titechextension</tab>
|
13 |
+
<sort_order>1000</sort_order>
|
14 |
+
<show_in_default>1</show_in_default>
|
15 |
+
<show_in_website>1</show_in_website>
|
16 |
+
<show_in_store>1</show_in_store>
|
17 |
+
|
18 |
+
<groups>
|
19 |
+
<autocrossupsellsettings translate="label" module="ti_autocrossupsell">
|
20 |
+
<label>Configurations</label>
|
21 |
+
<frontend_type>text</frontend_type>
|
22 |
+
<sort_order>1000</sort_order>
|
23 |
+
<show_in_default>1</show_in_default>
|
24 |
+
<show_in_website>1</show_in_website>
|
25 |
+
<show_in_store>1</show_in_store>
|
26 |
+
<fields>
|
27 |
+
<enable_action translate="label, comment">
|
28 |
+
<label>Automatic cross-sell and upsell module</label>
|
29 |
+
<comment><![CDATA[select yes to enable automatic cross-sell and upsell module]]></comment>
|
30 |
+
<frontend_type>select</frontend_type>
|
31 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
32 |
+
<sort_order>1</sort_order>
|
33 |
+
<show_in_default>1</show_in_default>
|
34 |
+
<show_in_website>1</show_in_website>
|
35 |
+
<show_in_store>1</show_in_store>
|
36 |
+
</enable_action>
|
37 |
+
<enable_crossell translate="label, comment">
|
38 |
+
<label>cross-sell settings</label>
|
39 |
+
<comment><![CDATA[select yes to enable automatic cross-sells action]]></comment>
|
40 |
+
<depends><enable_action>1</enable_action></depends>
|
41 |
+
<frontend_type>select</frontend_type>
|
42 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
43 |
+
<sort_order>2</sort_order>
|
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 |
+
</enable_crossell>
|
48 |
+
<enable_upsell translate="label, comment">
|
49 |
+
<label>up-sell settings</label>
|
50 |
+
<comment><![CDATA[select yes to enable automatic up-sell action]]></comment>
|
51 |
+
<depends><enable_action>1</enable_action></depends>
|
52 |
+
<frontend_type>select</frontend_type>
|
53 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
54 |
+
<sort_order>3</sort_order>
|
55 |
+
<show_in_default>1</show_in_default>
|
56 |
+
<show_in_website>1</show_in_website>
|
57 |
+
<show_in_store>1</show_in_store>
|
58 |
+
</enable_upsell>
|
59 |
+
<category_filter translate="label, comment">
|
60 |
+
<label>Category Filter</label>
|
61 |
+
<comment><![CDATA[select yes to enable category filter in automatic cross-sells & Up sells]]></comment>
|
62 |
+
<depends><enable_action>1</enable_action></depends>
|
63 |
+
<frontend_type>select</frontend_type>
|
64 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
65 |
+
<sort_order>4</sort_order>
|
66 |
+
<show_in_default>1</show_in_default>
|
67 |
+
<show_in_website>1</show_in_website>
|
68 |
+
<show_in_store>1</show_in_store>
|
69 |
+
</category_filter>
|
70 |
+
</fields>
|
71 |
+
</autocrossupsellsettings>
|
72 |
+
</groups>
|
73 |
+
</autocrossupsell>
|
74 |
+
</sections>
|
75 |
+
</config>
|
app/etc/modules/Ti_Autocrossupsell.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Ti_Autocrossupsell>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Ti_Autocrossupsell>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/locale/de_DE/Ti_Autocrossupsell.csv
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"Automatic cross-sell and upsell module","Automatische Cross-Selling und Up-Selling-Modul"
|
2 |
+
"Automatic cross-sells and upsells Settings","Automatisches Cross-sells-und Upselling-Einstellungen"
|
3 |
+
"select yes to enable automatic cross-sell and upsell module","Wählen Sie Ja, automatische Cross-und Upselling-Modul aktivieren"
|
4 |
+
"cross-sell settings","Cross-Selling-Einstellungen"
|
5 |
+
"select yes to enable automatic cross-sells action","Wählen Sie Ja, automatische Cross-Selling-Maßnahmen zu ermöglichen"
|
6 |
+
"up-sell settings","Up-Selling-Einstellungen"
|
7 |
+
"select yes to enable automatic up-sell action","Wählen Sie Ja, automatische Up-Selling-Maßnahmen zu ermöglichen"
|
8 |
+
"Category Filter","Kategorie Filter"
|
9 |
+
"select yes to enable category filter in automatic cross-sells","Wählen Sie Ja, Kategorie-Filter in der automatischen Cross-Selling zu ermöglichen"
|
app/locale/en_US/Ti_Autocrossupsell.csv
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"Automatic cross-sell and upsell module","Automatic cross-sell and upsell module"
|
2 |
+
"Automatic cross-sells and upsells Settings","Automatic cross-sells and upsells Settings"
|
3 |
+
"select yes to enable automatic cross-sell and upsell module","select yes to enable automatic cross-sell and upsell module"
|
4 |
+
"cross-sell settings","cross-sell settings"
|
5 |
+
"select yes to enable automatic cross-sells action","select yes to enable automatic cross-sells action"
|
6 |
+
"up-sell settings","up-sell settings"
|
7 |
+
"select yes to enable automatic up-sell action","select yes to enable automatic up-sell action"
|
8 |
+
"Category Filter","Category Filter"
|
9 |
+
"select yes to enable category filter in automatic cross-sells","select yes to enable category filter in automatic cross-sells"
|
10 |
+
"Yes","Yes"
|
11 |
+
"No","No"
|
package.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Ti_Autocrossupsell</name>
|
4 |
+
<version>1.0.1</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>GNU General Public License (GPL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>It will do the automatic cross-sell and up-sell functionality with category filter & Its working lIke who bought this also bought concept.</summary>
|
10 |
+
<description>Adds the cross sell &amp; up sell functionality in each order with its products.
|
11 |
+
Also we have an optional field for categories based filter.
|
12 |
+
If a customer purchases X and Y,. After successful order, X will be added as a cross-sell or up-sell product of Y and vice versa.</description>
|
13 |
+
<notes>First Stable Release</notes>
|
14 |
+
<authors><author><name>Ti Technologies</name><user>titech</user><email>info@titechnologies.in</email></author></authors>
|
15 |
+
<date>2013-02-20</date>
|
16 |
+
<time>11:18:54</time>
|
17 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Ti_Autocrossupsell.xml" hash="bca033b0e09190f5b82ea3bcd1ec84bf"/></dir></target><target name="magecommunity"><dir name="Ti"><dir name="Autocrossupsell"><dir name="Helper"><file name="Data.php" hash="bc0696e56e76b644aa62d9b61e01975d"/></dir><dir name="controllers"><dir name="Checkout"><file name="OnepageController.php" hash="452027841699eee1ac44a532ed3dec92"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="88c9a6a1b93046380c5361edacd351fc"/><file name="config.xml" hash="741e2593f9820d0ada323484622193cd"/><file name="system.xml" hash="aa755e4eca87c67169af1319d55143e6"/></dir></dir></dir></target><target name="magelocale"><dir name="de_DE"><file name="Ti_Autocrossupsell.csv" hash="ed3608e8799b33c1db80468d9450f14c"/></dir><dir name="en_US"><file name="Ti_Autocrossupsell.csv" hash="d3b37dcd22e09273d4e1e6677b38b375"/></dir></target></contents>
|
18 |
+
<compatible/>
|
19 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
20 |
+
</package>
|