Version Notes
First Stable Release
Download this release
Release Info
Developer | Ti |
Extension | Ti_Autocrossupsells |
Version | 1.0.1 |
Comparing to | |
See all releases |
Version 1.0.1
- app/code/community/Ti/Autocrossupsells/Helper/Data.php +31 -0
- app/code/community/Ti/Autocrossupsells/controllers/Checkout/OnepageController.php +107 -0
- app/code/community/Ti/Autocrossupsells/etc/adminhtml.xml +30 -0
- app/code/community/Ti/Autocrossupsells/etc/config.xml +37 -0
- app/code/community/Ti/Autocrossupsells/etc/system.xml +75 -0
- app/etc/modules/Ti_Autocrossupsells.xml +9 -0
- app/locale/de_DE/Ti_Autocrossupsells.csv +9 -0
- app/locale/en_US/Ti_Autocrossupsells.csv +11 -0
- package.xml +21 -0
app/code/community/Ti/Autocrossupsells/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_Autocrossupsells_Helper_Data extends Mage_Core_Helper_Abstract
|
11 |
+
{
|
12 |
+
const XML_PATH_ENABLED = 'autocrossupsells/autocrossupsellssettings/enable_action';
|
13 |
+
const XML_PATH_ENABLE_UPSELL = 'autocrossupsells/autocrossupsellssettings/enable_upsell';
|
14 |
+
const XML_PATH_CATEGORY_FILTER = 'autocrossupsells/autocrossupsellssettings/category_filter';
|
15 |
+
const XML_PATH_ENABLE_CROSSELL = 'autocrossupsells/autocrossupsellssettings/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/Autocrossupsells/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_Autocrossupsells
|
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_Autocrossupsells_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_autocrossupsells')->isEnabled() &&(Mage::helper('ti_autocrossupsells')->isUpsellEnabled()||Mage::helper('ti_autocrossupsells')->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_autocrossupsells')->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_autocrossupsells')->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_autocrossupsells')->isCrossellEnabled()):
|
97 |
+
$obj->assign('cross_sell', $id, $value);
|
98 |
+
$obj->assign('cross_sell', $value, $id);
|
99 |
+
endif;
|
100 |
+
if(Mage::helper('ti_autocrossupsells')->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/Autocrossupsells/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_Autocrossupsells>
|
11 |
+
<title>Auto cross-sells Module</title>
|
12 |
+
<sort_order>10</sort_order>
|
13 |
+
</Ti_Autocrossupsells>
|
14 |
+
<system>
|
15 |
+
<children>
|
16 |
+
<config>
|
17 |
+
<children>
|
18 |
+
<autocrossupsells translate="title" module="ti_autocrossupsells">
|
19 |
+
<title>Auto cross-sells Settings</title>
|
20 |
+
<sort_order>50</sort_order>
|
21 |
+
</autocrossupsells>
|
22 |
+
</children>
|
23 |
+
</config>
|
24 |
+
</children>
|
25 |
+
</system>
|
26 |
+
</children>
|
27 |
+
</admin>
|
28 |
+
</resources>
|
29 |
+
</acl>
|
30 |
+
</config>
|
app/code/community/Ti/Autocrossupsells/etc/config.xml
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Ti_Autocrossupsells>
|
5 |
+
<version>1.0.1</version>
|
6 |
+
</Ti_Autocrossupsells>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<helpers>
|
10 |
+
<ti_autocrossupsells>
|
11 |
+
<class>Ti_Autocrossupsells_Helper</class>
|
12 |
+
</ti_autocrossupsells>
|
13 |
+
</helpers>
|
14 |
+
</global>
|
15 |
+
<frontend>
|
16 |
+
<routers>
|
17 |
+
<checkout>
|
18 |
+
<args>
|
19 |
+
<modules>
|
20 |
+
<Ti_Autocrossupsells before="Mage_Checkout">Ti_Autocrossupsells_Checkout</Ti_Autocrossupsells>
|
21 |
+
</modules>
|
22 |
+
</args>
|
23 |
+
</checkout>
|
24 |
+
</routers>
|
25 |
+
</frontend>
|
26 |
+
<adminhtml>
|
27 |
+
<translate>
|
28 |
+
<modules>
|
29 |
+
<Ti_Autocrossupsells>
|
30 |
+
<files>
|
31 |
+
<default>Ti_Autocrossupsells.csv</default>
|
32 |
+
</files>
|
33 |
+
</Ti_Autocrossupsells>
|
34 |
+
</modules>
|
35 |
+
</translate>
|
36 |
+
</adminhtml>
|
37 |
+
</config>
|
app/code/community/Ti/Autocrossupsells/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_autocrossupsells">
|
5 |
+
<label>Ti Tech Extensions</label>
|
6 |
+
<sort_order>100</sort_order>
|
7 |
+
</titechextension>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<autocrossupsells translate="label" module="ti_autocrossupsells">
|
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 |
+
<autocrossupsellssettings translate="label" module="ti_autocrossupsells">
|
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 |
+
</autocrossupsellssettings>
|
72 |
+
</groups>
|
73 |
+
</autocrossupsells>
|
74 |
+
</sections>
|
75 |
+
</config>
|
app/etc/modules/Ti_Autocrossupsells.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Ti_Autocrossupsells>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Ti_Autocrossupsells>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/locale/de_DE/Ti_Autocrossupsells.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_Autocrossupsells.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,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Ti_Autocrossupsells</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. 
|
10 |
+
Its working like who bought this also bought concept. </summary>
|
11 |
+
<description>Adds the cross sell & up sell functionality in each order with its products .
|
12 |
+
Also we have an optional field for categories based filter.
|
13 |
+
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>
|
14 |
+
<notes>First Stable Release</notes>
|
15 |
+
<authors><author><name>Ti Technologies</name><user>titech</user><email>info@titechnologies.in</email></author></authors>
|
16 |
+
<date>2013-01-17</date>
|
17 |
+
<time>12:09:34</time>
|
18 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Ti_Autocrossupsells.xml" hash="d9f6e6ba22e37d3be394a129afad530b"/></dir></target><target name="magecommunity"><dir name="Ti"><dir name="Autocrossupsells"><dir name="Helper"><file name="Data.php" hash="8989cf5ba545d9070e195aec7eb3e5b8"/></dir><dir name="controllers"><dir name="Checkout"><file name="OnepageController.php" hash="bd82c452e3d4220a7d1e1aee14b6589e"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="8141acc2647b074fea0e7fe0b7951e97"/><file name="config.xml" hash="87f9724ce0d1d16cb46d1f4d96e94337"/><file name="system.xml" hash="a49b24e5a4c4090b3599fbe4536bc8d7"/></dir></dir></dir></target><target name="magelocale"><dir name="de_DE"><file name="Ti_Autocrossupsells.csv" hash="ed3608e8799b33c1db80468d9450f14c"/></dir><dir name="en_US"><file name="Ti_Autocrossupsells.csv" hash="d3b37dcd22e09273d4e1e6677b38b375"/></dir></target></contents>
|
19 |
+
<compatible/>
|
20 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
21 |
+
</package>
|