Version Notes
Stable release. Has been tested for bugs, compatibility, and performance on Magento Community Edition 1.6+ and Magento Enterprise Edition 1.11+. This extension has been tested in a live environment, but as always please leave feedback if you run into any issues.
Updated in this version: improved code and new support for Optimizely custom tags! Now any page tags available through the Magento module will appear as custom tags in your Optimizely experiment settings!
Download this release
Release Info
Developer | Blue Acorn, Inc. |
Extension | Blue_Acorn_Optimizely |
Version | 1.1.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.2 to 1.1.0
- app/code/community/BlueAcorn/MiniGrid/Block/System/Config/Form.php +27 -0
- app/code/community/BlueAcorn/MiniGrid/Block/System/Config/Form/Field/Minigrid.php +119 -0
- app/code/community/BlueAcorn/MiniGrid/Block/System/Config/Form/Field/Minigrid/Js.php +189 -0
- app/code/community/BlueAcorn/MiniGrid/Block/Widget/Minigrid/Form.php +142 -0
- app/code/community/BlueAcorn/MiniGrid/Model/System/Config/Backend/Minigrid.php +70 -0
- app/code/community/BlueAcorn/MiniGrid/Model/System/Config/Source/Minigrid/Abstract.php +41 -0
- app/code/community/BlueAcorn/MiniGrid/etc/config.xml +44 -0
- app/code/community/BlueAcorn/Optimizely/Block/CustomVariables.php +155 -384
- app/code/community/BlueAcorn/Optimizely/Block/Head.php +27 -0
- app/code/community/BlueAcorn/Optimizely/Block/SitewideJs.php +23 -0
- app/code/community/BlueAcorn/Optimizely/Block/System/Config/Explanation.php +5 -82
- app/code/community/BlueAcorn/Optimizely/Block/System/Config/Loginlink.php +6 -81
- app/code/community/BlueAcorn/Optimizely/Helper/Data.php +16 -72
- app/code/community/BlueAcorn/Optimizely/Model/DisallowDuplicates.php +0 -37
- app/code/community/BlueAcorn/Optimizely/Model/Enabledcheck.php +9 -5
- app/code/community/BlueAcorn/Optimizely/Model/Entity/Attribute.php +0 -48
- app/code/community/BlueAcorn/Optimizely/Model/Projectcode.php +26 -0
- app/code/community/BlueAcorn/Optimizely/Model/System/Config/Source/Attribute.php +60 -0
- app/code/community/BlueAcorn/Optimizely/Model/System/Config/Source/Minigrid/Attribute.php +37 -0
- app/code/community/BlueAcorn/Optimizely/data/blueacorn_optimizely_setup/data-upgrade-1.0.2-1.1.0.php +43 -0
- app/code/community/BlueAcorn/Optimizely/doc/changelog.txt +0 -5
- app/code/community/BlueAcorn/Optimizely/doc/design.txt +0 -29
- app/code/community/BlueAcorn/Optimizely/doc/makeTar.txt +0 -6
- app/code/community/BlueAcorn/Optimizely/etc/adminhtml.xml +11 -3
- app/code/community/BlueAcorn/Optimizely/etc/config.xml +49 -18
- app/code/community/BlueAcorn/Optimizely/etc/system.xml +27 -50
- app/code/community/BlueAcorn/Optimizely/sql/blueacorn_optimizely_setup/install-1.0.2.php +10 -0
- app/design/frontend/base/default/layout/blueacorn/optimizely.xml +10 -12
- app/design/frontend/base/default/template/blueacorn/optimizely/customVariables.phtml +0 -13
- app/design/frontend/base/default/template/blueacorn/optimizely/sitewideJs.phtml +0 -15
- app/etc/modules/BlueAcorn_Optimizely.xml +10 -8
- app/locale/en_US/BlueAcorn_Optimizely.csv +13 -0
- package.xml +7 -7
app/code/community/BlueAcorn/MiniGrid/Block/System/Config/Form.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* System config form
|
4 |
+
* This form overwrites the System Config form block in order
|
5 |
+
* to add the grid as a frontend type to forms in the system
|
6 |
+
* config.
|
7 |
+
*
|
8 |
+
* @package BlueAcorn\MiniGrid
|
9 |
+
* @version 1.1.0
|
10 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
11 |
+
* @copyright Blue Acorn, Inc. 2014
|
12 |
+
*/
|
13 |
+
class BlueAcorn_MiniGrid_Block_System_Config_Form extends Mage_Adminhtml_Block_System_Config_Form {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Add the additional grid type as a viable type on the form
|
17 |
+
*
|
18 |
+
* @return array
|
19 |
+
*/
|
20 |
+
protected function _getAdditionalElementTypes()
|
21 |
+
{
|
22 |
+
$types = parent::_getAdditionalElementTypes();
|
23 |
+
$types["minigrid"] = Mage::getConfig()->getBlockClassName("baminigrid/system_config_form_field_minigrid");
|
24 |
+
return $types;
|
25 |
+
}
|
26 |
+
|
27 |
+
}
|
app/code/community/BlueAcorn/MiniGrid/Block/System/Config/Form/Field/Minigrid.php
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Minigrid system config field element type
|
4 |
+
* Displays the minigid in a usable backend fashion. Requires a source
|
5 |
+
* model to properly display;
|
6 |
+
*
|
7 |
+
* @package BlueAcorn\MiniGrid
|
8 |
+
* @version 1.1.0
|
9 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
10 |
+
* @copyright Blue Acorn, Inc. 2014
|
11 |
+
*/
|
12 |
+
class BlueAcorn_MiniGrid_Block_System_Config_Form_Field_Minigrid extends Varien_Data_Form_Element_Abstract {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Add the js block which contains the js that makes
|
16 |
+
* the mini grids work only once to the admin js
|
17 |
+
* block
|
18 |
+
*/
|
19 |
+
protected function _addJsIfNecessary() {
|
20 |
+
$alias = 'ba.mini.grid.js';
|
21 |
+
$block = Mage::app()->getLayout()->createBlock("baminigrid/System_Config_Form_Field_Minigrid_Js", $alias);
|
22 |
+
|
23 |
+
$js = Mage::app()->getLayout()->getBlock('js');
|
24 |
+
if (!$js->getChild($alias)) {
|
25 |
+
Mage::app()->getLayout()->getBlock('js')->append($block, $alias);
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Default values of field array. Field array defines
|
31 |
+
* the fields on the grid.
|
32 |
+
*
|
33 |
+
* @return array
|
34 |
+
*/
|
35 |
+
protected function _getDefaultSourceValues() {
|
36 |
+
return array(
|
37 |
+
"{$this->getLabel()}" => array("width" => "98%", "type" => "text"),
|
38 |
+
);
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Element rendererd html. Called by getDefaultHtml which combines
|
43 |
+
* the label html with this html to render the full element. Specifically,
|
44 |
+
* this is the html to render the field input
|
45 |
+
*
|
46 |
+
* @var $fields Fields is the array of minigrid columns and fields
|
47 |
+
* Fields is represented by $this->getValues()
|
48 |
+
* @var $rowData The row data is an array of values of already existant
|
49 |
+
* grid rows. Row data is represented with $this->getValue();
|
50 |
+
*
|
51 |
+
* NOTE: We are breaking php runtime to fall into html directly
|
52 |
+
* in this function instead of using a template to keep this module
|
53 |
+
* succinct, contained, and to avoid rendering html/js via strings
|
54 |
+
* as is the convention for form and form element renderers.
|
55 |
+
*
|
56 |
+
* Providing optional parameters for required inputs if this block is being
|
57 |
+
* used outside of its normal use case (such as outside of system config)
|
58 |
+
*
|
59 |
+
* @param string $label
|
60 |
+
* @param string $tableId
|
61 |
+
* @param string $fieldName
|
62 |
+
* @param array $fields
|
63 |
+
* @param array $rowData
|
64 |
+
*
|
65 |
+
* @return string
|
66 |
+
*/
|
67 |
+
public function getElementHtml($tableId = null, $fieldName = null, $fields = array(), $rowData = array()) {
|
68 |
+
|
69 |
+
$this->_addJsIfNecessary();
|
70 |
+
|
71 |
+
$label = $this->getLabel();
|
72 |
+
$tableId = ($tableId) ? $tableId : $this->getHtmlId();
|
73 |
+
$fieldName = ($fieldName) ? $fieldName : $this->getName();
|
74 |
+
|
75 |
+
$fields = (empty($fields)) ? $this->getValues() : $fields;
|
76 |
+
if (!$fields) {
|
77 |
+
$fields = $this->_getDefaultSourceValues();
|
78 |
+
}
|
79 |
+
$rowData = (empty($rowData)) ? $this->getValue() : $rowData;
|
80 |
+
if (!is_array($rowData)) {
|
81 |
+
$rowData = array();
|
82 |
+
}
|
83 |
+
ob_start();
|
84 |
+
?>
|
85 |
+
<div class="grid">
|
86 |
+
<table id="ba-<?php echo $tableId?>-table" class="option-header" cellpadding="0" cellspacing="0">
|
87 |
+
<thead>
|
88 |
+
<tr class="headings">
|
89 |
+
<?php foreach($fields as $header => $def) :?>
|
90 |
+
<th style="width:<?php echo $def['width'];?>"><?php echo ucwords(str_replace("_"," ",$header))?></th>
|
91 |
+
<?php endforeach;?>
|
92 |
+
<th style="width:30px">Remove</th>
|
93 |
+
</tr>
|
94 |
+
</thead>
|
95 |
+
<tbody id="ba-<?php echo $tableId?>">
|
96 |
+
</tbody>
|
97 |
+
<tfoot>
|
98 |
+
<tr>
|
99 |
+
<td colspan="<?php echo count($fields) + 1?>" class="a-right">
|
100 |
+
<button id="ba-add-<?php echo $tableId?>" class="scalable add" type="button"><span>Add <?php echo ucwords($label)?></span></button>
|
101 |
+
</td>
|
102 |
+
</tr>
|
103 |
+
</tfoot>
|
104 |
+
</table>
|
105 |
+
</div>
|
106 |
+
|
107 |
+
<script type="text/javascript">
|
108 |
+
Event.observe(window,'load', function(){
|
109 |
+
(new baMiniGrid()).init($("ba-<?php echo $tableId?>"),
|
110 |
+
$('ba-add-<?php echo $tableId?>'),
|
111 |
+
"<?php echo $fieldName?>",
|
112 |
+
<?php echo json_encode($rowData)?>,
|
113 |
+
<?php echo json_encode($fields)?>);
|
114 |
+
});
|
115 |
+
</script>
|
116 |
+
<?php
|
117 |
+
return ob_get_clean();
|
118 |
+
}
|
119 |
+
}
|
app/code/community/BlueAcorn/MiniGrid/Block/System/Config/Form/Field/Minigrid/Js.php
ADDED
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Minigrid form field js
|
4 |
+
* Javascript that controls the forms
|
5 |
+
*
|
6 |
+
* @package BlueAcorn\MiniGrid
|
7 |
+
* @version 1.1.0
|
8 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
9 |
+
* @copyright Blue Acorn, Inc. 2014
|
10 |
+
*/
|
11 |
+
class BlueAcorn_MiniGrid_Block_System_Config_Form_Field_Minigrid_Js extends Mage_Core_Block_Text {
|
12 |
+
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Output the JS that controls the minigrids
|
16 |
+
*
|
17 |
+
* NOTE: We are breaking php runtime to fall into html directly
|
18 |
+
* in this function instead of using a template to keep this module
|
19 |
+
* succinct, contained, and to avoid rendering html/js via strings
|
20 |
+
* as is the convention for form and form element renderers.
|
21 |
+
*
|
22 |
+
* @use (new baMiniGrid()).init(tbody, addRowButton, rowName, collectionData, rowData);
|
23 |
+
* @return string
|
24 |
+
*/
|
25 |
+
protected function _toHtml() {
|
26 |
+
|
27 |
+
$html = parent::_toHtml();
|
28 |
+
$successIcon = $this->getSkinUrl('images/success_msg_icon.gif');
|
29 |
+
ob_start();
|
30 |
+
?>
|
31 |
+
<script type="text/javascript">
|
32 |
+
|
33 |
+
function baMiniGrid() {
|
34 |
+
return {
|
35 |
+
/**
|
36 |
+
* @param tbody Body tag of grid table to insert rows into
|
37 |
+
* @param addRowButton Button that adds rows to grid
|
38 |
+
* @param rowName Unique name to give the grid rows. Used in name attribute
|
39 |
+
* @param collectionData Object that has info on all prexisting grid rows
|
40 |
+
* @param rowData Object containing the schema of the columns in each row
|
41 |
+
*/
|
42 |
+
init : function(tbody, addRowButton, rowName, collectionData, rowData) {
|
43 |
+
this.tbody = tbody;
|
44 |
+
this.addRowButton = addRowButton;
|
45 |
+
this.collectionData = collectionData;
|
46 |
+
this.rowData = rowData;
|
47 |
+
this.rowName = rowName;
|
48 |
+
|
49 |
+
this.initRows();
|
50 |
+
this.observeAddRowButton();
|
51 |
+
},
|
52 |
+
observeAddRowButton : function () {
|
53 |
+
this.addRowButton.observe('click', function(ev){
|
54 |
+
ev.stop();
|
55 |
+
this.addRow();
|
56 |
+
}.bind(this));
|
57 |
+
},
|
58 |
+
getNewRowId : function () {
|
59 |
+
if (typeof this.rowId == "undefined") {
|
60 |
+
this.rowId = 0;
|
61 |
+
}
|
62 |
+
return this.tbody.id+"-row-id-"+this.rowId++;
|
63 |
+
},
|
64 |
+
initRows : function () {
|
65 |
+
if (!this.collectionData.length || this.collectionData.length < 1) {
|
66 |
+
return;
|
67 |
+
}
|
68 |
+
this.collectionData.each(function(rowValues) {
|
69 |
+
var row = this.getNewRow(rowValues);
|
70 |
+
this.addRow(row);
|
71 |
+
}.bind(this));
|
72 |
+
},
|
73 |
+
getNewRow : function (rowValues) {
|
74 |
+
var rowId = this.getNewRowId();
|
75 |
+
var rowName = this.rowName;
|
76 |
+
|
77 |
+
var tr = new Element('tr', {id: rowId});
|
78 |
+
var td, input;
|
79 |
+
for (var field in this.rowData) {
|
80 |
+
td = new Element('td');
|
81 |
+
input = this.getInputTag(field, rowName, rowId);
|
82 |
+
if (rowValues && typeof rowValues[field] != 'undefined') {
|
83 |
+
try {
|
84 |
+
input.value = rowValues[field];
|
85 |
+
delete rowValues[field];
|
86 |
+
}
|
87 |
+
catch (e) {
|
88 |
+
if (input.type == "file") {
|
89 |
+
var fileUploaded = new Element('div', {style:"float:left; width:16px; height:16px; background: url('<?php echo $successIcon ?>') no-repeat 0 0;"});
|
90 |
+
var uploaded = new Element('p', {style:"float:left; margin:0 0 0 5px"}).update("File Uploaded.");
|
91 |
+
Element.insert(td, {bottom: fileUploaded});
|
92 |
+
Element.insert(td, {bottom: uploaded});
|
93 |
+
td.setAttribute("title", "File: " + rowValues[field]);
|
94 |
+
}
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
Element.insert(td, {bottom: input});
|
99 |
+
Element.insert(tr, {bottom: td});
|
100 |
+
}
|
101 |
+
|
102 |
+
if (rowValues && typeof rowValues != 'undefined') {
|
103 |
+
for (var field in rowValues) {
|
104 |
+
Element.insert(tr, {top: new Element('input', {name:this.rowName + "["+rowId+"]["+field+"]", type:"hidden", value:rowValues[field]})})
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
var button = new Element('button', {type: 'button', style: 'width:50px;', title: 'Delete'}).update("<span>Delete</span>");
|
109 |
+
button.className = "scalable delete icon-btn";
|
110 |
+
button.observe('click', function(ev) {
|
111 |
+
ev.stop();
|
112 |
+
this.removeRow(rowId);
|
113 |
+
}.bind(this));
|
114 |
+
|
115 |
+
var buttonTd = new Element('td');
|
116 |
+
Element.insert(buttonTd, {bottom: button});
|
117 |
+
Element.insert(tr, {bottom: buttonTd});
|
118 |
+
return tr;
|
119 |
+
},
|
120 |
+
getInputTag : function (field, rowName, rowId) {
|
121 |
+
var input;
|
122 |
+
if (this.rowData[field]['type'] == 'textarea' || this.rowData[field]['type'] == "select") {
|
123 |
+
input = new Element(this.rowData[field]['type'], {style:"width:98%;",name: rowName + "["+rowId+"][" +field + "]"});
|
124 |
+
input.addClassName("minigrid-field");
|
125 |
+
input.addClassName("minigrid-field-" + field);
|
126 |
+
if (typeof this.rowData[field]['options'] != 'undefined') {
|
127 |
+
var options = this.rowData[field]['options'];
|
128 |
+
if (Object.isArray(options)) {
|
129 |
+
options.each(function(value,opt){
|
130 |
+
var option = new Element('option', {value: opt}).update(value);
|
131 |
+
Element.insert(input, {bottom: option});
|
132 |
+
}.bind(this));
|
133 |
+
}
|
134 |
+
else {
|
135 |
+
for (var opt in options) {
|
136 |
+
var option = new Element('option', {value: opt}).update(options[opt]);
|
137 |
+
Element.insert(input, {bottom: option});
|
138 |
+
}
|
139 |
+
}
|
140 |
+
}
|
141 |
+
input.observe('focus', function(ev) {
|
142 |
+
|
143 |
+
var fields = document.getElementsByClassName("minigrid-field-" + field);
|
144 |
+
|
145 |
+
// Disable any options already selected in corresponding select boxes
|
146 |
+
for (var i=0; i < fields.length; i++) {
|
147 |
+
if(fields[i].getAttribute('name') != input.getAttribute('name')) {
|
148 |
+
if (fields[i].selectedIndex != '') {
|
149 |
+
input.options[fields[i].selectedIndex].disabled = true;
|
150 |
+
} else {
|
151 |
+
input.options[fields[i].selectedIndex].disabled = false;
|
152 |
+
}
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}.bind(this));
|
156 |
+
}
|
157 |
+
else {
|
158 |
+
input = new Element('input', {style:"width:" + this.rowData[field]['width'],type: this.rowData[field]['type'], name: rowName + "["+rowId+"][" +field + "]"});
|
159 |
+
input.addClassName("minigrid-field");
|
160 |
+
input.addClassName("minigrid-field-" + field);
|
161 |
+
}
|
162 |
+
return input;
|
163 |
+
},
|
164 |
+
addRow : function (row) {
|
165 |
+
row = row || this.getNewRow();
|
166 |
+
if (typeof this.allRemoved != 'undefined' && this.allRemoved) {
|
167 |
+
this.allRemoved.remove();
|
168 |
+
delete this.allRemoved;
|
169 |
+
}
|
170 |
+
Element.insert(this.tbody, {bottom: row});
|
171 |
+
},
|
172 |
+
removeRow : function (rowId) {
|
173 |
+
var row = $(rowId);
|
174 |
+
if (typeof row != "undefined" && row) {
|
175 |
+
row.remove();
|
176 |
+
if (this.tbody.children.length == 0 ) {
|
177 |
+
this.allRemoved = new Element('input', {type:'hidden', name: this.rowName, value:''});
|
178 |
+
Element.insert(this.tbody, {bottom: this.allRemoved});
|
179 |
+
}
|
180 |
+
}
|
181 |
+
return 1;
|
182 |
+
}
|
183 |
+
}
|
184 |
+
}
|
185 |
+
</script>
|
186 |
+
<?php
|
187 |
+
return $html . ob_get_clean();
|
188 |
+
}
|
189 |
+
}
|
app/code/community/BlueAcorn/MiniGrid/Block/Widget/Minigrid/Form.php
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Form that utilizes a minigrid. Good as an alternative
|
4 |
+
* to a grid
|
5 |
+
*
|
6 |
+
* @package BlueAcorn\MiniGrid
|
7 |
+
* @version 1.1.0
|
8 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
9 |
+
* @copyright Blue Acorn, Inc. 2014
|
10 |
+
*/
|
11 |
+
class BlueAcorn_Minigrid_Block_Widget_Minigrid_Form extends Mage_Adminhtml_Block_Abstract {
|
12 |
+
|
13 |
+
protected $_formId = "ba-minigrid-form";
|
14 |
+
protected $_formClass = "";
|
15 |
+
protected $_formAction = "";
|
16 |
+
protected $_gridFields = array();
|
17 |
+
protected $_gridRowData = array();
|
18 |
+
|
19 |
+
/**
|
20 |
+
* It was decided to use the overwritable _toHtml instead of a template
|
21 |
+
* to be consistent with magento renderers and to increase portability
|
22 |
+
*
|
23 |
+
* @return string
|
24 |
+
*/
|
25 |
+
protected function _toHtml() {
|
26 |
+
$html = parent::_toHtml();
|
27 |
+
$html .= "<form id='{$this->getFormId()}' action='{$this->getFormAction()}' method='post' class='{$this->getFormClass()}' enctype='multipart/form-data'>";
|
28 |
+
$minigrid = new BlueAcorn_MiniGrid_Block_System_Config_Form_Field_Minigrid();
|
29 |
+
$html .= $minigrid->getElementHtml("ba-minigrid-form-grid", $this->getFieldName(), $this->getGridFields(), $this->getGridRowData());
|
30 |
+
$html .= "
|
31 |
+
</form>
|
32 |
+
<script type='text/javascript'>
|
33 |
+
function submitMinigridForm() {
|
34 |
+
$('{$this->getFormId()}').submit();
|
35 |
+
}
|
36 |
+
</script>
|
37 |
+
|
38 |
+
";
|
39 |
+
return $html;
|
40 |
+
}
|
41 |
+
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Public return for form id
|
45 |
+
*
|
46 |
+
* @return string
|
47 |
+
*/
|
48 |
+
public function getFormId() {
|
49 |
+
return $this->_formId;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Public set for form id
|
54 |
+
*
|
55 |
+
* @param string $formId
|
56 |
+
* @return Blueacorn_Minigrid_Block_Widget_Minigrid_Form
|
57 |
+
*/
|
58 |
+
public function setFormId($formId) {
|
59 |
+
$this->_formId = $formId;
|
60 |
+
return $this;
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Public return for form class
|
65 |
+
*
|
66 |
+
* @return string
|
67 |
+
*/
|
68 |
+
public function getFormClass() {
|
69 |
+
return $this->_formClass;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Public set for form class
|
74 |
+
*
|
75 |
+
* @param string $formClass
|
76 |
+
* @return Blueacorn_Minigrid_Block_Widget_Minigrid_Form
|
77 |
+
*/
|
78 |
+
public function setFormClass($formClass) {
|
79 |
+
$this->_formClass = $formClass;
|
80 |
+
return $this;
|
81 |
+
}
|
82 |
+
/**
|
83 |
+
* Public return for form class
|
84 |
+
*
|
85 |
+
* @return string
|
86 |
+
*/
|
87 |
+
public function getFormAction() {
|
88 |
+
return $this->_formAction;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Public set for form class
|
93 |
+
*
|
94 |
+
* @param string $url
|
95 |
+
* @return Blueacorn_Minigrid_Block_Widget_Minigrid_Form
|
96 |
+
*/
|
97 |
+
public function setFormAction($url) {
|
98 |
+
$this->_formAction = $url;
|
99 |
+
return $this;
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Public return for grid fields
|
104 |
+
*
|
105 |
+
* @return string
|
106 |
+
*/
|
107 |
+
public function getGridFields() {
|
108 |
+
return $this->_gridFields;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Public set for grid fields
|
113 |
+
*
|
114 |
+
* @param array $gridFields
|
115 |
+
* @return Blueacorn_Minigrid_Block_Widget_Minigrid_Form
|
116 |
+
*/
|
117 |
+
public function setGridFields(array $gridFields) {
|
118 |
+
$this->_gridFields = $gridFields;
|
119 |
+
return $this;
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Public return for grid row data
|
124 |
+
*
|
125 |
+
* @return string
|
126 |
+
*/
|
127 |
+
public function getGridRowData() {
|
128 |
+
return $this->_gridRowData;
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Public set for grid row data
|
133 |
+
*
|
134 |
+
* @param array $gridRowData
|
135 |
+
* @return Blueacorn_Minigrid_Block_Widget_Minigrid_Form
|
136 |
+
*/
|
137 |
+
public function setGridRowData(array $gridRowData) {
|
138 |
+
$this->_gridRowData = $gridRowData;
|
139 |
+
return $this;
|
140 |
+
}
|
141 |
+
|
142 |
+
}
|
app/code/community/BlueAcorn/MiniGrid/Model/System/Config/Backend/Minigrid.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Minigrid backend model
|
4 |
+
* Serializes and unserializes the grid data to
|
5 |
+
* the config data
|
6 |
+
*
|
7 |
+
* @package BlueAcorn\MiniGrid
|
8 |
+
* @version 1.1.0
|
9 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
10 |
+
* @copyright Blue Acorn, Inc. 2014
|
11 |
+
*/
|
12 |
+
class BlueAcorn_MiniGrid_Model_System_Config_Backend_Minigrid extends Mage_Core_Model_Config_Data {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* In the event of a minigrid with file, get the local tmp location of the
|
16 |
+
* image file that was uploaded by the font minigrid
|
17 |
+
*
|
18 |
+
* @return string|false
|
19 |
+
*/
|
20 |
+
protected function _getTmpFileNames() {
|
21 |
+
if (isset($_FILES['groups']['tmp_name']) && is_array($_FILES['groups']['tmp_name'])) {
|
22 |
+
if (isset($_FILES['groups']['tmp_name']["{$this->getGroupId()}"])) {
|
23 |
+
$field = $_FILES['groups']['tmp_name']["{$this->getGroupId()}"]['fields'][$this->getField()];
|
24 |
+
if (isset($field['value'])) {
|
25 |
+
return $field['value'];
|
26 |
+
}
|
27 |
+
}
|
28 |
+
}
|
29 |
+
return false;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* In the event that a file was uploaded,
|
34 |
+
* this array will contain the filenames as they appear
|
35 |
+
* on the uploaded file.
|
36 |
+
*
|
37 |
+
* @return array
|
38 |
+
*/
|
39 |
+
protected function _getFileNames() {
|
40 |
+
$groups = $this->getData('groups');
|
41 |
+
$values = $groups["{$this->getGroupId()}"]['fields'][$this->getField()]['value'];
|
42 |
+
|
43 |
+
return $values;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Serialize
|
48 |
+
*/
|
49 |
+
protected function _beforeSave() {
|
50 |
+
parent::_beforeSave();
|
51 |
+
$groups = $this->getData('groups');
|
52 |
+
$values = $groups["{$this->getGroupId()}"]['fields'][$this->getField()]['value'];
|
53 |
+
|
54 |
+
if (is_array($values)) {
|
55 |
+
$this->setValue(serialize(array_values($values)));
|
56 |
+
}
|
57 |
+
else {
|
58 |
+
$this->setValue(serialize($values));
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Unserialize
|
64 |
+
*/
|
65 |
+
protected function _afterLoad() {
|
66 |
+
parent::_afterLoad();
|
67 |
+
$this->setValue(unserialize($this->getValue()));
|
68 |
+
}
|
69 |
+
|
70 |
+
}
|
app/code/community/BlueAcorn/MiniGrid/Model/System/Config/Source/Minigrid/Abstract.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Minigrid system config field type source model abstract
|
4 |
+
* Provides base functionality for minigrid source models
|
5 |
+
* as the toOptionArray is specialized to the minigrid type
|
6 |
+
*
|
7 |
+
* @package BlueAcorn\MiniGrid
|
8 |
+
* @version 1.1.0
|
9 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
10 |
+
* @copyright Blue Acorn, Inc. 2014
|
11 |
+
*/
|
12 |
+
abstract class BlueAcorn_MiniGrid_Model_System_Config_Source_Minigrid_Abstract {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Default values of field array. Field array defines
|
16 |
+
* the fields on the grid.
|
17 |
+
*
|
18 |
+
* @return array
|
19 |
+
*/
|
20 |
+
abstract protected function _getFields();
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Add the additional grid type as a viable type on the form
|
24 |
+
*
|
25 |
+
* Note: Have to add value and label to each field array because
|
26 |
+
* the frontend renderer requires value and label to be set
|
27 |
+
* when under score scope.
|
28 |
+
*
|
29 |
+
* @return array
|
30 |
+
*/
|
31 |
+
public function toOptionArray() {
|
32 |
+
$fields = $this->_getFields();
|
33 |
+
foreach($fields as $key => $field) {
|
34 |
+
$fields[$key]['value'] = 1;
|
35 |
+
$fields[$key]['label'] = 1;
|
36 |
+
}
|
37 |
+
|
38 |
+
return $fields;
|
39 |
+
}
|
40 |
+
|
41 |
+
}
|
app/code/community/BlueAcorn/MiniGrid/etc/config.xml
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* The MiniGrid is that grid that you see around magento like
|
5 |
+
* in the tier prices area of the catalog product edit admin
|
6 |
+
* page. This module makes this grid a system config frontend
|
7 |
+
* type that can be used for a wide variety of things that require
|
8 |
+
* a bit more love than a multiselect.
|
9 |
+
*
|
10 |
+
* @package BlueAcorn\MiniGrid
|
11 |
+
* @version 1.1.0
|
12 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
13 |
+
* @copyright Blue Acorn, Inc. 2014
|
14 |
+
*/
|
15 |
+
-->
|
16 |
+
<config>
|
17 |
+
<modules>
|
18 |
+
<BlueAcorn_MiniGrid>
|
19 |
+
<version>1.0.0</version>
|
20 |
+
</BlueAcorn_MiniGrid>
|
21 |
+
</modules>
|
22 |
+
<global>
|
23 |
+
<blocks>
|
24 |
+
<baminigrid>
|
25 |
+
<class>BlueAcorn_MiniGrid_Block</class>
|
26 |
+
</baminigrid>
|
27 |
+
<adminhtml>
|
28 |
+
<rewrite>
|
29 |
+
<system_config_form>BlueAcorn_MiniGrid_Block_System_Config_Form</system_config_form>
|
30 |
+
</rewrite>
|
31 |
+
</adminhtml>
|
32 |
+
</blocks>
|
33 |
+
<helpers>
|
34 |
+
<baminigrid>
|
35 |
+
<class>BlueAcorn_MiniGrid_Helper</class>
|
36 |
+
</baminigrid>
|
37 |
+
</helpers>
|
38 |
+
<models>
|
39 |
+
<baminigrid>
|
40 |
+
<class>BlueAcorn_MiniGrid_Model</class>
|
41 |
+
</baminigrid>
|
42 |
+
</models>
|
43 |
+
</global>
|
44 |
+
</config>
|
app/code/community/BlueAcorn/Optimizely/Block/CustomVariables.php
CHANGED
@@ -1,29 +1,14 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
-
* @
|
5 |
-
* @
|
6 |
-
* @
|
7 |
*/
|
8 |
-
class BlueAcorn_Optimizely_Block_CustomVariables extends
|
9 |
{
|
10 |
|
11 |
-
const NEW_LINE = "\n";
|
12 |
-
const TABBED_SPACE = "\t";
|
13 |
-
|
14 |
-
protected $_helper = null;
|
15 |
-
protected $_product = null;
|
16 |
-
protected $_customAttrName = null;
|
17 |
-
protected $_category = null;
|
18 |
-
protected $_cms = null;
|
19 |
-
protected $_checkout = null;
|
20 |
-
protected $_homepage = null;
|
21 |
-
protected $_success = null;
|
22 |
-
protected $_search = null;
|
23 |
-
protected $_cart = null;
|
24 |
-
protected $_customer = null;
|
25 |
protected $_pageType = null;
|
26 |
-
protected $_numAttr = array('cost', 'weight', 'inventory');
|
27 |
|
28 |
/**
|
29 |
* Get module helper
|
@@ -32,7 +17,7 @@ class BlueAcorn_Optimizely_Block_CustomVariables extends Mage_Core_Block_Templat
|
|
32 |
*/
|
33 |
protected function _helper()
|
34 |
{
|
35 |
-
return
|
36 |
}
|
37 |
|
38 |
/**
|
@@ -42,7 +27,7 @@ class BlueAcorn_Optimizely_Block_CustomVariables extends Mage_Core_Block_Templat
|
|
42 |
*/
|
43 |
protected function _getProduct()
|
44 |
{
|
45 |
-
return
|
46 |
}
|
47 |
|
48 |
/**
|
@@ -52,429 +37,215 @@ class BlueAcorn_Optimizely_Block_CustomVariables extends Mage_Core_Block_Templat
|
|
52 |
*/
|
53 |
protected function _getCategory()
|
54 |
{
|
55 |
-
return
|
56 |
}
|
57 |
|
58 |
-
/**
|
59 |
-
* Check if current page is CMS
|
60 |
-
*
|
61 |
-
* @return bool
|
62 |
-
*/
|
63 |
-
protected function _isCms()
|
64 |
-
{
|
65 |
-
return $this->_cms = $this->getRequest()->getRequestedRouteName() == 'cms';
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Check if current page is Search
|
70 |
-
*
|
71 |
-
* @return bool
|
72 |
-
*/
|
73 |
|
74 |
-
protected function
|
75 |
-
{
|
76 |
-
return $this->_search = $this->getRequest()->getRequestedRouteName() == 'catalogsearch';
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Check if current page is Checkout
|
81 |
-
*
|
82 |
-
* @return bool
|
83 |
-
*/
|
84 |
-
|
85 |
-
protected function _isCheckout()
|
86 |
-
{
|
87 |
-
if ($this->getRequest()->getRequestedRouteName() == 'checkout' || $this->getRequest()->getRequestedRouteName() == 'onestepcheckout'){
|
88 |
-
return $this->_checkout = true;
|
89 |
-
} else {
|
90 |
-
return $this->_checkout = false;
|
91 |
-
}
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Check if current page is Homepage
|
96 |
-
*
|
97 |
-
* @return bool
|
98 |
-
*/
|
99 |
-
protected function _isHomepage()
|
100 |
-
{
|
101 |
-
if ($this->_isCms()) {
|
102 |
-
return $this->_homepage = $this->getRequest()->getRequestUri() == '/';
|
103 |
-
} else {
|
104 |
-
return null;
|
105 |
-
}
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Check if current page is Cart Page
|
110 |
-
*
|
111 |
-
* @return bool
|
112 |
-
*/
|
113 |
-
protected function _isCart()
|
114 |
-
{
|
115 |
-
if ($this->_isCheckout()) {
|
116 |
-
return $this->_cart = $this->getRequest()->getControllerName() == 'cart';
|
117 |
-
} else {
|
118 |
-
return null;
|
119 |
-
}
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Check if current page is Success Page
|
124 |
-
*
|
125 |
-
* @return bool
|
126 |
-
*/
|
127 |
-
protected function _isSuccessPage()
|
128 |
-
{
|
129 |
-
if ($this->_isCheckout()) {
|
130 |
-
return $this->_cart = $this->getRequest()->getActionName() == 'success';
|
131 |
-
} else {
|
132 |
-
return null;
|
133 |
-
}
|
134 |
-
}
|
135 |
-
|
136 |
-
/**
|
137 |
-
* Check if current page is Customer Page
|
138 |
-
*
|
139 |
-
* @return bool
|
140 |
-
*/
|
141 |
-
protected function _isCustomerPage()
|
142 |
{
|
|
|
|
|
143 |
|
144 |
-
return $this->_customer = $this->getRequest()->getRequestedRouteName() == 'customer';
|
145 |
-
}
|
146 |
|
|
|
|
|
|
|
147 |
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
if ($this->_helper()->isEnabled() == 1) {
|
152 |
-
$product = $this->_getProduct();
|
153 |
-
if ($product) {
|
154 |
-
$productSku = $this->_editString($product->getSku());
|
155 |
-
$productName = $this->_editString($product->getName());
|
156 |
-
$productType = $this->_editString($product->getTypeId());
|
157 |
-
$attributeSetModel = Mage::getModel("eav/entity_attribute_set");
|
158 |
-
$attributeSetModel->load($product->getAttributeSetId());
|
159 |
-
$productPrice = round($product->getMinimalPrice(), 2);
|
160 |
-
if ($productPrice == 0){
|
161 |
-
$productPrice = round($product->getPrice(),2);
|
162 |
-
}
|
163 |
-
if ($productType == "grouped") {
|
164 |
-
$aProductIds = $product->getTypeInstance()->getChildrenIds($product->getId());
|
165 |
-
$prices = array();
|
166 |
-
foreach ($aProductIds as $ids) {
|
167 |
-
foreach ($ids as $id) {
|
168 |
-
$aProduct = Mage::getSingleton('catalog/product')->load($id);
|
169 |
-
array_push($prices, $aProduct->getData('minimal_price'));
|
170 |
-
}
|
171 |
-
}
|
172 |
-
sort($prices, SORT_NUMERIC);
|
173 |
-
$productPrice = round($prices[0], 2);
|
174 |
-
} elseif ($productType == "bundle") {
|
175 |
-
$priceModel = $product->getPriceModel();
|
176 |
-
$productPrice = $priceModel->getTotalPrices($product, null, null, false);
|
177 |
-
$productPrice = $productPrice[0];
|
178 |
-
}
|
179 |
-
$this->_editString($productPrice);
|
180 |
|
181 |
-
|
182 |
-
$category = null;
|
183 |
-
if ($this->_product->getCategory()) {
|
184 |
-
$category = strtolower($this->_product->getCategory()->getName());
|
185 |
-
$productVariables .= "window['optimizely'].push(['customTag', 'category', '$category' ]);" . self::NEW_LINE;
|
186 |
-
}
|
187 |
|
188 |
-
|
189 |
-
$
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
//Get the value from the custom attributes defined if they exist for current
|
195 |
-
//product
|
196 |
-
$customAttrOne = $this->_helper()->getCustomAttrOne();
|
197 |
-
$customAttrTwo = $this->_helper()->getCustomAttrTwo();
|
198 |
-
$customAttrThree = $this->_helper()->getCustomAttrThree();
|
199 |
-
$customAttrFour = $this->_helper()->getCustomAttrFour();
|
200 |
-
|
201 |
-
$attrOneOptionId = $product->getData($customAttrOne);
|
202 |
-
$attrTwoOptionId = $product->getData($customAttrTwo);
|
203 |
-
$attrThreeOptionId = $product->getData($customAttrThree);
|
204 |
-
$attrFourOptionId = $product->getData($customAttrFour);
|
205 |
-
|
206 |
-
if ($attrOneOptionId) {
|
207 |
-
if (in_array($customAttrOne, $this->_numAttr)) {
|
208 |
-
if ($attrOneOptionId != 0) {
|
209 |
-
$productVariables .= "window['optimizely'].push(['customTag', '$customAttrOne', '".$this->_calcNumberAttr($customAttrOne)."' ]);" . self::NEW_LINE;
|
210 |
-
}
|
211 |
-
} else {
|
212 |
-
$productVariables .= "window['optimizely'].push(['customTag', '$customAttrOne', '". $this->_editString($this->_getCustomAttributeValue($customAttrOne))."' ]);" . self::NEW_LINE;
|
213 |
-
}
|
214 |
-
}
|
215 |
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
$productVariables .= "window['optimizely'].push(['customTag', '$customAttrTwo', '".$this->_calcNumberAttr($customAttrTwo)."' ]);" . self::NEW_LINE;
|
220 |
-
}
|
221 |
-
} else {
|
222 |
-
$productVariables .= "window['optimizely'].push(['customTag', '$customAttrTwo', '". $this->_editString($this->_getCustomAttributeValue($customAttrTwo))."' ]);" . self::NEW_LINE;
|
223 |
-
}
|
224 |
}
|
225 |
|
226 |
-
|
227 |
-
|
228 |
-
if ($attrThreeOptionId != 0) {
|
229 |
-
$productVariables .= "window['optimizely'].push(['customTag', '$customAttrThree', '".$this->_calcNumberAttr($customAttrThree)."' ]);" . self::NEW_LINE;
|
230 |
-
}
|
231 |
-
} else {
|
232 |
-
$productVariables .= "window['optimizely'].push(['customTag', '$customAttrThree', '". $this->_editString($this->_getCustomAttributeValue($customAttrThree))."' ]);" . self::NEW_LINE;
|
233 |
-
}
|
234 |
-
}
|
235 |
|
236 |
-
if ($
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
}
|
241 |
-
} else {
|
242 |
-
$productVariables .= "window['optimizely'].push(['customTag', '$customAttrFour', '". $this->_editString($this->_getCustomAttributeValue($customAttrFour))."' ]);" . self::NEW_LINE;
|
243 |
-
}
|
244 |
}
|
245 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
}
|
247 |
}
|
248 |
return $productVariables;
|
249 |
}
|
250 |
|
251 |
/**
|
252 |
-
*
|
253 |
*
|
254 |
-
* @param
|
255 |
* @return string
|
256 |
*/
|
257 |
-
protected function
|
258 |
{
|
259 |
-
|
260 |
-
|
261 |
-
if ($numberAttr && $numberAttr == 'news_from_date') {
|
262 |
-
$numberAttr = null;
|
263 |
-
$newFromDate = $product->getData('created_at');
|
264 |
-
$newFromDate = str_replace("-", "", substr($newFromDate, 0, strpos($newFromDate, " ")));
|
265 |
-
$today = date('Ymd');
|
266 |
-
if (is_numeric($newFromDate)) {
|
267 |
-
$numberAttr = $this->_editString(($today - $newFromDate));
|
268 |
-
}
|
269 |
-
}
|
270 |
-
//If Cost is the attribute chosen
|
271 |
-
if ($numberAttr && $numberAttr == 'cost') {
|
272 |
-
$numberAttr = null;
|
273 |
-
$cost = round($product->getData('cost'), 2);
|
274 |
-
if (is_numeric($cost)) {
|
275 |
-
$numberAttr = $this->_editString($cost);
|
276 |
-
}
|
277 |
-
}
|
278 |
-
//If Stock Remaining is the Attribute chosen
|
279 |
-
if ($numberAttr && $numberAttr == 'inventory') {
|
280 |
-
$numberAttr = null;
|
281 |
-
$qty = round(Mage::getSingleton('cataloginventory/stock_item')->loadByProduct($product)->getQty(), 0);
|
282 |
-
if (is_numeric($qty)) {
|
283 |
-
$numberAttr = $this->_editString($qty);
|
284 |
-
}
|
285 |
}
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
return $numberAttr;
|
295 |
}
|
296 |
|
297 |
/**
|
298 |
-
*
|
299 |
-
* if that are stored as int values
|
300 |
*
|
301 |
-
* @param $
|
302 |
* @return string
|
303 |
*/
|
304 |
-
protected function
|
305 |
{
|
306 |
$product = $this->_getProduct();
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
316 |
}
|
|
|
317 |
}
|
318 |
|
319 |
/**
|
320 |
-
*
|
321 |
-
* if the string is more than 50 characters. Also gets rid of characters that
|
322 |
-
* may cause JS errors like ", ', and ;
|
323 |
*
|
324 |
-
* @param $string
|
325 |
* @return string
|
326 |
*/
|
327 |
-
protected function
|
328 |
{
|
329 |
-
if (
|
330 |
-
|
331 |
-
} else {
|
332 |
-
$newString = $string;
|
333 |
}
|
334 |
|
335 |
-
$
|
336 |
-
|
337 |
-
|
338 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
340 |
}
|
341 |
-
return $newString;
|
342 |
-
}
|
343 |
|
344 |
-
|
345 |
-
* Gets the frontend name of the custom attribute code being used
|
346 |
-
*
|
347 |
-
* @param string|integer|Mage_Core_Model_Config_Element $customAttr
|
348 |
-
* @return mixed
|
349 |
-
*/
|
350 |
-
protected function _customAttrName($customAttr)
|
351 |
-
{
|
352 |
-
return $this->_customAttrName = $this->_getProduct()->getResource()->getAttribute($customAttr)->getStoreLabel();
|
353 |
}
|
354 |
|
355 |
/**
|
356 |
-
*
|
357 |
-
* immediate parent if one exists.
|
358 |
*
|
359 |
* @return string
|
360 |
*/
|
361 |
-
protected function
|
362 |
{
|
363 |
-
|
364 |
-
$categoryVariables = "";
|
365 |
-
if ($this->_helper()->isEnabled() == 1) {
|
366 |
-
if ($category && !$this->_getProduct()) {
|
367 |
-
$categoryName = $category->getName();
|
368 |
-
$categoryId = $category->getId();
|
369 |
-
|
370 |
-
//Retrieve Stores where isset category Path, returns comma separated list
|
371 |
-
$pathInStore = $category->getPathInStore();
|
372 |
-
//Reverse the list so the current category is at the bottom
|
373 |
-
$pathIds = array_reverse(explode(',', $pathInStore));
|
374 |
-
|
375 |
-
$categories = $category->getParentCategories();
|
376 |
-
$categoryTree = array();
|
377 |
-
foreach ($pathIds as $categoryId) {
|
378 |
-
//Push all category names into $categoryTree array
|
379 |
-
if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
|
380 |
-
array_push($categoryTree, $categories[$categoryId]->getName());
|
381 |
-
}
|
382 |
-
}
|
383 |
-
//See if there are any parent categories by seeing how many keys are stored
|
384 |
-
//in the $categoryTree array
|
385 |
-
$categoryTreeCount = count(array_keys($categoryTree));
|
386 |
-
//If the $categoryTree array does have more than 1 key, then pass the value
|
387 |
-
//of the second to last key into $parentCategory
|
388 |
-
if ($categoryTreeCount > 1) {
|
389 |
-
end($categoryTree);
|
390 |
-
}
|
391 |
-
|
392 |
-
$categoryVariables['name'] = strtolower($categoryName);
|
393 |
-
$categoryVariables['id'] = $categoryId;
|
394 |
-
}
|
395 |
-
}
|
396 |
-
return $categoryVariables;
|
397 |
-
}
|
398 |
-
|
399 |
-
protected function _getCustomVariables($html = null)
|
400 |
-
{
|
401 |
-
|
402 |
-
$this->_getPageType();
|
403 |
-
$pageType = $this->_editString($this->_pageType);
|
404 |
-
$html = "<script>".self::NEW_LINE;
|
405 |
-
$html .= "window['optimizely'] = window['optimizely'] || [];" . self::NEW_LINE;
|
406 |
-
// $html .= "var optimizely_custom = {" . self::NEW_LINE . self::TABBED_SPACE;
|
407 |
-
$html .= "window['optimizely'].push(['customTag', 'page_type', '$pageType' ]);" . self::NEW_LINE;
|
408 |
-
//return custom targeting parameters here based on module config
|
409 |
-
|
410 |
-
//if category
|
411 |
-
if ($this->_category) {
|
412 |
-
$categoryVars = $this->_getCategoryVariables();
|
413 |
-
$catName = $this->_editString($categoryVars['name']);
|
414 |
-
$html .= "window['optimizely'].push(['customTag', 'category', '$catName' ]);" . self::NEW_LINE;
|
415 |
-
}
|
416 |
-
//if product
|
417 |
-
if ($this->_product) {
|
418 |
-
$html .= $this->_getProductVariables();
|
419 |
-
}
|
420 |
|
|
|
421 |
|
|
|
|
|
422 |
|
|
|
|
|
|
|
423 |
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
$html .= sprintf("window['optimizely'].push(['trackEvent', 'success_page', %s]);%s", $revenueInCents, self::NEW_LINE);
|
430 |
-
}
|
431 |
-
$html .= "</script>" . self::NEW_LINE;
|
432 |
|
433 |
-
|
434 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
435 |
|
436 |
-
|
437 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
438 |
|
439 |
-
|
440 |
-
if ($this->_getProduct()) {
|
441 |
-
$this->_pageType = 'product';
|
442 |
-
return true;
|
443 |
-
} //if category page
|
444 |
-
elseif ($this->_getCategory()) {
|
445 |
-
$this->_pageType = 'category';
|
446 |
-
return true;
|
447 |
-
} //if home page
|
448 |
-
elseif ($this->_isHomepage()) {
|
449 |
-
$this->_pageType = 'homepage';
|
450 |
-
return true;
|
451 |
-
} //if cms page
|
452 |
-
elseif ($this->_isCMS()) {
|
453 |
-
$this->_pageType = 'cms';
|
454 |
-
return true;
|
455 |
-
} //if checkout page
|
456 |
-
elseif ($this->_isCart()) {
|
457 |
-
$this->_pageType = 'cart';
|
458 |
-
return true;
|
459 |
-
} //if checkout page
|
460 |
-
elseif ($this->_isSuccessPage()) {
|
461 |
-
$this->_pageType = 'success';
|
462 |
-
$this->_success = true;
|
463 |
-
return true;
|
464 |
-
} //if checkout page
|
465 |
-
elseif ($this->_isCheckout()) {
|
466 |
-
$this->_pageType = 'checkout';
|
467 |
-
return true;
|
468 |
-
} //if checkout page
|
469 |
-
elseif ($this->_isCustomerPage()) {
|
470 |
-
$this->_pageType = 'customer';
|
471 |
-
return true;
|
472 |
-
} elseif ($this->_isSearch()) {
|
473 |
-
$this->_pageType = 'search';
|
474 |
-
return true;
|
475 |
-
} else {
|
476 |
-
return false;
|
477 |
}
|
478 |
}
|
479 |
-
|
480 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package BlueAcorn\Optimizely
|
4 |
+
* @version 1.1.0
|
5 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
6 |
+
* @copyright Blue Acorn, Inc. 2014
|
7 |
*/
|
8 |
+
class BlueAcorn_Optimizely_Block_CustomVariables extends Mage_Core_Block_Abstract
|
9 |
{
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
protected $_pageType = null;
|
|
|
12 |
|
13 |
/**
|
14 |
* Get module helper
|
17 |
*/
|
18 |
protected function _helper()
|
19 |
{
|
20 |
+
return Mage::helper('blueacorn_optimizely');
|
21 |
}
|
22 |
|
23 |
/**
|
27 |
*/
|
28 |
protected function _getProduct()
|
29 |
{
|
30 |
+
return Mage::registry('current_product');
|
31 |
}
|
32 |
|
33 |
/**
|
37 |
*/
|
38 |
protected function _getCategory()
|
39 |
{
|
40 |
+
return Mage::registry('current_category');
|
41 |
}
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
+
protected function _getProductVariables()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
{
|
46 |
+
$product = $this->_getProduct();
|
47 |
+
if ($product) {
|
48 |
|
|
|
|
|
49 |
|
50 |
+
//calcuate price
|
51 |
+
$productType = $this->_clean($product->getTypeId());
|
52 |
+
$productPrice = round($product->getMinimalPrice(), 2);
|
53 |
|
54 |
+
if ($productPrice == 0) {
|
55 |
+
$productPrice = round($product->getPrice(), 2);
|
56 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
+
if ($productType == "grouped") {
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
+
$aProductIds = $product->getTypeInstance()->getChildrenIds($product->getId());
|
61 |
+
$collection = Mage::getModel('catalog/product')
|
62 |
+
->getCollection()
|
63 |
+
->addAttributeToFilter('entity_id', array('in' => $aProductIds))
|
64 |
+
->addMinimalPrice();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
+
$productPrice = 0;
|
67 |
+
foreach ($collection as $aProduct) {
|
68 |
+
$productPrice += $aProduct->getMinimalPrice();
|
|
|
|
|
|
|
|
|
|
|
69 |
}
|
70 |
|
71 |
+
} elseif ($productType == "bundle") {
|
72 |
+
$priceModel = $product->getPriceModel();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
+
if (method_exists($priceModel, 'getTotalPrices')) {
|
75 |
+
$productPrice = $priceModel->getTotalPrices($product, null, null, false);
|
76 |
+
} else { //getPrices() deprecated in 1.5.1.0
|
77 |
+
$productPrice = $priceModel->getPrices($product, null);
|
|
|
|
|
|
|
|
|
78 |
}
|
79 |
|
80 |
+
$productPrice = $productPrice[0];
|
81 |
+
}
|
82 |
+
//build custom tag array
|
83 |
+
$productVariables = array(
|
84 |
+
'product_type' => $productType,
|
85 |
+
'product_sku' => $product->getSku(),
|
86 |
+
'product_name' => $product->getName(),
|
87 |
+
'product_price' => $productPrice,
|
88 |
+
);
|
89 |
+
|
90 |
+
$customAttributes = $this->_helper()->getCustomAttributes();
|
91 |
+
foreach ($customAttributes as $attr) {
|
92 |
+
$productVariables[$attr] = $this->_getAttrValue($attr);
|
93 |
}
|
94 |
}
|
95 |
return $productVariables;
|
96 |
}
|
97 |
|
98 |
/**
|
99 |
+
* Cleans and truncates the value
|
100 |
*
|
101 |
+
* @param mixed $val
|
102 |
* @return string
|
103 |
*/
|
104 |
+
protected function _clean($val)
|
105 |
{
|
106 |
+
if (is_numeric($val)) {
|
107 |
+
return round($val, 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
}
|
109 |
+
|
110 |
+
$badChars = array("\"", "'", ";", "\n");
|
111 |
+
|
112 |
+
$newString = str_replace($badChars, '', $val);
|
113 |
+
$newString = (strlen($newString) < 50) ? $newString : substr($newString, 0, 50);
|
114 |
+
|
115 |
+
return $newString;
|
116 |
+
|
|
|
117 |
}
|
118 |
|
119 |
/**
|
120 |
+
* Retrieves attribute values
|
|
|
121 |
*
|
122 |
+
* @param string $attr
|
123 |
* @return string
|
124 |
*/
|
125 |
+
protected function _getAttrValue($attr)
|
126 |
{
|
127 |
$product = $this->_getProduct();
|
128 |
+
$value = '';
|
129 |
+
|
130 |
+
switch ($attr) {
|
131 |
+
case 'news_from_date':
|
132 |
+
$newFromDate = $product->getData('created_at');
|
133 |
+
$newFromDate = str_replace("-", "", substr($newFromDate, 0, strpos($newFromDate, " ")));
|
134 |
+
$today = date('Ymd');
|
135 |
+
if (is_numeric($newFromDate)) {
|
136 |
+
$value = $today - $newFromDate;
|
137 |
+
}
|
138 |
+
break;
|
139 |
+
case 'inventory':
|
140 |
+
$value = round(Mage::getSingleton('cataloginventory/stock_item')->loadByProduct($product)->getQty(), 0);
|
141 |
+
break;
|
142 |
+
default:
|
143 |
+
$value = $product->getData($attr);
|
144 |
}
|
145 |
+
return $value;
|
146 |
}
|
147 |
|
148 |
/**
|
149 |
+
* Get the page type
|
|
|
|
|
150 |
*
|
|
|
151 |
* @return string
|
152 |
*/
|
153 |
+
protected function _getPageType()
|
154 |
{
|
155 |
+
if ($this->_pageType != NULL) {
|
156 |
+
return $this->_pageType;
|
|
|
|
|
157 |
}
|
158 |
|
159 |
+
$routeName = $this->getRequest()->getRequestedRouteName();
|
160 |
+
$actionName = $this->getAction()->getFullActionName();
|
161 |
+
$this->_pageType = '';
|
162 |
+
|
163 |
+
if ($actionName == 'catalog_product_view') {
|
164 |
+
$this->_pageType = 'product';
|
165 |
+
|
166 |
+
} elseif ($actionName == 'catalog_category_view') {
|
167 |
+
$this->_pageType = 'category';
|
168 |
+
|
169 |
+
} elseif ($this->getRequest()->getPathInfo() == '/') {
|
170 |
+
$this->_pageType = 'home';
|
171 |
+
|
172 |
+
} elseif ($routeName == 'cms') {
|
173 |
+
|
174 |
+
$identifier = Mage::getSingleton('cms/page')->getIdentifier();
|
175 |
+
if ($identifier == 'home' || $identifier == 'enterprise-home') {
|
176 |
+
$this->_pageType = 'home';
|
177 |
+
|
178 |
+
} else {
|
179 |
+
$this->_pageType = 'cms';
|
180 |
}
|
181 |
+
|
182 |
+
} elseif ($routeName == 'checkout' || $routeName == 'onestepcheckout') {
|
183 |
+
|
184 |
+
if ($this->getRequest()->getControllerName() == 'cart') {
|
185 |
+
$this->_pageType = 'cart';
|
186 |
+
|
187 |
+
} elseif ($this->getRequest()->getActionName() == 'success') {
|
188 |
+
$this->_pageType = 'success';
|
189 |
+
|
190 |
+
} else {
|
191 |
+
$this->_pageType = 'checkout';
|
192 |
+
}
|
193 |
+
|
194 |
+
} elseif ($routeName == 'customer') {
|
195 |
+
$this->_pageType = 'customer';
|
196 |
+
|
197 |
+
|
198 |
+
} elseif ($routeName == 'catalogsearch') {
|
199 |
+
$this->_pageType = 'search';
|
200 |
+
|
201 |
}
|
|
|
|
|
202 |
|
203 |
+
return $this->_pageType;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
}
|
205 |
|
206 |
/**
|
207 |
+
* Ouput HTML
|
|
|
208 |
*
|
209 |
* @return string
|
210 |
*/
|
211 |
+
protected function _toHtml()
|
212 |
{
|
213 |
+
if ($this->_helper()->isEnabled()) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
|
215 |
+
$optimizelyString = "window['optimizely'].push(['%s', '%s', '%s' ]);" . PHP_EOL;
|
216 |
|
217 |
+
$html = "<script>" . PHP_EOL;
|
218 |
+
$html .= "window['optimizely'] = window['optimizely'] || [];" . PHP_EOL;
|
219 |
|
220 |
+
if ($this->_getPageType()) {
|
221 |
+
$html .= sprintf($optimizelyString, 'customTag', 'page_type', $this->_getPageType());
|
222 |
+
}
|
223 |
|
224 |
+
//if category
|
225 |
+
if ($category = $this->_getCategory()) {
|
226 |
+
$categoryName = strtolower($category->getName());
|
227 |
+
$html .= sprintf($optimizelyString, 'customTag', 'category', $this->_clean($categoryName));
|
228 |
+
}
|
|
|
|
|
|
|
229 |
|
230 |
+
//if product
|
231 |
+
if ($this->_getProduct()) {
|
232 |
+
foreach ($this->_getProductVariables() as $key => $value) {
|
233 |
+
if ($value) {
|
234 |
+
$html .= sprintf($optimizelyString, 'customTag', $key, $this->_clean($value));
|
235 |
+
}
|
236 |
+
}
|
237 |
+
}
|
238 |
|
239 |
+
//if is success page, add the revenue tracking script
|
240 |
+
if ($this->_getPageType() == 'success' && $this->_helper()->isRevenueTrackingEnabled()) {
|
241 |
+
$orderId = Mage::getSingleton('checkout/session')->getData('last_order_id');
|
242 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
243 |
+
$revenueInCents = ($order->getGrandTotal() * 100);
|
244 |
+
$html .= sprintf($optimizelyString, 'trackEvent', 'success_page', $revenueInCents);
|
245 |
+
}
|
246 |
+
$html .= "</script>" . PHP_EOL;
|
247 |
|
248 |
+
return $html;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
}
|
250 |
}
|
|
|
251 |
}
|
app/code/community/BlueAcorn/Optimizely/Block/Head.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @package BlueAcorn\Optimizely
|
5 |
+
* @version 1.1.0
|
6 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
7 |
+
* @copyright Blue Acorn, Inc. 2014
|
8 |
+
*/
|
9 |
+
class BlueAcorn_Optimizely_Block_Head extends Mage_Page_Block_Html_Head
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* This will inject the optimizely embed payload into the top of the head tag and remove it from the block stack.
|
13 |
+
* If this isn't ran for some reason, the layout updates should ensure this is still rendered somewhere within
|
14 |
+
* the head tag.
|
15 |
+
*
|
16 |
+
* I considered using an observer here, but core_block_abstract_to_html_before seems to be the only good canidate and this
|
17 |
+
* feels more surgical, considering there's a fallback mechanism in place if there's a rewrite that supercedes this.
|
18 |
+
*
|
19 |
+
* @return string
|
20 |
+
*/
|
21 |
+
public function _toHtml()
|
22 |
+
{
|
23 |
+
$embed = $this->getChildHtml('optimizely_head');
|
24 |
+
if($embed) $this->unsetChild('optimizely_head');
|
25 |
+
return $embed.parent::_toHtml();
|
26 |
+
}
|
27 |
+
}
|
app/code/community/BlueAcorn/Optimizely/Block/SitewideJs.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package BlueAcorn\Optimizely
|
4 |
+
* @version 1.1.0
|
5 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
6 |
+
* @copyright Blue Acorn, Inc. 2014
|
7 |
+
*/
|
8 |
+
class BlueAcorn_Optimizely_Block_SitewideJs extends Mage_Core_Block_Abstract
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Return project code JS. returns empty string if module is disabled in System > Configuration
|
12 |
+
*
|
13 |
+
* @return string
|
14 |
+
*/
|
15 |
+
protected function _toHtml()
|
16 |
+
{
|
17 |
+
if (Mage::helper('blueacorn_optimizely')->isEnabled()) {
|
18 |
+
return Mage::helper('blueacorn_optimizely')->getOptimizelyProjectCode() . PHP_EOL;
|
19 |
+
} else {
|
20 |
+
return '';
|
21 |
+
}
|
22 |
+
}
|
23 |
+
}
|
app/code/community/BlueAcorn/Optimizely/Block/System/Config/Explanation.php
CHANGED
@@ -1,91 +1,14 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
-
* @
|
5 |
-
* @
|
6 |
-
* @
|
7 |
*/
|
8 |
class BlueAcorn_Optimizely_Block_System_Config_Explanation extends Mage_Adminhtml_Block_System_Config_Form_Field
|
9 |
{
|
10 |
-
|
11 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
12 |
{
|
13 |
-
return 'These are for additional attributes you can set for product pages. These attributes will be included in your
|
14 |
-
}
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Enter description here...
|
18 |
-
*
|
19 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
20 |
-
* @return string
|
21 |
-
*/
|
22 |
-
public function render(Varien_Data_Form_Element_Abstract $element)
|
23 |
-
{
|
24 |
-
$id = $element->getHtmlId();
|
25 |
-
|
26 |
-
$useContainerId = $element->getData('use_container_id');
|
27 |
-
$html = '<tr id="row_' . $id . '">'
|
28 |
-
. '<td class="label"><label for="' . $id . '">' . $element->getLabel() . '</label></td>';
|
29 |
-
|
30 |
-
//$isDefault = !$this->getRequest()->getParam('website') && !$this->getRequest()->getParam('store');
|
31 |
-
$isMultiple = $element->getExtType() === 'multiple';
|
32 |
-
|
33 |
-
// replace [value] with [inherit]
|
34 |
-
$namePrefix = preg_replace('#\[value\](\[\])?$#', '', $element->getName());
|
35 |
-
|
36 |
-
$options = $element->getValues();
|
37 |
-
|
38 |
-
$addInheritCheckbox = false;
|
39 |
-
if ($element->getCanUseWebsiteValue()) {
|
40 |
-
$addInheritCheckbox = true;
|
41 |
-
$checkboxLabel = Mage::helper('adminhtml')->__('Use Website');
|
42 |
-
} elseif ($element->getCanUseDefaultValue()) {
|
43 |
-
$addInheritCheckbox = true;
|
44 |
-
$checkboxLabel = Mage::helper('adminhtml')->__('Use Default');
|
45 |
-
}
|
46 |
-
|
47 |
-
if ($addInheritCheckbox) {
|
48 |
-
$inherit = $element->getInherit() == 1 ? 'checked="checked"' : '';
|
49 |
-
if ($inherit) {
|
50 |
-
$element->setDisabled(true);
|
51 |
-
}
|
52 |
-
}
|
53 |
-
|
54 |
-
$html .= '<td class="value">';
|
55 |
-
$html .= $this->_getElementHtml($element);
|
56 |
-
if ($element->getComment()) {
|
57 |
-
$html .= '<p class="note"><span>' . $element->getComment() . '</span></p>';
|
58 |
-
}
|
59 |
-
$html .= '</td>';
|
60 |
-
|
61 |
-
if ($addInheritCheckbox) {
|
62 |
-
|
63 |
-
$defText = $element->getDefaultValue();
|
64 |
-
if ($options) {
|
65 |
-
$defTextArr = array();
|
66 |
-
foreach ($options as $k => $v) {
|
67 |
-
if ($isMultiple) {
|
68 |
-
if (is_array($v['value']) && in_array($k, $v['value'])) {
|
69 |
-
$defTextArr[] = $v['label'];
|
70 |
-
}
|
71 |
-
} elseif ($v['value'] == $defText) {
|
72 |
-
$defTextArr[] = $v['label'];
|
73 |
-
break;
|
74 |
-
}
|
75 |
-
}
|
76 |
-
$defText = join(', ', $defTextArr);
|
77 |
-
}
|
78 |
-
}
|
79 |
-
|
80 |
-
$html .= '<td class="">';
|
81 |
-
if ($element->getHint()) {
|
82 |
-
$html .= '<div class="hint" >';
|
83 |
-
$html .= '<div style="display: none;">' . $element->getHint() . '</div>';
|
84 |
-
$html .= '</div>';
|
85 |
-
}
|
86 |
-
$html .= '</td>';
|
87 |
-
|
88 |
-
$html .= '</tr>';
|
89 |
-
return $html;
|
90 |
}
|
91 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package BlueAcorn\Optimizely
|
4 |
+
* @version 1.1.0
|
5 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
6 |
+
* @copyright Blue Acorn, Inc. 2014
|
7 |
*/
|
8 |
class BlueAcorn_Optimizely_Block_System_Config_Explanation extends Mage_Adminhtml_Block_System_Config_Form_Field
|
9 |
{
|
|
|
10 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
11 |
{
|
12 |
+
return $this->helper('blueacorn_optimizely')->__('These are for additional attributes you can set for product pages. These attributes will be included in your Optimizely custom variable and be available for page targeting.');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
}
|
14 |
}
|
app/code/community/BlueAcorn/Optimizely/Block/System/Config/Loginlink.php
CHANGED
@@ -1,90 +1,15 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
-
* @
|
5 |
-
* @
|
6 |
-
* @
|
7 |
*/
|
8 |
class BlueAcorn_Optimizely_Block_System_Config_Loginlink extends Mage_Adminhtml_Block_System_Config_Form_Field
|
9 |
{
|
10 |
-
|
11 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
12 |
{
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Enter description here...
|
18 |
-
*
|
19 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
20 |
-
* @return string
|
21 |
-
*/
|
22 |
-
public function render(Varien_Data_Form_Element_Abstract $element)
|
23 |
-
{
|
24 |
-
$id = $element->getHtmlId();
|
25 |
-
|
26 |
-
$useContainerId = $element->getData('use_container_id');
|
27 |
-
$html = '<tr id="row_' . $id . '">'
|
28 |
-
. '<td class="label"><label for="' . $id . '">' . $element->getLabel() . '</label></td>';
|
29 |
-
|
30 |
-
$isMultiple = $element->getExtType() === 'multiple';
|
31 |
-
|
32 |
-
// replace [value] with [inherit]
|
33 |
-
$namePrefix = preg_replace('#\[value\](\[\])?$#', '', $element->getName());
|
34 |
-
|
35 |
-
$options = $element->getValues();
|
36 |
-
|
37 |
-
$addInheritCheckbox = false;
|
38 |
-
if ($element->getCanUseWebsiteValue()) {
|
39 |
-
$addInheritCheckbox = true;
|
40 |
-
$checkboxLabel = Mage::helper('adminhtml')->__('Use Website');
|
41 |
-
} elseif ($element->getCanUseDefaultValue()) {
|
42 |
-
$addInheritCheckbox = true;
|
43 |
-
$checkboxLabel = Mage::helper('adminhtml')->__('Use Default');
|
44 |
-
}
|
45 |
-
|
46 |
-
if ($addInheritCheckbox) {
|
47 |
-
$inherit = $element->getInherit() == 1 ? 'checked="checked"' : '';
|
48 |
-
if ($inherit) {
|
49 |
-
$element->setDisabled(true);
|
50 |
-
}
|
51 |
-
}
|
52 |
-
|
53 |
-
$html .= '<td class="value">';
|
54 |
-
$html .= $this->_getElementHtml($element);
|
55 |
-
if ($element->getComment()) {
|
56 |
-
$html .= '<p class="note"><span>' . $element->getComment() . '</span></p>';
|
57 |
-
}
|
58 |
-
$html .= '</td>';
|
59 |
-
|
60 |
-
if ($addInheritCheckbox) {
|
61 |
-
|
62 |
-
$defText = $element->getDefaultValue();
|
63 |
-
if ($options) {
|
64 |
-
$defTextArr = array();
|
65 |
-
foreach ($options as $k => $v) {
|
66 |
-
if ($isMultiple) {
|
67 |
-
if (is_array($v['value']) && in_array($k, $v['value'])) {
|
68 |
-
$defTextArr[] = $v['label'];
|
69 |
-
}
|
70 |
-
} elseif ($v['value'] == $defText) {
|
71 |
-
$defTextArr[] = $v['label'];
|
72 |
-
break;
|
73 |
-
}
|
74 |
-
}
|
75 |
-
$defText = join(', ', $defTextArr);
|
76 |
-
}
|
77 |
-
}
|
78 |
-
|
79 |
-
$html .= '<td class="">';
|
80 |
-
if ($element->getHint()) {
|
81 |
-
$html .= '<div class="hint" >';
|
82 |
-
$html .= '<div style="display: none;">' . $element->getHint() . '</div>';
|
83 |
-
$html .= '</div>';
|
84 |
-
}
|
85 |
-
$html .= '</td>';
|
86 |
-
|
87 |
-
$html .= '</tr>';
|
88 |
-
return $html;
|
89 |
}
|
90 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package BlueAcorn\Optimizely
|
4 |
+
* @version 1.1.0
|
5 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
6 |
+
* @copyright Blue Acorn, Inc. 2014
|
7 |
*/
|
8 |
class BlueAcorn_Optimizely_Block_System_Config_Loginlink extends Mage_Adminhtml_Block_System_Config_Form_Field
|
9 |
{
|
|
|
10 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
11 |
{
|
12 |
+
$label = $this->helper('blueacorn_optimizely')->__('Optimizely Login/Signup');
|
13 |
+
return '<a href="http://optimizely.com" target="_blank">' . $label . '</a>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
}
|
15 |
}
|
app/code/community/BlueAcorn/Optimizely/Helper/Data.php
CHANGED
@@ -2,17 +2,14 @@
|
|
2 |
/**
|
3 |
* Methods that retrieve saved data in the module's system configuration
|
4 |
*
|
5 |
-
* @package
|
6 |
-
* @
|
7 |
-
* @
|
8 |
-
* @
|
9 |
*/
|
10 |
class BlueAcorn_Optimizely_Helper_Data extends Mage_Core_Helper_Abstract
|
11 |
{
|
12 |
-
const CONFIG_PATH = '
|
13 |
-
protected $config = null;
|
14 |
-
protected $defaultGroup = "settings";
|
15 |
-
protected $storedConfigs = array();
|
16 |
|
17 |
/**
|
18 |
* Config meta method for getting gts config
|
@@ -21,19 +18,9 @@ class BlueAcorn_Optimizely_Helper_Data extends Mage_Core_Helper_Abstract
|
|
21 |
* @param string $group
|
22 |
* @return mixed
|
23 |
*/
|
24 |
-
public function getConfig($code
|
25 |
{
|
26 |
-
|
27 |
-
if ($group == null) {
|
28 |
-
$group = $this->defaultGroup;
|
29 |
-
}
|
30 |
-
if (!isset($this->storedConfigs[$code])) {
|
31 |
-
$this->config = Mage::getStoreConfig(self::CONFIG_PATH . "$group/$code");
|
32 |
-
} else {
|
33 |
-
$this->config = $this->storedConfigs[$code];
|
34 |
-
}
|
35 |
-
}
|
36 |
-
return $this->config;
|
37 |
}
|
38 |
|
39 |
/**
|
@@ -63,66 +50,23 @@ class BlueAcorn_Optimizely_Helper_Data extends Mage_Core_Helper_Abstract
|
|
63 |
*/
|
64 |
public function getOptimizelyProjectCode()
|
65 |
{
|
66 |
-
|
67 |
-
return $this->getConfig('optimizely_project_code', 'settings');
|
68 |
-
} else {
|
69 |
-
return null;
|
70 |
-
}
|
71 |
-
}
|
72 |
|
73 |
-
/**
|
74 |
-
* Get first custom product attribute from config
|
75 |
-
*
|
76 |
-
* @return int
|
77 |
-
*/
|
78 |
-
public function getCustomAttrOne()
|
79 |
-
{
|
80 |
-
if ($this->isEnabled() == 1) {
|
81 |
-
return $this->getConfig('optimizely_custom_one', 'project_settings');
|
82 |
-
} else {
|
83 |
-
return null;
|
84 |
-
}
|
85 |
}
|
86 |
|
87 |
/**
|
88 |
-
* Get
|
89 |
*
|
90 |
-
* @return
|
91 |
*/
|
92 |
-
public function
|
93 |
{
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
}
|
99 |
-
}
|
100 |
|
101 |
-
|
102 |
-
* Get third custom product attribute from config
|
103 |
-
*
|
104 |
-
* @return int
|
105 |
-
*/
|
106 |
-
public function getCustomAttrThree()
|
107 |
-
{
|
108 |
-
if ($this->isEnabled() == 1) {
|
109 |
-
return $this->getConfig('optimizely_custom_three', 'project_settings');
|
110 |
-
} else {
|
111 |
-
return null;
|
112 |
-
}
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* Get fourth custom product attribute from config
|
117 |
-
*
|
118 |
-
* @return int
|
119 |
-
*/
|
120 |
-
public function getCustomAttrFour()
|
121 |
-
{
|
122 |
-
if ($this->isEnabled() == 1) {
|
123 |
-
return $this->getConfig('optimizely_custom_four', 'project_settings');
|
124 |
-
} else {
|
125 |
-
return null;
|
126 |
-
}
|
127 |
}
|
128 |
}
|
2 |
/**
|
3 |
* Methods that retrieve saved data in the module's system configuration
|
4 |
*
|
5 |
+
* @package BlueAcorn\Optimizely
|
6 |
+
* @version 1.1.0
|
7 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
8 |
+
* @copyright Blue Acorn, Inc. 2014
|
9 |
*/
|
10 |
class BlueAcorn_Optimizely_Helper_Data extends Mage_Core_Helper_Abstract
|
11 |
{
|
12 |
+
const CONFIG_PATH = 'blueacorn_optimizely/';
|
|
|
|
|
|
|
13 |
|
14 |
/**
|
15 |
* Config meta method for getting gts config
|
18 |
* @param string $group
|
19 |
* @return mixed
|
20 |
*/
|
21 |
+
public function getConfig($code, $group)
|
22 |
{
|
23 |
+
return Mage::getStoreConfig(self::CONFIG_PATH . "$group/$code");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
|
26 |
/**
|
50 |
*/
|
51 |
public function getOptimizelyProjectCode()
|
52 |
{
|
53 |
+
return $this->getConfig('optimizely_project_code', 'settings');
|
|
|
|
|
|
|
|
|
|
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
+
* Get custom product attributes from config
|
59 |
*
|
60 |
+
* @return array
|
61 |
*/
|
62 |
+
public function getCustomAttributes()
|
63 |
{
|
64 |
+
$config = Mage::getStoreConfig(self::CONFIG_PATH . "project_settings/attributes");
|
65 |
+
$attrs = array();
|
66 |
+
foreach($config as $attr) {
|
67 |
+
$attrs[] = $attr['attribute'];
|
68 |
}
|
|
|
69 |
|
70 |
+
return $attrs;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
}
|
72 |
}
|
app/code/community/BlueAcorn/Optimizely/Model/DisallowDuplicates.php
DELETED
@@ -1,37 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* TODO: Fix undefined index: value on line 23 when changing the value of an attribute on the store scope after default values are set.
|
4 |
-
* Makes sure the user doesn't select the same attribute twice.
|
5 |
-
*
|
6 |
-
* @package BlueAcorn
|
7 |
-
* @subpackage Optimizely
|
8 |
-
* @author James Bruner
|
9 |
-
*/
|
10 |
-
class BlueAcorn_Optimizely_Model_DisallowDuplicates extends Mage_Core_Model_Config_Data
|
11 |
-
{
|
12 |
-
/**
|
13 |
-
* @return Mage_Core_Model_Abstract
|
14 |
-
*/
|
15 |
-
protected function _beforeSave()
|
16 |
-
{
|
17 |
-
$groups = $this->getData('groups');
|
18 |
-
if (isset($groups['product_settings']['fields'])) {
|
19 |
-
$fields = $groups['product_settings']['fields'];
|
20 |
-
unset($fields['explanation']);
|
21 |
-
|
22 |
-
foreach ($fields as $searchKey => $searchField) {
|
23 |
-
$searchField = $searchField['value'];
|
24 |
-
foreach ($fields as $key => $field) {
|
25 |
-
$field = $field['value'];
|
26 |
-
if ($field && $field !== "" && $searchField && $searchField !== "") {
|
27 |
-
if ($searchKey != $key && $field == $searchField) {
|
28 |
-
Mage::throwException("Settings have not been saved. An attribute has been chosen twice. Please select only unique attributes.");
|
29 |
-
}
|
30 |
-
}
|
31 |
-
}
|
32 |
-
}
|
33 |
-
}
|
34 |
-
|
35 |
-
return parent::_beforeSave();
|
36 |
-
}
|
37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/BlueAcorn/Optimizely/Model/Enabledcheck.php
CHANGED
@@ -3,10 +3,10 @@
|
|
3 |
* Sending a warning after save to tell the user they have not actually enabled
|
4 |
* the module so no settings will appear on the frontend.
|
5 |
*
|
6 |
-
* @package
|
7 |
-
* @
|
8 |
-
* @
|
9 |
-
* @
|
10 |
*/
|
11 |
class BlueAcorn_Optimizely_Model_Enabledcheck extends Mage_Core_Model_Config_Data
|
12 |
{
|
@@ -19,8 +19,12 @@ class BlueAcorn_Optimizely_Model_Enabledcheck extends Mage_Core_Model_Config_Dat
|
|
19 |
{
|
20 |
$enabled = $this->getValue();
|
21 |
if ($enabled == null || $enabled == 0) {
|
22 |
-
|
|
|
|
|
23 |
}
|
|
|
|
|
24 |
return parent::_afterSave();
|
25 |
}
|
26 |
}
|
3 |
* Sending a warning after save to tell the user they have not actually enabled
|
4 |
* the module so no settings will appear on the frontend.
|
5 |
*
|
6 |
+
* @package BlueAcorn\Optimizely
|
7 |
+
* @version 1.1.0
|
8 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
9 |
+
* @copyright Blue Acorn, Inc. 2014
|
10 |
*/
|
11 |
class BlueAcorn_Optimizely_Model_Enabledcheck extends Mage_Core_Model_Config_Data
|
12 |
{
|
19 |
{
|
20 |
$enabled = $this->getValue();
|
21 |
if ($enabled == null || $enabled == 0) {
|
22 |
+
Mage::getSingleton('core/session')->addNotice(
|
23 |
+
Mage::helper('blueacorn_optimizely')->__('You have not enabled the Optimizely Extension. No data will appear on the frontend. Please enable to activate frontend Javascript output.')
|
24 |
+
);
|
25 |
}
|
26 |
+
|
27 |
+
|
28 |
return parent::_afterSave();
|
29 |
}
|
30 |
}
|
app/code/community/BlueAcorn/Optimizely/Model/Entity/Attribute.php
DELETED
@@ -1,48 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Creates the select values in the configuration by pulling all catalog product
|
4 |
-
* attributes from the Magento DB.
|
5 |
-
*
|
6 |
-
* @package BlueAcorn
|
7 |
-
* @subpackage Optimizely
|
8 |
-
* @version 1.0.2
|
9 |
-
* @author James Bruner
|
10 |
-
*/
|
11 |
-
class BlueAcorn_Optimizely_Model_Entity_Attribute extends Mage_Eav_Model_Entity_Attribute
|
12 |
-
{
|
13 |
-
/**
|
14 |
-
* Options select for different types of custom text attributes
|
15 |
-
*
|
16 |
-
* @return array
|
17 |
-
*/
|
18 |
-
public function toOptionArray()
|
19 |
-
{
|
20 |
-
$eavEntityType = Mage::getModel('eav/entity_type')->loadByCode('catalog_product');
|
21 |
-
$attributes = $this->getCollection()->setEntityTypeFilter($eavEntityType->getId());
|
22 |
-
$excluded = array('sku', 'price', 'name');
|
23 |
-
$attributeOptions = array(
|
24 |
-
array('value' => 0, 'label' => Mage::helper('optimizely')->__('')),
|
25 |
-
);
|
26 |
-
$i = 1;
|
27 |
-
foreach ($attributes as $attribute) {
|
28 |
-
$code = $attribute['attribute_code'];
|
29 |
-
$label = $attribute['frontend_label'];
|
30 |
-
if (!in_array($code, $excluded)) {
|
31 |
-
if ($label !== null && $label !== "") {
|
32 |
-
array_push($attributeOptions, array('value' => $code, 'label' => Mage::helper('optimizely')->__($label)));
|
33 |
-
$i++;
|
34 |
-
}
|
35 |
-
}
|
36 |
-
}
|
37 |
-
uasort($attributeOptions, 'blueAcornOptimizelyModelEntityAttributeCompareFunction');
|
38 |
-
return $attributeOptions;
|
39 |
-
}
|
40 |
-
}
|
41 |
-
|
42 |
-
function blueAcornOptimizelyModelEntityAttributeCompareFunction($a, $b)
|
43 |
-
{
|
44 |
-
if ($a['label'] == $b['label']) {
|
45 |
-
return 0;
|
46 |
-
}
|
47 |
-
return ($a['label'] < $b['label']) ? -1 : 1;
|
48 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/BlueAcorn/Optimizely/Model/Projectcode.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Clean the project code JS of unicode characters
|
4 |
+
*
|
5 |
+
* @package BlueAcorn\Optimizely
|
6 |
+
* @version 1.1.0
|
7 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
8 |
+
* @copyright Blue Acorn, Inc. 2014
|
9 |
+
*/
|
10 |
+
class BlueAcorn_Optimizely_Model_Projectcode extends Mage_Core_Model_Config_Data
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Clean the project code of unicode characters.
|
14 |
+
*
|
15 |
+
* @return Mage_Core_Model_Abstract|void
|
16 |
+
*/
|
17 |
+
protected function _beforeSave()
|
18 |
+
{
|
19 |
+
$script = $this->getValue();
|
20 |
+
$script = preg_replace('/[^(\x20-\x7F)]*/','', $script);
|
21 |
+
|
22 |
+
$this->setValue($script);
|
23 |
+
|
24 |
+
return parent::_beforeSave();
|
25 |
+
}
|
26 |
+
}
|
app/code/community/BlueAcorn/Optimizely/Model/System/Config/Source/Attribute.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Creates the select values in the configuration by pulling all catalog product
|
4 |
+
* attributes from the Magento DB.
|
5 |
+
*
|
6 |
+
* @package BlueAcorn\Optimizely
|
7 |
+
* @version 1.1.0
|
8 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
9 |
+
* @copyright Blue Acorn, Inc. 2014
|
10 |
+
*/
|
11 |
+
class BlueAcorn_Optimizely_Model_System_Config_Source_Attribute
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Options select for different types of custom text attributes
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
public function toOptionArray()
|
19 |
+
{
|
20 |
+
$entityTypeId = Mage::getModel('eav/entity')
|
21 |
+
->setType(Mage_Catalog_Model_Product::ENTITY)
|
22 |
+
->getTypeId();
|
23 |
+
|
24 |
+
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')
|
25 |
+
->setEntityTypeFilter($entityTypeId)
|
26 |
+
->getItems();
|
27 |
+
|
28 |
+
$excluded = array('sku', 'price', 'name');
|
29 |
+
$attributeOptions = array(
|
30 |
+
array('value' => '', 'label' => ''),
|
31 |
+
);
|
32 |
+
|
33 |
+
foreach ($attributes as $attribute) {
|
34 |
+
$code = $attribute['attribute_code'];
|
35 |
+
$label = $attribute['frontend_label'];
|
36 |
+
if (!in_array($code, $excluded) && strlen($label) > 0) {
|
37 |
+
array_push(
|
38 |
+
$attributeOptions,
|
39 |
+
array(
|
40 |
+
'value' => $code,
|
41 |
+
'label' => $label,
|
42 |
+
)
|
43 |
+
);
|
44 |
+
}
|
45 |
+
}
|
46 |
+
uasort($attributeOptions, array($this, 'attributeOptionArrayComparison'));
|
47 |
+
|
48 |
+
return $attributeOptions;
|
49 |
+
}
|
50 |
+
|
51 |
+
static public function attributeOptionArrayComparison($a, $b)
|
52 |
+
{
|
53 |
+
if ($a['label'] == $b['label']) {
|
54 |
+
return 0;
|
55 |
+
}
|
56 |
+
return ($a['label'] < $b['label']) ? -1 : 1;
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
|
app/code/community/BlueAcorn/Optimizely/Model/System/Config/Source/Minigrid/Attribute.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Creates the select values in the configuration by pulling all catalog product
|
4 |
+
* attributes from the Magento DB.
|
5 |
+
*
|
6 |
+
* @package BlueAcorn\Optimizely
|
7 |
+
* @version 1.1.0
|
8 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
9 |
+
* @copyright Blue Acorn, Inc. 2014
|
10 |
+
*/
|
11 |
+
class BlueAcorn_Optimizely_Model_System_Config_Source_Minigrid_Attribute
|
12 |
+
extends BlueAcorn_MiniGrid_Model_System_Config_Source_Minigrid_Abstract {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Minigrid field source. One column with a list of product attributes
|
16 |
+
*
|
17 |
+
* @return array
|
18 |
+
*/
|
19 |
+
protected function _getFields() {
|
20 |
+
|
21 |
+
$options = Mage::getModel('blueacorn_optimizely/system_config_source_attribute')->toOptionArray();
|
22 |
+
|
23 |
+
$opts = array();
|
24 |
+
foreach ($options as $opt) {
|
25 |
+
$opts[$opt['value']] = $opt['label'];
|
26 |
+
}
|
27 |
+
|
28 |
+
return array(
|
29 |
+
"attribute" => array(
|
30 |
+
"width" => "100%",
|
31 |
+
"type" => "select",
|
32 |
+
"options" => $opts,
|
33 |
+
)
|
34 |
+
);
|
35 |
+
}
|
36 |
+
|
37 |
+
}
|
app/code/community/BlueAcorn/Optimizely/data/blueacorn_optimizely_setup/data-upgrade-1.0.2-1.1.0.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package BlueAcorn\Optimizely
|
4 |
+
* @version 1.1.0
|
5 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
6 |
+
* @copyright Blue Acorn, Inc. 2014
|
7 |
+
*/
|
8 |
+
$config = new Mage_Core_Model_Config();
|
9 |
+
|
10 |
+
$settings = array(
|
11 |
+
'settings/enabled',
|
12 |
+
'settings/revenue_tracking',
|
13 |
+
'settings/optimizely_project_code',
|
14 |
+
);
|
15 |
+
|
16 |
+
foreach($settings as $setting) {
|
17 |
+
$val = Mage::getStoreConfig("optimizely/$setting");
|
18 |
+
$config->saveConfig("blueacorn_optimizely/$setting", $val);
|
19 |
+
$config->deleteConfig("optimizely/$setting");
|
20 |
+
}
|
21 |
+
|
22 |
+
$cust_attrs = array(
|
23 |
+
'project_settings/optimizely_custom_one',
|
24 |
+
'project_settings/optimizely_custom_two',
|
25 |
+
'project_settings/optimizely_custom_three',
|
26 |
+
'project_settings/optimizely_custom_four',
|
27 |
+
);
|
28 |
+
|
29 |
+
$attributes = array();
|
30 |
+
foreach($cust_attrs as $setting) {
|
31 |
+
|
32 |
+
$val = Mage::getStoreConfig("optimizely/$setting");
|
33 |
+
|
34 |
+
if ($val) {
|
35 |
+
$attributes[] = array(
|
36 |
+
'attribute' => $val,
|
37 |
+
);
|
38 |
+
}
|
39 |
+
$config->deleteConfig("optimizely/$setting");
|
40 |
+
};
|
41 |
+
|
42 |
+
$config->saveConfig("blueacorn_optimizely/project_settings/attributes", serialize($attributes));
|
43 |
+
|
app/code/community/BlueAcorn/Optimizely/doc/changelog.txt
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
1.0.1
|
2 |
-
Initial development of module. Added system configuration Javascript variables for products, categories, and page types. Integration of sitewide script, revenue tracking, and page targeting (via optimizely_custom variable).
|
3 |
-
|
4 |
-
1.0.2
|
5 |
-
Added support for new Optimizely custom tag feature and updated previous code to follow new logic. Also added more security to escaped strings and updated a few page types.
|
|
|
|
|
|
|
|
|
|
app/code/community/BlueAcorn/Optimizely/doc/design.txt
DELETED
@@ -1,29 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* BlueAcorn Optimizely Magento Module
|
3 |
-
*
|
4 |
-
* @package BlueAcorn
|
5 |
-
* @subpackage Optimizely
|
6 |
-
* @version 1.0.2
|
7 |
-
* @author James Bruner
|
8 |
-
*/
|
9 |
-
|
10 |
-
BlueAcorn Optimizely allows for an easy way to add necessary Optimizely.com
|
11 |
-
Javascript scripts and custom variables to pages of your Magento web store.
|
12 |
-
|
13 |
-
System Configuration:
|
14 |
-
The System Config is store scope specific so that you can enable the module on
|
15 |
-
one store of a multi-store Magento setup.
|
16 |
-
|
17 |
-
All that needs to be configured is your project code and your custom product attributes (if needed).
|
18 |
-
|
19 |
-
If the module is disabled, nothing will output on the frontend of your website.
|
20 |
-
|
21 |
-
The Sitewide Javascript is placed directly in the <head> tag,
|
22 |
-
and before the Google Analytics script. The optimizely custom variable is placed
|
23 |
-
above the sitewide Javascript code, and encapsulates all custom attributes.
|
24 |
-
Custom attribute variables defined in the system config will only appear on product
|
25 |
-
pages that have a value defined for that attribute.
|
26 |
-
|
27 |
-
If an admin user selects two of the same attribute, the configuration will not
|
28 |
-
be saved, and an error will be thrown telling the user to select unique
|
29 |
-
attributes for each custom value.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/BlueAcorn/Optimizely/doc/makeTar.txt
DELETED
@@ -1,6 +0,0 @@
|
|
1 |
-
tar -czvf
|
2 |
-
BlueAcorn_Optimizely-1.0.5.tar.gz
|
3 |
-
app/code/community/BlueAcorn/Optimizely
|
4 |
-
app/etc/modules/BlueAcorn_Optimizely.xml
|
5 |
-
app/design/frontend/base/default/layout/blueacorn/optimizely.xml
|
6 |
-
app/design/frontend/base/default/template/blueacorn/optimizely
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/BlueAcorn/Optimizely/etc/adminhtml.xml
CHANGED
@@ -1,4 +1,12 @@
|
|
1 |
<?xml version="1.0"?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
<config>
|
3 |
<acl>
|
4 |
<resources>
|
@@ -8,9 +16,9 @@
|
|
8 |
<children>
|
9 |
<config>
|
10 |
<children>
|
11 |
-
<
|
12 |
<title>Optimizely</title>
|
13 |
-
</
|
14 |
</children>
|
15 |
</config>
|
16 |
</children>
|
@@ -19,4 +27,4 @@
|
|
19 |
</admin>
|
20 |
</resources>
|
21 |
</acl>
|
22 |
-
</config>
|
1 |
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @package BlueAcorn\Optimizely
|
5 |
+
* @version 1.1.0
|
6 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
7 |
+
* @copyright Blue Acorn, Inc. 2014
|
8 |
+
*/
|
9 |
+
-->
|
10 |
<config>
|
11 |
<acl>
|
12 |
<resources>
|
16 |
<children>
|
17 |
<config>
|
18 |
<children>
|
19 |
+
<blueacorn_optimizely module="blueacorn_optimizely" translate="title">
|
20 |
<title>Optimizely</title>
|
21 |
+
</blueacorn_optimizely>
|
22 |
</children>
|
23 |
</config>
|
24 |
</children>
|
27 |
</admin>
|
28 |
</resources>
|
29 |
</acl>
|
30 |
+
</config>
|
app/code/community/BlueAcorn/Optimizely/etc/config.xml
CHANGED
@@ -1,42 +1,73 @@
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<BlueAcorn_Optimizely>
|
5 |
-
<version>1.0
|
6 |
</BlueAcorn_Optimizely>
|
7 |
</modules>
|
8 |
<global>
|
9 |
<blocks>
|
10 |
-
<
|
11 |
<class>BlueAcorn_Optimizely_Block</class>
|
12 |
-
</
|
|
|
|
|
|
|
|
|
|
|
13 |
</blocks>
|
14 |
<helpers>
|
15 |
-
<
|
16 |
<class>BlueAcorn_Optimizely_Helper</class>
|
17 |
-
</
|
18 |
</helpers>
|
19 |
<models>
|
20 |
-
<
|
21 |
<class>BlueAcorn_Optimizely_Model</class>
|
22 |
-
</
|
23 |
</models>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
</global>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
<frontend>
|
26 |
<layout>
|
27 |
<updates>
|
28 |
-
<
|
29 |
<file>blueacorn/optimizely.xml</file>
|
30 |
-
</
|
31 |
</updates>
|
32 |
</layout>
|
33 |
</frontend>
|
34 |
-
<
|
35 |
-
<
|
36 |
-
<
|
37 |
-
<
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
</
|
|
|
|
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @package BlueAcorn\Optimizely
|
5 |
+
* @version 1.1.0
|
6 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
7 |
+
* @copyright Blue Acorn, Inc. 2014
|
8 |
+
*/
|
9 |
+
-->
|
10 |
<config>
|
11 |
<modules>
|
12 |
<BlueAcorn_Optimizely>
|
13 |
+
<version>1.1.0</version>
|
14 |
</BlueAcorn_Optimizely>
|
15 |
</modules>
|
16 |
<global>
|
17 |
<blocks>
|
18 |
+
<blueacorn_optimizely>
|
19 |
<class>BlueAcorn_Optimizely_Block</class>
|
20 |
+
</blueacorn_optimizely>
|
21 |
+
<page>
|
22 |
+
<rewrite>
|
23 |
+
<html_head>BlueAcorn_Optimizely_Block_Head</html_head>
|
24 |
+
</rewrite>
|
25 |
+
</page>
|
26 |
</blocks>
|
27 |
<helpers>
|
28 |
+
<blueacorn_optimizely>
|
29 |
<class>BlueAcorn_Optimizely_Helper</class>
|
30 |
+
</blueacorn_optimizely>
|
31 |
</helpers>
|
32 |
<models>
|
33 |
+
<blueacorn_optimizely>
|
34 |
<class>BlueAcorn_Optimizely_Model</class>
|
35 |
+
</blueacorn_optimizely>
|
36 |
</models>
|
37 |
+
<resources>
|
38 |
+
<blueacorn_optimizely_setup>
|
39 |
+
<setup>
|
40 |
+
<module>BlueAcorn_Optimizely</module>
|
41 |
+
<class>Mage_Core_Model_Resource_Setup</class>
|
42 |
+
</setup>
|
43 |
+
</blueacorn_optimizely_setup>
|
44 |
+
</resources>
|
45 |
</global>
|
46 |
+
<default>
|
47 |
+
<blueacorn_optimizely>
|
48 |
+
<project_settings>
|
49 |
+
<attributes backend_model="baminigrid/system_config_backend_minigrid" />
|
50 |
+
</project_settings>
|
51 |
+
</blueacorn_optimizely>
|
52 |
+
</default>
|
53 |
<frontend>
|
54 |
<layout>
|
55 |
<updates>
|
56 |
+
<blueacorn_optimizely module="BlueAcorn_Optimizely">
|
57 |
<file>blueacorn/optimizely.xml</file>
|
58 |
+
</blueacorn_optimizely>
|
59 |
</updates>
|
60 |
</layout>
|
61 |
</frontend>
|
62 |
+
<adminhtml>
|
63 |
+
<translate>
|
64 |
+
<modules>
|
65 |
+
<BlueAcorn_Optimizely>
|
66 |
+
<files>
|
67 |
+
<default>BlueAcorn_Optimizely.csv</default>
|
68 |
+
</files>
|
69 |
+
</BlueAcorn_Optimizely>
|
70 |
+
</modules>
|
71 |
+
</translate>
|
72 |
+
</adminhtml>
|
73 |
+
</config>
|
app/code/community/BlueAcorn/Optimizely/etc/system.xml
CHANGED
@@ -1,7 +1,17 @@
|
|
1 |
<?xml version="1.0"?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
<config>
|
3 |
<sections>
|
4 |
-
<
|
5 |
<class>optimizely</class>
|
6 |
<label>Optimizely</label>
|
7 |
<tab>general</tab>
|
@@ -22,7 +32,7 @@
|
|
22 |
<fields>
|
23 |
<signup translate="label">
|
24 |
<label>Login or Signup</label>
|
25 |
-
<frontend_model>
|
26 |
<frontend_type>text</frontend_type>
|
27 |
<sort_order>0</sort_order>
|
28 |
<show_in_default>1</show_in_default>
|
@@ -30,7 +40,7 @@
|
|
30 |
<show_in_store>1</show_in_store>
|
31 |
</signup>
|
32 |
<enabled translate="label">
|
33 |
-
<backend_model>
|
34 |
<label>Enabled</label>
|
35 |
<frontend_type>select</frontend_type>
|
36 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
@@ -39,17 +49,17 @@
|
|
39 |
<show_in_website>1</show_in_website>
|
40 |
<show_in_store>1</show_in_store>
|
41 |
</enabled>
|
42 |
-
<optimizely_project_code translate="label">
|
43 |
<label>Optimizely Project Code</label>
|
44 |
<frontend_type>textarea</frontend_type>
|
|
|
45 |
<sort_order>20</sort_order>
|
46 |
-
<comment
|
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 |
</optimizely_project_code>
|
51 |
<revenue_tracking translate="label">
|
52 |
-
<backend_model>optimizely/enabledcheck</backend_model>
|
53 |
<label>Enable Revenue Tracking</label>
|
54 |
<frontend_type>select</frontend_type>
|
55 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
@@ -72,60 +82,27 @@
|
|
72 |
<fields>
|
73 |
<explanation translate="label">
|
74 |
<label>What are Product Settings?</label>
|
75 |
-
<frontend_model>
|
76 |
<frontend_type>text</frontend_type>
|
77 |
-
<sort_order>0</sort_order>
|
78 |
-
<show_in_default>1</show_in_default>
|
79 |
-
<show_in_website>1</show_in_website>
|
80 |
-
<show_in_store>1</show_in_store>
|
81 |
-
</explanation>
|
82 |
-
<optimizely_custom_one translate="label">
|
83 |
-
<label>Custom Variable</label>
|
84 |
-
<!--<backend_model>optimizely/disallowDuplicates</backend_model>-->
|
85 |
-
<source_model>optimizely/entity_attribute</source_model>
|
86 |
-
<frontend_type>select</frontend_type>
|
87 |
<sort_order>10</sort_order>
|
88 |
-
<comment>Please do not select the same attribute twice.</comment>
|
89 |
<show_in_default>1</show_in_default>
|
90 |
<show_in_website>1</show_in_website>
|
91 |
<show_in_store>1</show_in_store>
|
92 |
-
</
|
93 |
-
<
|
94 |
-
<label>
|
95 |
-
|
96 |
-
<
|
97 |
-
<
|
|
|
98 |
<sort_order>20</sort_order>
|
99 |
-
<comment>Please do not select the same attribute twice.</comment>
|
100 |
-
<show_in_default>1</show_in_default>
|
101 |
-
<show_in_website>1</show_in_website>
|
102 |
-
<show_in_store>1</show_in_store>
|
103 |
-
</optimizely_custom_two>
|
104 |
-
<optimizely_custom_three translate="label">
|
105 |
-
<label>Custom Variable</label>
|
106 |
-
<!--<backend_model>optimizely/disallowDuplicates</backend_model>-->
|
107 |
-
<source_model>optimizely/entity_attribute</source_model>
|
108 |
-
<frontend_type>select</frontend_type>
|
109 |
-
<sort_order>30</sort_order>
|
110 |
-
<comment>Please do not select the same attribute twice.</comment>
|
111 |
-
<show_in_default>1</show_in_default>
|
112 |
-
<show_in_website>1</show_in_website>
|
113 |
-
<show_in_store>1</show_in_store>
|
114 |
-
</optimizely_custom_three>
|
115 |
-
<optimizely_custom_four translate="label">
|
116 |
-
<label>Custom Variable</label>
|
117 |
-
<!--<backend_model>optimizely/disallowDuplicates</backend_model>-->
|
118 |
-
<source_model>optimizely/entity_attribute</source_model>
|
119 |
-
<frontend_type>select</frontend_type>
|
120 |
-
<sort_order>40</sort_order>
|
121 |
-
<comment>Please do not select the same attribute twice.</comment>
|
122 |
<show_in_default>1</show_in_default>
|
123 |
<show_in_website>1</show_in_website>
|
124 |
<show_in_store>1</show_in_store>
|
125 |
-
</
|
126 |
</fields>
|
127 |
</project_settings>
|
128 |
</groups>
|
129 |
-
</
|
130 |
</sections>
|
131 |
-
</config>
|
1 |
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* System XML for Optimizely
|
5 |
+
*
|
6 |
+
* @package BlueAcorn\Optimizely
|
7 |
+
* @version 1.1.0
|
8 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
9 |
+
* @copyright Blue Acorn, Inc. 2014
|
10 |
+
*/
|
11 |
+
-->
|
12 |
<config>
|
13 |
<sections>
|
14 |
+
<blueacorn_optimizely translate="label" module="blueacorn_optimizely">
|
15 |
<class>optimizely</class>
|
16 |
<label>Optimizely</label>
|
17 |
<tab>general</tab>
|
32 |
<fields>
|
33 |
<signup translate="label">
|
34 |
<label>Login or Signup</label>
|
35 |
+
<frontend_model>blueacorn_optimizely/system_config_loginlink</frontend_model>
|
36 |
<frontend_type>text</frontend_type>
|
37 |
<sort_order>0</sort_order>
|
38 |
<show_in_default>1</show_in_default>
|
40 |
<show_in_store>1</show_in_store>
|
41 |
</signup>
|
42 |
<enabled translate="label">
|
43 |
+
<backend_model>blueacorn_optimizely/enabledcheck</backend_model>
|
44 |
<label>Enabled</label>
|
45 |
<frontend_type>select</frontend_type>
|
46 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
49 |
<show_in_website>1</show_in_website>
|
50 |
<show_in_store>1</show_in_store>
|
51 |
</enabled>
|
52 |
+
<optimizely_project_code translate="label comment">
|
53 |
<label>Optimizely Project Code</label>
|
54 |
<frontend_type>textarea</frontend_type>
|
55 |
+
<backend_model>blueacorn_optimizely/projectcode</backend_model>
|
56 |
<sort_order>20</sort_order>
|
57 |
+
<comment>Please enter your Optimizely script here. Your Project Code is located on the Dashboard in your Optimizely.com account.</comment>
|
58 |
<show_in_default>1</show_in_default>
|
59 |
<show_in_website>1</show_in_website>
|
60 |
<show_in_store>1</show_in_store>
|
61 |
</optimizely_project_code>
|
62 |
<revenue_tracking translate="label">
|
|
|
63 |
<label>Enable Revenue Tracking</label>
|
64 |
<frontend_type>select</frontend_type>
|
65 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
82 |
<fields>
|
83 |
<explanation translate="label">
|
84 |
<label>What are Product Settings?</label>
|
85 |
+
<frontend_model>blueacorn_optimizely/system_config_explanation</frontend_model>
|
86 |
<frontend_type>text</frontend_type>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
<sort_order>10</sort_order>
|
|
|
88 |
<show_in_default>1</show_in_default>
|
89 |
<show_in_website>1</show_in_website>
|
90 |
<show_in_store>1</show_in_store>
|
91 |
+
</explanation>
|
92 |
+
<attributes translate="label comment">
|
93 |
+
<label>Attributes to include</label>
|
94 |
+
<comment>Price, Product Type, Name, and SKU are not available to select as these attributes will automatically be added for every product.</comment>
|
95 |
+
<frontend_type>minigrid</frontend_type>
|
96 |
+
<source_model>blueacorn_optimizely/system_config_source_minigrid_attribute</source_model>
|
97 |
+
<backend_model>baminigrid/system_config_backend_minigrid</backend_model>
|
98 |
<sort_order>20</sort_order>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
<show_in_default>1</show_in_default>
|
100 |
<show_in_website>1</show_in_website>
|
101 |
<show_in_store>1</show_in_store>
|
102 |
+
</attributes>
|
103 |
</fields>
|
104 |
</project_settings>
|
105 |
</groups>
|
106 |
+
</blueacorn_optimizely>
|
107 |
</sections>
|
108 |
+
</config>
|
app/code/community/BlueAcorn/Optimizely/sql/blueacorn_optimizely_setup/install-1.0.2.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package BlueAcorn\Optimizely
|
4 |
+
* @version 1.1.0
|
5 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
6 |
+
* @copyright Blue Acorn, Inc. 2014
|
7 |
+
*/
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
$installer->endSetup();
|
app/design/frontend/base/default/layout/blueacorn/optimizely.xml
CHANGED
@@ -2,24 +2,22 @@
|
|
2 |
<!--
|
3 |
/**
|
4 |
* This is the layout xml file for BlueAcorn Optimizely. It creates two
|
5 |
-
* blocks within a text_list block that output the sitewide
|
6 |
* and the page specific targeting variables.
|
7 |
*
|
8 |
-
*
|
9 |
-
*
|
|
|
|
|
10 |
*/
|
11 |
-
|
12 |
-->
|
13 |
-
<layout
|
14 |
<default>
|
15 |
<reference name="head">
|
16 |
-
<block type="core/text_list" name="
|
17 |
-
<block type="
|
18 |
-
|
19 |
-
template="blueacorn/optimizely/customVariables.phtml"/>
|
20 |
-
<block type="core/template" name="optimizely_sidewide" as="optimizely_sidewide"
|
21 |
-
template="blueacorn/optimizely/sitewideJs.phtml"/>
|
22 |
</block>
|
23 |
</reference>
|
24 |
</default>
|
25 |
-
</layout>
|
2 |
<!--
|
3 |
/**
|
4 |
* This is the layout xml file for BlueAcorn Optimizely. It creates two
|
5 |
+
* blocks within a text_list block that output the sitewide Optimizely script
|
6 |
* and the page specific targeting variables.
|
7 |
*
|
8 |
+
* @package BlueAcorn\Optimizely
|
9 |
+
* @version 1.1.0
|
10 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
11 |
+
* @copyright Blue Acorn, Inc. 2014
|
12 |
*/
|
|
|
13 |
-->
|
14 |
+
<layout>
|
15 |
<default>
|
16 |
<reference name="head">
|
17 |
+
<block type="core/text_list" name="optimizely_head" as="optimizely_head">
|
18 |
+
<block type="blueacorn_optimizely/customVariables" name="optimizely_customer_type" as="optimizely_customer_type"/>
|
19 |
+
<block type="blueacorn_optimizely/sitewideJs" name="optimizely_sidewide" as="optimizely_sidewide"/>
|
|
|
|
|
|
|
20 |
</block>
|
21 |
</reference>
|
22 |
</default>
|
23 |
+
</layout>
|
app/design/frontend/base/default/template/blueacorn/optimizely/customVariables.phtml
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package BlueAcorn
|
4 |
-
* @subpackage Optimizely
|
5 |
-
* @version 1.0.1
|
6 |
-
* @author James Bruner
|
7 |
-
*/
|
8 |
-
|
9 |
-
$helper = Mage::helper('optimizely');
|
10 |
-
|
11 |
-
if($helper->isEnabled() == 1) {
|
12 |
-
echo $this->_getCustomVariables();
|
13 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/blueacorn/optimizely/sitewideJs.phtml
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Displays the necessary sitewide Optimizely script in head
|
4 |
-
*
|
5 |
-
* @package BlueAcorn
|
6 |
-
* @subpackage Optimizely
|
7 |
-
* @version 1.0.1
|
8 |
-
* @author James Bruner
|
9 |
-
*/
|
10 |
-
?>
|
11 |
-
<?php
|
12 |
-
$helper = Mage::helper('optimizely');
|
13 |
-
if($helper->isEnabled() == 1) {
|
14 |
-
echo $helper->getOptimizelyProjectCode();
|
15 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/etc/modules/BlueAcorn_Optimizely.xml
CHANGED
@@ -1,13 +1,9 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
<!--
|
3 |
/**
|
4 |
-
*
|
5 |
-
*
|
6 |
-
*
|
7 |
-
*
|
8 |
-
* outputs necessary frontend JavaScript variables (automatic and user selected)
|
9 |
-
* based on Magento attributes. These variables are used in the user's
|
10 |
-
* Convert.com account to set up conversion testing.
|
11 |
*/
|
12 |
-->
|
13 |
<config>
|
@@ -17,4 +13,10 @@
|
|
17 |
<codePool>community</codePool>
|
18 |
</BlueAcorn_Optimizely>
|
19 |
</modules>
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
</config>
|
|
|
1 |
<!--
|
2 |
/**
|
3 |
+
* @package BlueAcorn\Optimizely
|
4 |
+
* @version 1.1.0
|
5 |
+
* @author Blue Acorn, Inc. <code@blueacorn.com>
|
6 |
+
* @copyright Blue Acorn, Inc. 2014
|
|
|
|
|
|
|
7 |
*/
|
8 |
-->
|
9 |
<config>
|
13 |
<codePool>community</codePool>
|
14 |
</BlueAcorn_Optimizely>
|
15 |
</modules>
|
16 |
+
<modules>
|
17 |
+
<BlueAcorn_MiniGrid>
|
18 |
+
<active>true</active>
|
19 |
+
<codePool>community</codePool>
|
20 |
+
</BlueAcorn_MiniGrid>
|
21 |
+
</modules>
|
22 |
</config>
|
app/locale/en_US/BlueAcorn_Optimizely.csv
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"Optimizely","Optimizely"
|
2 |
+
"General Settings","General Settings"
|
3 |
+
"Login or Signup","Login or Signup"
|
4 |
+
"Enabled","Enabled"
|
5 |
+
"Optimizely Project Code","Optimizely Project Code"
|
6 |
+
"Enable Revenue Tracking","Enable Revenue Tracking"
|
7 |
+
"Custom Variables","Custom Variables"
|
8 |
+
"What are Product Settings?","What are Product Settings?"
|
9 |
+
"Please enter your Optimizely script here. Your Project Code is located on the Dashboard in your Optimizely.com account.","Please enter your Optimizely script here. Your Project Code is located on the Dashboard in your <a href=""http://www.optimizely.com"" target=""_blank"">Optimizely.com</a> account."
|
10 |
+
"Optimizely Login/Signup","Optimizely Login/Signup"
|
11 |
+
"These are for additional attributes you can set for product pages. These attributes will be included in your Optimizely custom variable and be available for page targeting.","These are for additional attributes you can set for product pages. These attributes will be included in your Optimizely custom variable and be available for page targeting."
|
12 |
+
"Price, Product Type, Name, and SKU are not available to select as these attributes will automatically be added for every product.","Price, Product Type, Name, and SKU are not available to select as these attributes will automatically be added for every product."
|
13 |
+
"You have not enabled the Optimizely Extension. No data will appear on the frontend. Please enable to activate frontend JavaScript output.","You have not enabled the Optimizely Extension. No data will appear on the frontend. Please enable to activate frontend JavaScript output."
|
package.xml
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Blue_Acorn_Optimizely</name>
|
4 |
-
<version>1.0
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/gpl-license.php">GNU General Public License (GPL)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Optimizely by Blue Acorn is an easy-integration module that outputs the necessary frontend JavaScript used by Optimizely to perform conversion tests. Track engagement, clicks, conversions, sign ups, or anything else that matter to you and your business.</summary>
|
10 |
-
<description>Optimizely by Blue Acorn is an easy-integration module that outputs the necessary frontend JavaScript used by Optimizely to perform conversion tests. Track engagement, clicks, conversions, sign ups, or anything else that matter to you and your business. Optimizely's custom goal tracking provides an endless range of measurable actions that you can define. Just tell Optimizely what to measure, and we will do the rest. With the Optimizely by Blue Acorn module, tracking your revenue, conversion testing, and custom targeting is just a click away. Say goodbye
|
11 |
<notes>Stable release. Has been tested for bugs, compatibility, and performance on Magento Community Edition 1.6+ and Magento Enterprise Edition 1.11+. This extension has been tested in a live environment, but as always please leave feedback if you run into any issues.
|
12 |

|
13 |
-
Updated in this version: new support for Optimizely custom tags! Now any page tags available through the Magento module will appear as custom tags in your Optimizely experiment settings!</notes>
|
14 |
-
<authors><author><name>
|
15 |
-
<date>
|
16 |
-
<time>
|
17 |
-
<contents><target name="magecommunity"><dir name="BlueAcorn"><dir name="Optimizely"><dir name="Block"><file name="CustomVariables.php" hash="
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.1.0</min><max>5.4.13</max></php></required></dependencies>
|
20 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Blue_Acorn_Optimizely</name>
|
4 |
+
<version>1.1.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/gpl-license.php">GNU General Public License (GPL)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Optimizely by Blue Acorn is an easy-integration module that outputs the necessary frontend JavaScript used by Optimizely to perform conversion tests. Track engagement, clicks, conversions, sign ups, or anything else that matter to you and your business.</summary>
|
10 |
+
<description>Optimizely by Blue Acorn is an easy-integration module that outputs the necessary frontend JavaScript used by Optimizely to perform conversion tests. Track engagement, clicks, conversions, sign ups, or anything else that matter to you and your business. Optimizely's custom goal tracking provides an endless range of measurable actions that you can define. Just tell Optimizely what to measure, and we will do the rest. With the Optimizely by Blue Acorn module, tracking your revenue, conversion testing, and custom targeting is just a click away. Say goodbye to technical bottlenecks and hello to actionable data!</description>
|
11 |
<notes>Stable release. Has been tested for bugs, compatibility, and performance on Magento Community Edition 1.6+ and Magento Enterprise Edition 1.11+. This extension has been tested in a live environment, but as always please leave feedback if you run into any issues.
|
12 |

|
13 |
+
Updated in this version: improved code and new support for Optimizely custom tags! Now any page tags available through the Magento module will appear as custom tags in your Optimizely experiment settings!</notes>
|
14 |
+
<authors><author><name>Blue Acorn, Inc.</name><user>blueacorn</user><email>code@blueacorn.com</email></author></authors>
|
15 |
+
<date>2014-03-18</date>
|
16 |
+
<time>21:08:13</time>
|
17 |
+
<contents><target name="magecommunity"><dir name="BlueAcorn"><dir name="Optimizely"><dir name="Block"><file name="CustomVariables.php" hash="208670ebb8f03a5469d61d6a49bd0cc9"/><file name="Head.php" hash="48530033124fb2d284628e7f3a019e85"/><file name="SitewideJs.php" hash="cf397bd340bff0d5c03e6dab0370a7ff"/><dir name="System"><dir name="Config"><file name="Explanation.php" hash="f8c185b93238349139de9449cb53340a"/><file name="Loginlink.php" hash="9748ae0bd9e2c68664213afcb0bcdb35"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="2bc9f0a8aafb89400463c38f93c3174b"/></dir><dir name="Model"><file name="Enabledcheck.php" hash="08edd2def60bcd8fd5d4ccc1b5ce6dd4"/><file name="Projectcode.php" hash="6c10982a14498883dba6afcc0738270d"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Attribute.php" hash="d150176869a9f8b5ba1f4a4fc48e35ee"/><dir name="Minigrid"><file name="Attribute.php" hash="1a68edc6f44e5ad7c2fd1593cc00c257"/></dir></dir></dir></dir></dir><dir name="data"><dir name="blueacorn_optimizely_setup"><file name="data-upgrade-1.0.2-1.1.0.php" hash="4cae64c0bf75b7e21d587f520ae66d5f"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="ded90dc9c4a7b3485f7a3a5ba72c5d8c"/><file name="config.xml" hash="678e7b50f53be948027afe5c495346e3"/><file name="system.xml" hash="bcf0542092984295c99c5e97f9e11cda"/></dir><dir name="sql"><dir name="blueacorn_optimizely_setup"><file name="install-1.0.2.php" hash="00424add4fcc219ae7982bc2232636d4"/></dir></dir></dir><dir name="MiniGrid"><dir name="Block"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><dir name="Minigrid"><file name="Js.php" hash="df2d35664d20312d67bff903ddba6ac7"/></dir><file name="Minigrid.php" hash="d6519a5e28225218edd339819e09010a"/></dir></dir><file name="Form.php" hash="c6e478cccdc06ee94666e50654bddb75"/></dir></dir><dir name="Widget"><dir name="Minigrid"><file name="Form.php" hash="79bcc4ce1ba203939990149b8c57c5ff"/></dir></dir></dir><dir name="Model"><dir name="System"><dir name="Config"><dir name="Backend"><file name="Minigrid.php" hash="7798ddce7fa65b2a0070a5e0929827d9"/></dir><dir name="Source"><dir name="Minigrid"><file name="Abstract.php" hash="e3f9462cd90a689b61b918485bc6b08f"/></dir></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="973b69f9dd7b9d11a5ea2a671f3b3a20"/></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="BlueAcorn_Optimizely.csv" hash="a29c8d8c5e1eff8663d03b9a28b68d9d"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="blueacorn"><file name="optimizely.xml" hash="955b636e087b4cc4be8107a03303a909"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="BlueAcorn_Optimizely.xml" hash="0cc497da2dfda65336182266a3c0a645"/></dir></target></contents>
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.1.0</min><max>5.4.13</max></php></required></dependencies>
|
20 |
</package>
|