Version Notes
Buscapé e-bit é compatível com Magento Enterprise Edition 1.7.0.0 ou superior, Professional Edition 1.9.0.0 ou superior, e Magento Community Edition 1.3.3.0 ou superior.
Download this release
Release Info
Developer | Magento Core Team |
Extension | Buscape_Lomadee |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/community/Buscape/Lomadee/Block/Adminhtml/System/Config/Fieldset/Events.php +234 -0
- app/code/community/Buscape/Lomadee/Block/Checkout/Success.php +136 -0
- app/code/community/Buscape/Lomadee/Helper/Data.php +68 -0
- app/code/community/Buscape/Lomadee/Model/Config.php +61 -0
- app/code/community/Buscape/Lomadee/Model/Observer.php +52 -0
- app/code/community/Buscape/Lomadee/etc/config.xml +65 -0
- app/code/community/Buscape/Lomadee/etc/system.xml +73 -0
- app/etc/modules/Buscape_Lomadee.xml +29 -0
- package.xml +18 -0
app/code/community/Buscape/Lomadee/Block/Adminhtml/System/Config/Fieldset/Events.php
ADDED
@@ -0,0 +1,234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to suporte.developer@buscape-inc.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Buscape
|
16 |
+
* @package Buscape_Lomadee
|
17 |
+
* @copyright Copyright (c) 2010 Buscapé Company (http://www.buscapecompany.com)
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
class Buscape_Lomadee_Block_Adminhtml_System_Config_Fieldset_Events extends Mage_Adminhtml_Block_Abstract
|
22 |
+
implements Varien_Data_Form_Element_Renderer_Interface
|
23 |
+
{
|
24 |
+
|
25 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
26 |
+
{
|
27 |
+
return $element->getElementHtml();
|
28 |
+
}
|
29 |
+
|
30 |
+
protected function getElementCategories()
|
31 |
+
{
|
32 |
+
$category = Mage::getModel('catalog/category')->getCollection()
|
33 |
+
->addAttributeToSelect('*')
|
34 |
+
->addIsActiveFilter()
|
35 |
+
->addLevelFilter(2)
|
36 |
+
->addOrderField('name');
|
37 |
+
|
38 |
+
$html = "+ '<option value=\"\">Selecione uma categoria</option>'\n\t";
|
39 |
+
|
40 |
+
foreach($category as $cat) {
|
41 |
+
|
42 |
+
if(is_null($cat->getName())) {
|
43 |
+
continue;
|
44 |
+
}
|
45 |
+
|
46 |
+
$value = str_replace("'", "", $cat->getName());
|
47 |
+
|
48 |
+
$html.= "+ '<option value=\"{$cat->getId()}\">{$value}</option>'\n\t";
|
49 |
+
}
|
50 |
+
|
51 |
+
return $html;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Render fieldset html
|
56 |
+
*
|
57 |
+
* @param Varien_Data_Form_Element_Abstract $fieldset
|
58 |
+
* @class Mage_Adminhtml_Block_System_Config_Form_Field
|
59 |
+
* @return string
|
60 |
+
*/
|
61 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
62 |
+
{
|
63 |
+
$id = $element->getHtmlId();
|
64 |
+
|
65 |
+
$html = sprintf('<tr class="system-fieldset-sub-head" id="row_header_%s"><td colspan="5"><h4 id="%s">%s</h4><p class="note"><span>Inclua o(s) codigo(s) fornecido pela Lomadee.com e associe com suas categorias corretamente.</span></p></td></tr>',
|
66 |
+
$element->getHtmlId(), $element->getHtmlId(), $element->getLabel()
|
67 |
+
);
|
68 |
+
|
69 |
+
if(!Mage::helper('lomadee')->validateAvailable()) {
|
70 |
+
$html .= sprintf('<tr class="system-fieldset-sub-head" id="row_header_%s"><td colspan="5"><h4 id="%s">O plugin eBehavior está sendo utilizado no sistema.</h4><p class="note"><span>Entre em contato com o eBehavior para habilitar o Lomadee.</span></p></td></tr>',
|
71 |
+
$element->getHtmlId(), $element->getHtmlId(), $element->getLabel()
|
72 |
+
);
|
73 |
+
}
|
74 |
+
|
75 |
+
$html.= <<<SCRIPT
|
76 |
+
|
77 |
+
<script type="text/javascript">
|
78 |
+
//<![CDATA[
|
79 |
+
|
80 |
+
var templateLomadee = '<tr id="events_lomadee_row_#{index}">'
|
81 |
+
+ '<td>'
|
82 |
+
+ '<input type="input" name="groups[lomadee][fields][event_#{index}][value]" value="#{event_value}" class="input-text" style="width: 50px;" />'
|
83 |
+
+ '</td>'
|
84 |
+
+ '<td>'
|
85 |
+
+ '<select name="groups[lomadee][fields][event_category_#{index}][value]" id="lomadee_category_#{index}" style="width: 220px;" class="select">'
|
86 |
+
{$this->getElementCategories()}
|
87 |
+
+ '</select>'
|
88 |
+
+ '</td>'
|
89 |
+
+ '</tr>';
|
90 |
+
|
91 |
+
var Lomadee = {
|
92 |
+
template: new Template(templateLomadee),
|
93 |
+
itemsCount: 1,
|
94 |
+
addItem: function() {
|
95 |
+
|
96 |
+
var data = {
|
97 |
+
event_value: '',
|
98 |
+
index: this.itemsCount++,
|
99 |
+
category_value: '',
|
100 |
+
};
|
101 |
+
|
102 |
+
if(arguments.length >= 1) {
|
103 |
+
data.event_value = arguments[0];
|
104 |
+
data.category_value = arguments[1];
|
105 |
+
}
|
106 |
+
|
107 |
+
Element.insert($('events_lomadee'), {
|
108 |
+
bottom : this.template.evaluate(data)
|
109 |
+
});
|
110 |
+
|
111 |
+
if(arguments[0] == '') {
|
112 |
+
$('events_lomadee_row_' + data.index).hide();
|
113 |
+
}
|
114 |
+
|
115 |
+
if(data.category_value != '') {
|
116 |
+
$('lomadee_category_' + data.index).value = data.category_value;
|
117 |
+
}
|
118 |
+
},
|
119 |
+
deleteItem: function(event) {
|
120 |
+
|
121 |
+
var tr = Event.findElement(event, 'tr');
|
122 |
+
|
123 |
+
if (tr) {
|
124 |
+
Element.select(tr, '.delete').each(function(elem){elem.value='1'});
|
125 |
+
Element.select(tr, ['input', 'select']).each(function(elem){elem.hide()});
|
126 |
+
Element.hide(tr);
|
127 |
+
Element.addClassName(tr, 'no-display template');
|
128 |
+
}
|
129 |
+
return false;
|
130 |
+
}
|
131 |
+
};
|
132 |
+
|
133 |
+
//]]>
|
134 |
+
</script>
|
135 |
+
SCRIPT;
|
136 |
+
|
137 |
+
$html.= '<tr id="row_' . $id . '">'
|
138 |
+
. '<td class="label"><button id="events_lomadee_additem" class="scalable add" onclick="Lomadee.addItem(); return false;" type="button"><span>Adicionar</span></button></td>';
|
139 |
+
|
140 |
+
$html.= '<td class="value">';
|
141 |
+
|
142 |
+
$html.= '<table id="events_lomadee">';
|
143 |
+
|
144 |
+
$html.= '</table>';
|
145 |
+
$html.= '</td>';
|
146 |
+
$html.= '</tr>';
|
147 |
+
|
148 |
+
$prepare = null;
|
149 |
+
|
150 |
+
$prepare = array();
|
151 |
+
|
152 |
+
$events = Mage::getModel('core/config_data')->getCollection();
|
153 |
+
|
154 |
+
$events->addFieldToFilter('path', array('like' => 'sales/lomadee/event_%'));
|
155 |
+
|
156 |
+
$events->setOrder('path', 'ASC');
|
157 |
+
|
158 |
+
if($events->count() > 0) {
|
159 |
+
|
160 |
+
foreach($events as $event) {
|
161 |
+
|
162 |
+
$validate = explode("/", $event->getPath());
|
163 |
+
|
164 |
+
$validate = explode("_", $validate[2]);
|
165 |
+
|
166 |
+
$format = explode("/", $event->getPath());
|
167 |
+
|
168 |
+
switch(count($validate)) {
|
169 |
+
case 2:
|
170 |
+
$prepare[$format[2]] = array('event_value' => $event->getValue());
|
171 |
+
break;
|
172 |
+
case 3:
|
173 |
+
|
174 |
+
$event_id = str_replace("category_", "", $format[2]);
|
175 |
+
|
176 |
+
if(array_key_exists($event_id, $prepare) && !is_null($event->getValue())) {
|
177 |
+
$prepare[$event_id]['category_path'] = $event->getPath();
|
178 |
+
|
179 |
+
$prepare[$event_id]['category_value'] = $event->getValue();
|
180 |
+
}
|
181 |
+
break;
|
182 |
+
}
|
183 |
+
|
184 |
+
// remove data
|
185 |
+
if(is_null($event->getValue()) || $event->getValue() === '') {
|
186 |
+
|
187 |
+
$event_exclude = Mage::getModel('core/config_data')
|
188 |
+
->getCollection()
|
189 |
+
->addFieldToFilter('path', array('in' => array($event->getData('path'), str_replace("event", "event_category", $event->getData('path')))));
|
190 |
+
|
191 |
+
if($event_exclude->count()) {
|
192 |
+
|
193 |
+
try {
|
194 |
+
|
195 |
+
foreach($event_exclude as $exc) {
|
196 |
+
|
197 |
+
$exclude = Mage::getModel('core/config_data')->load($exc->getId());
|
198 |
+
|
199 |
+
$exclude->delete();
|
200 |
+
}
|
201 |
+
|
202 |
+
} catch(Exception $e) {
|
203 |
+
// log
|
204 |
+
}
|
205 |
+
}
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
$script_load = <<<SCRIPT
|
210 |
+
<script type="text/javascript">
|
211 |
+
//<![CDATA[
|
212 |
+
SCRIPT;
|
213 |
+
$script_load .= "\n";
|
214 |
+
|
215 |
+
foreach($prepare as $key => $data) {
|
216 |
+
|
217 |
+
if(!is_null($data)) {
|
218 |
+
|
219 |
+
$script_load .= sprintf("Lomadee.addItem('%s', '%s');", $data['event_value'], $data['category_value']);
|
220 |
+
|
221 |
+
$script_load .= "\n";
|
222 |
+
}
|
223 |
+
}
|
224 |
+
|
225 |
+
$script_load .= <<<SCRIPT
|
226 |
+
//]]>
|
227 |
+
</script>
|
228 |
+
SCRIPT;
|
229 |
+
$html.= $script_load;
|
230 |
+
}
|
231 |
+
|
232 |
+
return $html;
|
233 |
+
}
|
234 |
+
}
|
app/code/community/Buscape/Lomadee/Block/Checkout/Success.php
ADDED
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to suporte.developer@buscape-inc.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Buscape
|
16 |
+
* @package Buscape_Lomadee
|
17 |
+
* @copyright Copyright (c) 2010 Buscapé Company (http://www.buscapecompany.com)
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
class Buscape_Lomadee_Block_Checkout_Success extends Mage_Core_Block_Text
|
22 |
+
{
|
23 |
+
protected function _getTrackingCode()
|
24 |
+
{
|
25 |
+
$orderIds = $this->getOrderIds();
|
26 |
+
|
27 |
+
if(is_null($orderIds)) {
|
28 |
+
return;
|
29 |
+
}
|
30 |
+
|
31 |
+
$collection = Mage::getResourceModel('sales/order_collection')
|
32 |
+
->addFieldToFilter('entity_id', array('in' => $orderIds));
|
33 |
+
|
34 |
+
$result = array();
|
35 |
+
|
36 |
+
foreach ($collection as $order) {
|
37 |
+
|
38 |
+
if($order->getIsVirtual()) {
|
39 |
+
$address = $order->getBillingAddress();
|
40 |
+
} else {
|
41 |
+
$address = $order->getShippingAddress();
|
42 |
+
}
|
43 |
+
|
44 |
+
$item_event_group = array();
|
45 |
+
|
46 |
+
foreach($order->getAllVisibleItems() as $item) {
|
47 |
+
|
48 |
+
$product = Mage::getModel('catalog/product')->load($item->getProductId());
|
49 |
+
|
50 |
+
$category = Mage::getModel('catalog/category')
|
51 |
+
->getCollection()
|
52 |
+
->addFieldToFilter('entity_id', array('in' => implode(",", $product->getCategoryIds())))
|
53 |
+
->getFirstItem();
|
54 |
+
|
55 |
+
$category_level = explode("/", $category->getData('path'));
|
56 |
+
|
57 |
+
if(!isset($category_level[2])) {
|
58 |
+
continue;
|
59 |
+
}
|
60 |
+
|
61 |
+
$events = Mage::getModel('core/config_data')
|
62 |
+
->getCollection()
|
63 |
+
->addFieldToFilter('path', array('like' => 'sales/lomadee/event_category_%'))
|
64 |
+
->addFieldToFilter('value', $category_level[2])
|
65 |
+
->getFirstItem();
|
66 |
+
|
67 |
+
if(is_null($events)) {
|
68 |
+
continue;
|
69 |
+
}
|
70 |
+
|
71 |
+
$category_event = str_replace("category_", "", $events->getData('path'));
|
72 |
+
$category_event = str_replace("sales/lomadee/", "", $category_event);
|
73 |
+
|
74 |
+
$event_data = Mage::getModel('core/config_data')
|
75 |
+
->getCollection()
|
76 |
+
->addFieldToFilter('path', array('like' => 'sales/lomadee/' . $category_event))
|
77 |
+
->getFirstItem();
|
78 |
+
|
79 |
+
if(is_null($event_data->getData('value')) || is_null($category_level[2]) || $event_data->getData('value') === '' || $category_level[2] === '') {
|
80 |
+
continue;
|
81 |
+
}
|
82 |
+
|
83 |
+
if(isset($item_event_group[$event_data->getData('value')])) {
|
84 |
+
|
85 |
+
$item_event_group[$event_data->getData('value')] += $item->getPrice() * intval($item->getQtyOrdered());
|
86 |
+
} else {
|
87 |
+
$item_event_group[$event_data->getData('value')] = $item->getPrice() * intval($item->getQtyOrdered());
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
$event = '';
|
92 |
+
|
93 |
+
$i = 1;
|
94 |
+
foreach($item_event_group as $cat_event => $price) {
|
95 |
+
if(strlen($price) > 6) {
|
96 |
+
$price = number_format($price, 2, ',', '.');
|
97 |
+
} else {
|
98 |
+
$price = number_format($price, 2);
|
99 |
+
}
|
100 |
+
$event .= "&event{$i}={$cat_event}&value{$i}=" . $price;
|
101 |
+
$i++;
|
102 |
+
}
|
103 |
+
|
104 |
+
if(count($item_event_group) == 0) {
|
105 |
+
continue;
|
106 |
+
}
|
107 |
+
|
108 |
+
$url = sprintf("https://secure.lomadee.com/at/actionlog?adv=%s&country=%s&transaction=%s",
|
109 |
+
Mage::getModel('lomadee/config')->getAccount(),
|
110 |
+
$address->getCountry(),
|
111 |
+
$order->getIncrementId()
|
112 |
+
);
|
113 |
+
|
114 |
+
$result[] = $url . $event;
|
115 |
+
}
|
116 |
+
|
117 |
+
if(count($result) == 0) {
|
118 |
+
return false;
|
119 |
+
}
|
120 |
+
|
121 |
+
return implode("\n", $result);
|
122 |
+
}
|
123 |
+
|
124 |
+
protected function _toHtml()
|
125 |
+
{
|
126 |
+
if (!Mage::helper('lomadee')->isAvailable() || !$this->_getTrackingCode()) {
|
127 |
+
return '';
|
128 |
+
}
|
129 |
+
|
130 |
+
return '
|
131 |
+
<!-- BEGIN LOMADEE CODE -->
|
132 |
+
<img width="1" height="1" src="' . $this->_getTrackingCode() . '" style="position: absolute; margin-left: -5000px" />
|
133 |
+
<!-- END LOMADEE CODE -->
|
134 |
+
';
|
135 |
+
}
|
136 |
+
}
|
app/code/community/Buscape/Lomadee/Helper/Data.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to suporte.developer@buscape-inc.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Buscape
|
16 |
+
* @package Buscape_Lomadee
|
17 |
+
* @copyright Copyright (c) 2010 Buscapé Company (http://www.buscapecompany.com)
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
class Buscape_Lomadee_Helper_Data extends Mage_Core_Helper_Abstract
|
22 |
+
{
|
23 |
+
const DEBUG = true;
|
24 |
+
|
25 |
+
public function isAvailable($store = null)
|
26 |
+
{
|
27 |
+
$accountId = Mage::getStoreConfig(Buscape_Lomadee_Model_Config::XML_PATH_ACCOUNT, $store);
|
28 |
+
return $accountId && Mage::getStoreConfigFlag(Buscape_Lomadee_Model_Config::XML_PATH_ACTIVE, $store) && $this->validateAvailable();
|
29 |
+
}
|
30 |
+
|
31 |
+
public function validateAvailable()
|
32 |
+
{
|
33 |
+
if(self::DEBUG) {
|
34 |
+
return true;
|
35 |
+
}
|
36 |
+
|
37 |
+
$modules = array_keys((array)Mage::getConfig()->getNode('modules')->children());
|
38 |
+
|
39 |
+
$advancedDisabled = true;
|
40 |
+
|
41 |
+
$moduleDisabled = true;
|
42 |
+
|
43 |
+
$data = Mage::getModel('core/config_data')
|
44 |
+
->getCollection()
|
45 |
+
->addFieldToFilter('path', array('like' => 'advanced/modules_disable_output/Buscape_Ebehavior'))
|
46 |
+
->getFirstItem();
|
47 |
+
|
48 |
+
$module = Mage::getConfig()->getNode('modules')->{'Buscape_Ebehavior'};
|
49 |
+
|
50 |
+
if(!is_null($data->getData())) {
|
51 |
+
|
52 |
+
$advancedDisabled = (intval($data->getValue()) == 1) ? true : false;
|
53 |
+
}
|
54 |
+
|
55 |
+
if(!is_null($module->active)) {
|
56 |
+
$inactive = (array) $module->active;
|
57 |
+
$inactive = ($inactive[0] == 'false') ? true : false;
|
58 |
+
|
59 |
+
$moduleDisabled = $inactive;
|
60 |
+
}
|
61 |
+
|
62 |
+
if($moduleDisabled && $advancedDisabled) {
|
63 |
+
return true;
|
64 |
+
}
|
65 |
+
|
66 |
+
return false;
|
67 |
+
}
|
68 |
+
}
|
app/code/community/Buscape/Lomadee/Model/Config.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to suporte.developer@buscape-inc.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Buscape
|
16 |
+
* @package Buscape_Lomadee
|
17 |
+
* @copyright Copyright (c) 2010 Buscapé Company (http://www.buscapecompany.com)
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
class Buscape_Lomadee_Model_Config extends Varien_Object
|
22 |
+
{
|
23 |
+
const XML_PATH = 'sales/lomadee/';
|
24 |
+
|
25 |
+
const XML_PATH_ACTIVE = 'sales/lomadee/active';
|
26 |
+
|
27 |
+
const XML_PATH_ACCOUNT = 'sales/lomadee/advertising';
|
28 |
+
|
29 |
+
const XML_PATH_EVENT = 'sales/lomadee/event';
|
30 |
+
|
31 |
+
const XML_PATH_UNIQUE = 'sales/lomadee/unique';
|
32 |
+
|
33 |
+
protected $_config = array();
|
34 |
+
|
35 |
+
public function getConfigData($key, $storeId = null)
|
36 |
+
{
|
37 |
+
if (!isset($this->_config[$key][$storeId])) {
|
38 |
+
$value = Mage::getStoreConfig(self::XML_PATH . $key, $storeId);
|
39 |
+
$this->_config[$key][$storeId] = $value;
|
40 |
+
}
|
41 |
+
return $this->_config[$key][$storeId];
|
42 |
+
}
|
43 |
+
|
44 |
+
public function getAccount($store = null)
|
45 |
+
{
|
46 |
+
if (!$this->hasData('lomadee_account')) {
|
47 |
+
$this->setData('lomadee_account', $this->getConfigData('advertising', $store));
|
48 |
+
}
|
49 |
+
|
50 |
+
return $this->getData('lomadee_account');
|
51 |
+
}
|
52 |
+
|
53 |
+
public function getEvent($store = null)
|
54 |
+
{
|
55 |
+
if (!$this->hasData('lomadee_event')) {
|
56 |
+
$this->setData('lomadee_event', $this->getConfigData('event', $store));
|
57 |
+
}
|
58 |
+
|
59 |
+
return $this->getData('lomadee_event');
|
60 |
+
}
|
61 |
+
}
|
app/code/community/Buscape/Lomadee/Model/Observer.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to suporte.developer@buscape-inc.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Buscape
|
16 |
+
* @package Buscape_Lomadee
|
17 |
+
* @copyright Copyright (c) 2010 Buscapé Company (http://www.buscapecompany.com)
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
class Buscape_Lomadee_Model_Observer
|
22 |
+
{
|
23 |
+
const BLOCK_CHECKOUT_SUCCESS = 'Buscape_Lomadee_Block_Checkout_Success';
|
24 |
+
|
25 |
+
protected function _getOnepage()
|
26 |
+
{
|
27 |
+
return Mage::getSingleton('checkout/type_onepage');
|
28 |
+
}
|
29 |
+
|
30 |
+
public function setLomadeeOnOrderSuccessPageView(Varien_Event_Observer $observer)
|
31 |
+
{
|
32 |
+
|
33 |
+
$lastOrderId = $this->_getOnepage()->getCheckout()->getLastOrderId();
|
34 |
+
|
35 |
+
$block = Mage::app()->getFrontController()->getAction()->getLayout()->createBlock(
|
36 |
+
self::BLOCK_CHECKOUT_SUCCESS,
|
37 |
+
'lomadee_checkout_success',
|
38 |
+
array(
|
39 |
+
'as' => 'lomadee_checkout_success'
|
40 |
+
)
|
41 |
+
);
|
42 |
+
|
43 |
+
$content = Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('content');
|
44 |
+
|
45 |
+
if ($content) {
|
46 |
+
|
47 |
+
$block->setOrderIds($lastOrderId);
|
48 |
+
|
49 |
+
$content->insert($block);
|
50 |
+
}
|
51 |
+
}
|
52 |
+
}
|
app/code/community/Buscape/Lomadee/etc/config.xml
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to suporte.developer@buscape-inc.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* @category Buscape
|
17 |
+
* @package Buscape_Lomadee
|
18 |
+
* @copyright Copyright (c) 2010 Buscapé Company (http://www.buscapecompany.com)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
-->
|
22 |
+
<config>
|
23 |
+
<modules>
|
24 |
+
<Buscape_Lomadee>
|
25 |
+
<version>0.1.0</version>
|
26 |
+
</Buscape_Lomadee>
|
27 |
+
</modules>
|
28 |
+
<global>
|
29 |
+
<models>
|
30 |
+
<lomadee>
|
31 |
+
<class>Buscape_Lomadee_Model</class>
|
32 |
+
</lomadee>
|
33 |
+
</models>
|
34 |
+
<blocks>
|
35 |
+
<lomadee>
|
36 |
+
<class>Buscape_Lomadee_Block</class>
|
37 |
+
</lomadee>
|
38 |
+
</blocks>
|
39 |
+
<helpers>
|
40 |
+
<lomadee>
|
41 |
+
<class>Buscape_Lomadee_Helper</class>
|
42 |
+
</lomadee>
|
43 |
+
</helpers>
|
44 |
+
</global>
|
45 |
+
<frontend>
|
46 |
+
<events>
|
47 |
+
<checkout_onepage_controller_success_action>
|
48 |
+
<observers>
|
49 |
+
<lomadee_order_success>
|
50 |
+
<class>lomadee/observer</class>
|
51 |
+
<method>setLomadeeOnOrderSuccessPageView</method>
|
52 |
+
</lomadee_order_success>
|
53 |
+
</observers>
|
54 |
+
</checkout_onepage_controller_success_action>
|
55 |
+
<checkout_multishipping_controller_success_action>
|
56 |
+
<observers>
|
57 |
+
<lomadee_order_success>
|
58 |
+
<class>lomadee/observer</class>
|
59 |
+
<method>setLomadeeOnOrderSuccessPageView</method>
|
60 |
+
</lomadee_order_success>
|
61 |
+
</observers>
|
62 |
+
</checkout_multishipping_controller_success_action>
|
63 |
+
</events>
|
64 |
+
</frontend>
|
65 |
+
</config>
|
app/code/community/Buscape/Lomadee/etc/system.xml
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to suporte.developer@buscape-inc.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* @category Buscape
|
17 |
+
* @package Buscape_Lomadee
|
18 |
+
* @copyright Copyright (c) 2010 Buscapé Company (http://www.buscapecompany.com)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
-->
|
22 |
+
<config>
|
23 |
+
<sections>
|
24 |
+
<sales translate="label" module="lomadee">
|
25 |
+
<groups>
|
26 |
+
<lomadee translate="label">
|
27 |
+
<label>BuscaPé Lomadee</label>
|
28 |
+
<sort_order>10</sort_order>
|
29 |
+
<show_in_default>1</show_in_default>
|
30 |
+
<show_in_website>1</show_in_website>
|
31 |
+
<show_in_store>1</show_in_store>
|
32 |
+
<comment>
|
33 |
+
<![CDATA[
|
34 |
+
<div style="padding:10px;background-color:#fff;border:1px solid #ddd;margin-bottom:7px;">
|
35 |
+
Este módulo foi desenvolvido pelo <a href="http://developer.buscape.com" target="_blank">Core BuscaPé</a>.
|
36 |
+
Por favor reportar bugs para <a href="mailto:magento@buscape-inc.com">magento@buscape-inc.com</a>.
|
37 |
+
</div>
|
38 |
+
]]>
|
39 |
+
</comment>
|
40 |
+
<fields>
|
41 |
+
<active translate="label">
|
42 |
+
<label>Habilitado</label>
|
43 |
+
<frontend_type>select</frontend_type>
|
44 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
45 |
+
<sort_order>10</sort_order>
|
46 |
+
<show_in_default>1</show_in_default>
|
47 |
+
<show_in_website>1</show_in_website>
|
48 |
+
<show_in_store>1</show_in_store>
|
49 |
+
</active>
|
50 |
+
<advertising translate="label">
|
51 |
+
<label>Código do anunciante</label>
|
52 |
+
<frontend_type>text</frontend_type>
|
53 |
+
<sort_order>20</sort_order>
|
54 |
+
<show_in_default>1</show_in_default>
|
55 |
+
<show_in_website>1</show_in_website>
|
56 |
+
<show_in_store>1</show_in_store>
|
57 |
+
</advertising>
|
58 |
+
<events>
|
59 |
+
<label>Código dos Eventos</label>
|
60 |
+
<button_label>Adicionar</button_label>
|
61 |
+
<button_url><![CDATA[https://]]></button_url>
|
62 |
+
<frontend_model>lomadee/adminhtml_system_config_fieldset_events</frontend_model>
|
63 |
+
<sort_order>25</sort_order>
|
64 |
+
<show_in_default>1</show_in_default>
|
65 |
+
<show_in_website>1</show_in_website>
|
66 |
+
<show_in_store>1</show_in_store>
|
67 |
+
</events>
|
68 |
+
</fields>
|
69 |
+
</lomadee>
|
70 |
+
</groups>
|
71 |
+
</sales>
|
72 |
+
</sections>
|
73 |
+
</config>
|
app/etc/modules/Buscape_Lomadee.xml
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to suporte.developer@buscape-inc.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* @category Buscape
|
17 |
+
* @package Buscape_Lomadee
|
18 |
+
* @copyright Copyright (c) 2010 Buscapé Company (http://www.buscapecompany.com)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
-->
|
22 |
+
<config>
|
23 |
+
<modules>
|
24 |
+
<Buscape_Lomadee>
|
25 |
+
<active>true</active>
|
26 |
+
<codePool>community</codePool>
|
27 |
+
</Buscape_Lomadee>
|
28 |
+
</modules>
|
29 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Buscape_Lomadee</name>
|
4 |
+
<version>0.1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Você pode consultar a performance e resultados das suas campanhas em uma interface consolidada. Muito mais facilidade para gerenciar seu Programa.</summary>
|
10 |
+
<description>Extensão Buscapé Lomadee para Magento</description>
|
11 |
+
<notes>Buscapé e-bit é compatível com Magento Enterprise Edition 1.7.0.0 ou superior, Professional Edition 1.9.0.0 ou superior, e Magento Community Edition 1.3.3.0 ou superior.</notes>
|
12 |
+
<authors><author><name>Adriano Aguiar</name><user>auto-converted</user><email>adrianoaguiaralves@gmail.com</email></author></authors>
|
13 |
+
<date>2011-11-29</date>
|
14 |
+
<time>17:50:40</time>
|
15 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Buscape_Lomadee.xml" hash="d9c1175b52e250abe9721d97f1c2cb9a"/></dir></target><target name="magecommunity"><dir name="Buscape"><dir name="Lomadee"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Events.php" hash="f6a836ff384aeecab784405bea321f55"/></dir></dir></dir></dir><dir name="Checkout"><file name="Success.php" hash="8b8feae72b59dd750344d0f42e637b2a"/></dir></dir><dir name="Helper"><file name="Data.php" hash="e6154c1d0e75726c4b5a814d314558c4"/></dir><dir name="Model"><file name="Config.php" hash="816574c8f70cb67796f5fb0f03e123a2"/><file name="Observer.php" hash="f171f3ea315cdf3b35d0a4322b5e94c3"/></dir><dir name="etc"><file name="config.xml" hash="25f62e37e78d329d02f1fcfa9acc907d"/><file name="system.xml" hash="90f4d7cb0c456ddb968b731f52d50cac"/></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies/>
|
18 |
+
</package>
|