Affiliate4You_A4yPixelAndFeed - Version 0.1.1

Version Notes

First released version.

Download this release

Release Info

Developer Affiliate4You
Extension Affiliate4You_A4yPixelAndFeed
Version 0.1.1
Comparing to
See all releases


Version 0.1.1

app/code/community/Affiliate4You/A4yPixelAndFeed/Block/Conversion.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Affiliate4You_A4yPixelAndFeed_Block_Conversion extends Mage_Core_Block_Template
4
+ {
5
+ public function getIsActive()
6
+ {
7
+ return Mage::getStoreConfig('a4ypixel/general/enabled') ? true : false;
8
+ }
9
+
10
+ public function getCampaignId()
11
+ {
12
+ return Mage::getStoreConfig('a4ypixel/general/campaign_id');
13
+ }
14
+ }
app/code/community/Affiliate4You/A4yPixelAndFeed/Helper/Data.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Affiliate4You_A4yPixelAndFeed_Helper_Data extends Mage_Core_Helper_Abstract {
4
+
5
+ }
6
+
7
+ ?>
app/code/community/Affiliate4You/A4yPixelAndFeed/Helper/SimpleXml.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Affiliate4You_A4yPixelAndFeed_Helper_SimpleXml extends SimpleXMLElement
4
+ {
5
+
6
+ public function add_cdata( $cdata_text )
7
+ {
8
+ $node = dom_import_simplexml( $this );
9
+ $no = $node->ownerDocument;
10
+ $node->appendChild( $no->createCDATASection( $cdata_text ) );
11
+ }
12
+
13
+ public function as_formated_xml()
14
+ {
15
+ $xml_string = $this->asXML();
16
+ $dom = new DOMDocument( '1.0', 'UTF-8' );
17
+ $dom->loadXML( $xml_string );
18
+ $dom->preserveWhiteSpace = FALSE;
19
+ $dom->formatOutput = TRUE;
20
+ return $dom->saveXML();
21
+ }
22
+ }
app/code/community/Affiliate4You/A4yPixelAndFeed/Helper/XmlFeed.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Author: Lennart Kramer
4
+ Company: Affiliate4You
5
+ Version: 0.1.1
6
+ Date: 14 August 2013
7
+ */
8
+
9
+ class Affiliate4You_A4yPixelAndFeed_Helper_XmlFeed
10
+ {
11
+ private $_config;
12
+
13
+ function __construct($config)
14
+ {
15
+ $this->_config = $config;
16
+ }
17
+
18
+ public function build_xml(array $products)
19
+ {
20
+ $xml_feed = new Affiliate4You_A4yPixelAndFeed_Helper_SimpleXml('<?xml version="1.0" encoding="UTF-8"?><products></products>');
21
+ foreach ($products as $product)
22
+ {
23
+ $xml_product = $xml_feed->addChild('product');
24
+ $xml_product = $this->_add_product_fields($xml_product, $product);
25
+ }
26
+ return $xml_feed->as_formated_xml();
27
+ }
28
+
29
+ private function _add_product_fields($xml_product, $product_fields)
30
+ {
31
+ foreach($product_fields as $field_name => $field_value)
32
+ {
33
+ $field_value = $this->_clean_string($field_value);
34
+ if ($field_name == 'link')
35
+ {
36
+ $field_value = $this->_add_url_params($field_value);
37
+ }
38
+ $product = $xml_product->addChild($field_name, NULL);
39
+ $product->add_cdata($field_value);
40
+ }
41
+
42
+ return $xml_product;
43
+ }
44
+
45
+ private function _add_url_params($url)
46
+ {
47
+ if( ! strstr($url, '?'))
48
+ {
49
+ $url .= '?'.str_replace('?','', $this->_config->general->urlparam);
50
+ }
51
+ else
52
+ {
53
+ $url .= '&'.str_replace('?','', $this->_config->general->urlparam);
54
+ }
55
+ return $url;
56
+ }
57
+
58
+ private function _clean_string($string)
59
+ {
60
+ $string = strip_tags($string);
61
+ $string = str_replace(array('"',"\r\n","\n","\r","\t"), array(""," "," "," ",""), $string);
62
+ return $string;
63
+ }
64
+ }
65
+ ?>
app/code/community/Affiliate4You/A4yPixelAndFeed/Model/Observer.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Affiliate4You_A4yPixelAndFeed_Model_Observer
3
+ {
4
+ public function captureReferral(Varien_Event_Observer $observer)
5
+ {
6
+ if (!empty($_GET["a4ytrid"]) && !empty($_GET["a4yadvid"]))
7
+ {
8
+ // If you do not use the built-in session functionality in PHP, modify below
9
+ session_start();
10
+ // set domain from the SERVER vars
11
+ $a4yCookieDomain = str_replace("www.", "", (!empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']));
12
+
13
+ // set cookie for default 100 days. Actual time will be set when checking order
14
+ setcookie("A4Ytrid[".$_GET["a4yadvid"]."]", $_GET["a4ytrid"],(time() + 100*24*60*60), "/", '.'.$a4yCookieDomain);
15
+ // If you do not use the built-in session functionality in PHP, modify
16
+ // the following expression to work with your session handling routines.
17
+ $_SESSION["A4Ytrid"] = $_GET["a4ytrid"];
18
+ }
19
+ }
20
+ }
app/code/community/Affiliate4You/A4yPixelAndFeed/controllers/IndexController.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Author: Lennart Kramer
4
+ Company: Affiliate4You
5
+ Version: 0.1.1
6
+ Date: 14 August 2013
7
+ */
8
+ class Affiliate4You_A4yPixelAndFeed_IndexController extends Mage_Core_Controller_Front_Action {
9
+ private $_Products;
10
+ private $_ProductIds;
11
+ private $_Config;
12
+ private $_ConfigPaths = array
13
+ (
14
+ 'a4yfeed/general/enabled',
15
+ 'a4yfeed/general/urlparam',
16
+ 'a4yfeed/general/imgsmall_width',
17
+ 'a4yfeed/general/imgsmall_height',
18
+ 'a4yfeed/general/imgmedium_width',
19
+ 'a4yfeed/general/imgmedium_height',
20
+ 'a4yfeed/general/shippingtime',
21
+ 'a4yfeed/general/shippingcost'
22
+ );
23
+
24
+ public function indexAction()
25
+ {
26
+ set_time_limit(3600);
27
+ $this->_setConfig();
28
+ if($this->_Config->general->enabled == 1)
29
+ {
30
+ $Feed = new Affiliate4You_A4yPixelAndFeed_Helper_XmlFeed($this->_Config);
31
+ $this->_buildProductsArray();
32
+ $_Products = array();
33
+ foreach($this->_ProductIds as $iProduct)
34
+ {
35
+ array_push($_Products,$this->_getProductData($iProduct));
36
+ }
37
+ $xmlFeed = $Feed->build_xml($_Products);
38
+ $this->_sendHeader();
39
+ echo $xmlFeed;
40
+ }
41
+ }
42
+
43
+ private function _setConfig()
44
+ {
45
+ $this->_Config = new StdClass();
46
+ foreach($this->_ConfigPaths as $Path)
47
+ {
48
+ $Parts = explode('/',$Path);
49
+ @$this->_Config->$Parts[1]->$Parts[2] = Mage::getStoreConfig($Path);
50
+ }
51
+
52
+ if(!is_numeric($this->_Config->general->imgsmall_width))
53
+ {
54
+ $this->_Config->general->imgsmall_width = 150;
55
+ }
56
+
57
+ if(!is_numeric($this->_Config->general->imgsmall_height))
58
+ {
59
+ $this->_Config->general->imgsmall_height = 150;
60
+ }
61
+
62
+ if(!is_numeric($this->_Config->general->imgmedium_width))
63
+ {
64
+ $this->_Config->general->imgmedium_width = 320;
65
+ }
66
+
67
+ if(!is_numeric($this->_Config->general->imgmedium_height))
68
+ {
69
+ $this->_Config->general->imgmedium_height = 320;
70
+ }
71
+ }
72
+
73
+ private function _buildProductsArray()
74
+ {
75
+ $this->_Products = Mage::getModel('catalog/product')->getCollection();
76
+ $this->_Products->addAttributeToFilter('status', 1);//enabled
77
+ $this->_Products->addAttributeToFilter('visibility', 4);//catalog, search
78
+ $this->_Products->addAttributeToSelect('*');
79
+ $this->_ProductIds = $this->_Products->getAllIds();
80
+ }
81
+
82
+ private function _getProductData($ProductInput)
83
+ {
84
+ $Product = Mage::getModel('catalog/product')->load($ProductInput);
85
+ $Cats = $this->_getCategories($Product);
86
+ $Data = array();
87
+ $Data['id']=$ProductInput;
88
+ $Data['title']=$Product->getName();
89
+ $Data['description']=strip_tags($Product->getDescription());
90
+ $Data['price']=$Product->getPrice();
91
+ $Data['special_price']=$Product->getSpecialPrice();
92
+ $Data['link']=$Product->getProductUrl();
93
+ $Data['image_link_large']= Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product'.$Product->getImage();
94
+ $Data['image_link_small']= (string) Mage::helper('catalog/image')->init( $Product, 'image')->resize($this->_Config->general->imgsmall_width,$this->_Config->general->imgsmall_height);
95
+ $Data['image_link_medium']= (string) Mage::helper('catalog/image')->init($Product, 'image')->resize($this->_Config->general->imgmedium_width,$this->_Config->general->imgmedium_width);
96
+ $Data['category'] = $Cats['main'];
97
+ $Data['subcategory'] = $Cats['sub'];
98
+ $Data['brand']=$Product->getResource()->getAttribute('manufacturer')->getFrontend()->getValue($Product);
99
+ $Data['availability']='yes';
100
+ $Data['shippingcost'] = $this->_Config->general->shippingcost;
101
+ $Data['shippingtime'] = $this->_Config->general->shippingtime;
102
+
103
+ $attributes = $Product->getAttributes();
104
+
105
+ foreach ($attributes as $attribute)
106
+ {
107
+ if ($attribute->getIsVisibleOnFront())
108
+ {
109
+ $Data[$attribute->getAttributeCode()] = $attribute->getFrontend()->getValue($Product);
110
+ // do something with $value here
111
+ }
112
+ }
113
+
114
+ if($Data['special_price'] == '')
115
+ {
116
+ $Data['special_price'] = $Data['price'];
117
+ }
118
+
119
+ return $Data;
120
+ }
121
+
122
+ private function _getCategories($Product)
123
+ {
124
+ $Ids = $Product->getCategoryIds();
125
+
126
+ $Categories = array();
127
+
128
+ foreach($Ids as $Category)
129
+ {
130
+ $CategoryModel = Mage::getModel('catalog/category')->load($Category);
131
+ if ($CategoryModel->getLevel() != '3' && $CategoryModel->getLevel() != '4')
132
+ {
133
+ continue;
134
+ }
135
+ $Categories['main'] = $CategoryModel->getParentCategory()->getName();
136
+ $Categories['sub'] = $CategoryModel->getName();
137
+ }
138
+
139
+ return $Categories;
140
+ }
141
+
142
+ private function _sendHeader()
143
+ {
144
+ header('Content-type: text/xml');
145
+ }
146
+
147
+ private function _debug($m)
148
+ {
149
+ echo '<pre>';
150
+ print_r($m);
151
+ echo '</pre>';
152
+ }
153
+ }
app/code/community/Affiliate4You/A4yPixelAndFeed/etc/adminhtml.xml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ Author: Lennart Kramer
4
+ Company: Affiliate4You
5
+ Version: 0.1.1
6
+ Date: 14 August 2013
7
+ -->
8
+ <config>
9
+ <acl>
10
+ <resources>
11
+ <admin>
12
+ <children>
13
+ <system>
14
+ <children>
15
+ <config>
16
+ <children>
17
+ <a4yfeed translate="title" module="a4ypixelandfeed">
18
+ <title>Affiliate4You Product Feed</title>
19
+ </a4yfeed>
20
+ <a4ypixel translate="title" module="a4ypixelandfeed">
21
+ <title>Affiliate4You Tracking Pixel</title>
22
+ </a4ypixel>
23
+ </children>
24
+ </config>
25
+ </children>
26
+ </system>
27
+ </children>
28
+ </admin>
29
+ </resources>
30
+ </acl>
31
+ </config>
app/code/community/Affiliate4You/A4yPixelAndFeed/etc/config.xml ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ Author: Lennart Kramer
4
+ Company: Affiliate4You
5
+ Version: 0.1.1
6
+ Date: 14 August 2013
7
+ -->
8
+ <config>
9
+ <modules>
10
+ <Affiliate4You_A4yPixelAndFeed>
11
+ <version>0.1.1</version>
12
+ </Affiliate4You_A4yPixelAndFeed>
13
+ </modules>
14
+ <global>
15
+ <models>
16
+ <a4ypixelandfeed>
17
+ <class>Affiliate4You_A4yPixelAndFeed_Model</class>
18
+ </a4ypixelandfeed>
19
+ </models>
20
+ <blocks>
21
+ <affiliate4you_a4ypixelandfeed>
22
+ <class>Affiliate4You_A4yPixelAndFeed_Block</class>
23
+ </affiliate4you_a4ypixelandfeed>
24
+ </blocks>
25
+ <helpers>
26
+ <a4ypixelandfeed>
27
+ <class>Affiliate4You_A4yPixelAndFeed_Helper</class>
28
+ </a4ypixelandfeed>
29
+ </helpers>
30
+ <events>
31
+ <controller_front_init_before>
32
+ <observers>
33
+ <a4ypixelandfeed>
34
+ <class>Affiliate4You_A4yPixelAndFeed_Model_Observer</class>
35
+ <method>captureReferral</method>
36
+ <type>singleton</type>
37
+ </a4ypixelandfeed>
38
+ </observers>
39
+ </controller_front_init_before>
40
+ </events>
41
+ </global>
42
+ <frontend>
43
+ <routers>
44
+ <affiliate4you_a4ypixelandfeed>
45
+ <use>standard</use>
46
+ <args>
47
+ <module>Affiliate4You_A4yPixelAndFeed</module>
48
+ <frontName>a4ypixelandfeed</frontName>
49
+ </args>
50
+ </affiliate4you_a4ypixelandfeed>
51
+ </routers>
52
+ <layout>
53
+ <updates>
54
+ <affiliate4you_a4ypixelandfeed module="Affiliate4You_A4yPixelAndFeed">
55
+ <file>affiliate4you_a4ypixelandfeed.xml</file>
56
+ </affiliate4you_a4ypixelandfeed>
57
+ </updates>
58
+ </layout>
59
+ </frontend>
60
+ <default>
61
+ <a4yfeed>
62
+ <general>
63
+ <enabled>1</enabled>
64
+ <imgsmall_width>150</imgsmall_width>
65
+ <imgsmall_height>150</imgsmall_height>
66
+ <imgmedium_width>300</imgmedium_width>
67
+ <imgmedium_height>300</imgmedium_height>
68
+ <shippingtime>1 day</shippingtime>
69
+ <shippingcost>1.50</shippingcost>
70
+ </general>
71
+ </a4yfeed>
72
+ <a4ypixel>
73
+ <general>
74
+ <enabled>1</enabled>
75
+ </general>
76
+ </a4ypixel>
77
+ </default>
78
+ </config>
app/code/community/Affiliate4You/A4yPixelAndFeed/etc/system.xml ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ Author: Lennart Kramer
4
+ Company: Affiliate4You
5
+ Version: 0.1.1
6
+ Date: 14 August 2013
7
+ -->
8
+ <config>
9
+ <tabs>
10
+ <affiliate4you>
11
+ <label>Affiliate4You</label>
12
+ <sort_order>200</sort_order>
13
+ </affiliate4you>
14
+ </tabs>
15
+ <sections>
16
+ <a4yfeed module="a4ypixelandfeed">
17
+ <label>Affiliate4You Product Feed</label>
18
+ <tab>affiliate4you</tab>
19
+ <frontend_type>text</frontend_type>
20
+ <sort_order>200</sort_order>
21
+ <show_in_default>1</show_in_default>
22
+ <show_in_website>1</show_in_website>
23
+ <show_in_store>1</show_in_store>
24
+ <groups>
25
+ <general>
26
+ <label>General</label>
27
+ <sort_order>100</sort_order>
28
+ <show_in_default>1</show_in_default>
29
+ <show_in_website>1</show_in_website>
30
+ <show_in_store>1</show_in_store>
31
+ <fields>
32
+ <enabled>
33
+ <label>Enabled</label>
34
+ <frontend_type>select</frontend_type>
35
+ <comment><![CDATA[ When enabled you can access the feed at: http://yourdomain.com/a4ypixelandfeed ]]></comment>
36
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
37
+ <sort_order>0</sort_order>
38
+ <show_in_default>1</show_in_default>
39
+ <show_in_website>1</show_in_website>
40
+ <show_in_store>1</show_in_store>
41
+ </enabled>
42
+ <urlparam>
43
+ <label>Optional URL parameters</label>
44
+ <comment><![CDATA[ Extra parameters to add to product URLs. For example: utm_source=ay&utm_medium=feed&utm_campaign=mycampaign ]]></comment>
45
+ <frontend_type>text</frontend_type>
46
+ <sort_order>10</sort_order>
47
+ <show_in_default>1</show_in_default>
48
+ <show_in_website>1</show_in_website>
49
+ <show_in_store>1</show_in_store>
50
+ </urlparam>
51
+ <imgsmall_width>
52
+ <label>Width for small image</label>
53
+ <comment><![CDATA[ in pixels ]]></comment>
54
+ <frontend_type>text</frontend_type>
55
+ <sort_order>20</sort_order>
56
+ <show_in_default>1</show_in_default>
57
+ <show_in_website>1</show_in_website>
58
+ <show_in_store>1</show_in_store>
59
+ </imgsmall_width>
60
+ <imgsmall_height>
61
+ <label>Height for small image</label>
62
+ <comment><![CDATA[ in pixels ]]></comment>
63
+ <frontend_type>text</frontend_type>
64
+ <sort_order>30</sort_order>
65
+ <show_in_default>1</show_in_default>
66
+ <show_in_website>1</show_in_website>
67
+ <show_in_store>1</show_in_store>
68
+ </imgsmall_height>
69
+ <imgmedium_width>
70
+ <label>Width for medium image</label>
71
+ <comment><![CDATA[ in pixels (max 500px)]]></comment>
72
+ <frontend_type>text</frontend_type>
73
+ <sort_order>40</sort_order>
74
+ <show_in_default>1</show_in_default>
75
+ <show_in_website>1</show_in_website>
76
+ <show_in_store>1</show_in_store>
77
+ </imgmedium_width>
78
+ <imgmedium_height>
79
+ <label>Height for medium image</label>
80
+ <comment><![CDATA[ in pixels (max 500px)]]></comment>
81
+ <frontend_type>text</frontend_type>
82
+ <sort_order>50</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
+ </imgmedium_height>
87
+ <shippingtime>
88
+ <label>Usual shipping time for products</label>
89
+ <comment><![CDATA[ Can contain letters "1 day" is allowed]]></comment>
90
+ <frontend_type>text</frontend_type>
91
+ <sort_order>60</sort_order>
92
+ <show_in_default>1</show_in_default>
93
+ <show_in_website>1</show_in_website>
94
+ <show_in_store>1</show_in_store>
95
+ </shippingtime>
96
+ <shippingcost>
97
+ <label>Usual shipping cost for products</label>
98
+ <comment><![CDATA[ The format "2.25" is preferred ]]></comment>
99
+ <frontend_type>text</frontend_type>
100
+ <sort_order>70</sort_order>
101
+ <show_in_default>1</show_in_default>
102
+ <show_in_website>1</show_in_website>
103
+ <show_in_store>1</show_in_store>
104
+ </shippingcost>
105
+ </fields>
106
+ </general>
107
+ </groups>
108
+ </a4yfeed>
109
+ <a4ypixel module="a4ypixelandfeed">
110
+ <label>Affilate4You Tracking Pixel</label>
111
+ <tab>affiliate4you</tab>
112
+ <sort_order>300</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
+ <groups>
117
+ <general>
118
+ <label>General</label>
119
+ <sort_order>100</sort_order>
120
+ <show_in_default>1</show_in_default>
121
+ <show_in_website>1</show_in_website>
122
+ <show_in_store>1</show_in_store>
123
+ <fields>
124
+ <enabled>
125
+ <label>Enabled</label>
126
+ <frontend_type>select</frontend_type>
127
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
128
+ <sort_order>0</sort_order>
129
+ <show_in_default>1</show_in_default>
130
+ <show_in_website>1</show_in_website>
131
+ <show_in_store>0</show_in_store>
132
+ </enabled>
133
+ <campaign_id>
134
+ <label>Campaign ID</label>
135
+ <comment><![CDATA[ The correct campaign id will be given to you by Affiliate4You ]]></comment>
136
+ <frontend_type>text</frontend_type>
137
+ <sort_order>10</sort_order>
138
+ <show_in_default>1</show_in_default>
139
+ <show_in_website>1</show_in_website>
140
+ <show_in_store>1</show_in_store>
141
+ </campaign_id>
142
+ </fields>
143
+ </general>
144
+ </groups>
145
+ </a4ypixel>
146
+ </sections>
147
+ </config>
app/design/frontend/base/default/layout/affiliate4you_a4ypixelandfeed.xml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout>
3
+ <checkout_onepage_success>
4
+ <reference name="before_body_end">
5
+ <block type="affiliate4you_a4ypixelandfeed/conversion"
6
+ name="affiliate4you_a4ypixelandfeed_conversion"
7
+ template="affiliate4you_a4ypixelandfeed/conversion.phtml">
8
+ </block>
9
+ </reference>
10
+ </checkout_onepage_success>
11
+ </layout>
app/design/frontend/base/default/template/affiliate4you_a4ypixelandfeed/conversion.phtml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if($this->getIsActive())
3
+ {
4
+ $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
5
+ $order_info = Mage::getModel('sales/order')->loadByIncrementId($orderId);
6
+ $billing_address = $order_info->getBillingAddress();
7
+
8
+ foreach ($order_info->getAllItems() as $order_item)
9
+ {
10
+ break;
11
+ }
12
+
13
+ // Get the Magento Information
14
+ $campaign = $this->getCampaignId();
15
+ $order_number = urlencode($orderId);
16
+ $order_amount = urlencode(number_format($order_info->getSubtotal(), 2, '.', ''));
17
+ $order_description = urlencode(substr($order_item->getName(), 0, 50));
18
+ $customer_info = urlencode($billing_address['postcode'].' '.$billing_address['country_id']);
19
+
20
+ // Get the Tracking ID
21
+ $tracking_id = '';
22
+ if ( ! empty($_SESSION["A4Ytrid"]))
23
+ {
24
+ $tracking_id = $_SESSION["A4Ytrid"];
25
+ }
26
+ elseif ( ! empty($_COOKIE["A4Ytrid"][$campaign]))
27
+ {
28
+ $tracking_id = $_COOKIE["A4Ytrid"][$campaign];
29
+ }
30
+
31
+ $_a4yprotocol = ((strtolower(substr($_SERVER['SERVER_PROTOCOL'],0,5))=='https' || (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')) ? 'https://' : 'http://');
32
+
33
+ $trackingUrl = $_a4yprotocol . "leads.affiliate4you.nl/"
34
+ . "?campagne=" . $campaign
35
+ . "&ordernummer=" . $order_number
36
+ . "&orderbedrag=" . $order_amount
37
+ . "&a4ytrid=" . $tracking_id
38
+ . "&klantnaam=" . $customer_info
39
+ . "&omschr=" . $order_description;
40
+
41
+ echo "\n<img src=\"" . $trackingUrl . "\" alt=\"\" style=\"border: none\" border=\"0\" width=\"1\" height=\"1\" />\n";
42
+ }
43
+ ?>
44
+
app/etc/modules/Affiliate4You_A4yPixelAndFeed.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Affiliate4You_A4yPixelAndFeed>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Affiliate4You_A4yPixelAndFeed>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Affiliate4You_A4yPixelAndFeed</name>
4
+ <version>0.1.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.gnu.org/licenses/gpl-3.0.html">GPL v3</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Automatic tracking pixel placement and xml product feed generator for affiliate marketing purpose.</summary>
10
+ <description>1. Contents&#xD;
11
+ - Uses&#xD;
12
+ - Xml product feed generator&#xD;
13
+ - Tracking pixel on success page&#xD;
14
+ &#xD;
15
+ 2. Uses&#xD;
16
+ This module is intended as a convience meassure for Affiliate4You customers and is optimized to those specifications. However the xml product feed can be used for other purposes.&#xD;
17
+ &#xD;
18
+ 3. Xml product feed generator&#xD;
19
+ When enabled this will provide a xml product feed that has the required fields for Affiliate4you as well as any custom fields you added personally. You can use this generator to easily create a product feed with the correct specifications.&#xD;
20
+ &#xD;
21
+ Admin options:&#xD;
22
+ - Enable/Disable&#xD;
23
+ - Optional URL parameters&#xD;
24
+ - Width for small image&#xD;
25
+ - Height for small image&#xD;
26
+ - Width for medium image&#xD;
27
+ - Height for medium image&#xD;
28
+ - Usual shipping time for products&#xD;
29
+ - Usual shipping cost for products&#xD;
30
+ &#xD;
31
+ 4. Tracking pixel on success page&#xD;
32
+ When enabled this will add a tracking pixel to the succes sale page without you having to edit any base files. The correct campaign ID will be supplied by Affiliate4you.&#xD;
33
+ &#xD;
34
+ Admin options:&#xD;
35
+ - Enable/Disable&#xD;
36
+ - Campaign ID</description>
37
+ <notes>First released version.</notes>
38
+ <authors><author><name>Affiliate4You</name><user>Affiliate4You</user><email>support@affiliate4you.nl</email></author><author><name>Lennart Kramer</name><user>lennartkramer</user><email>lennart@affiliate4you.nl</email></author></authors>
39
+ <date>2013-08-16</date>
40
+ <time>09:32:57</time>
41
+ <contents><target name="magecommunity"><dir name="Affiliate4You"><dir name="A4yPixelAndFeed"><dir name="Block"><file name="Conversion.php" hash="841dbd0c7dc96dbd220f6eecd44ee847"/></dir><dir name="Helper"><file name="Data.php" hash="e1569c51c71ca2c8cf010c702d0d3a49"/><file name="SimpleXml.php" hash="e0f2005a5d7e413bd33b5c904ecc45dc"/><file name="XmlFeed.php" hash="ba0720b40aaba458d5a897b240700d11"/></dir><dir name="Model"><file name="Observer.php" hash="31305b0b35ea8ab288e467ba28d2dd8e"/></dir><dir name="controllers"><file name="IndexController.php" hash="5eebe4a65f12c6b7f8ee6c15f1880418"/></dir><dir name="etc"><file name="adminhtml.xml" hash="8ea247e15036ac836a7c82d08f0ce2a2"/><file name="config.xml" hash="1073db6cacde3168de9060819274be16"/><file name="system.xml" hash="b4b0857d931fed53dd23af4f4e342eff"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Affiliate4You_A4yPixelAndFeed.xml" hash="74f6011a3faf75b1635eef047719815c"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="affiliate4you_a4ypixelandfeed"><file name="conversion.phtml" hash="601d76dbbc3dbf3d03e266c7185926a1"/></dir></dir><dir name="layout"><file name="affiliate4you_a4ypixelandfeed.xml" hash="e87a32ab186a2fd1c25fc1b8d82885e1"/></dir></dir></dir></dir></target></contents>
42
+ <compatible/>
43
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
44
+ </package>