Version Notes
Solved a problem with catalog retrieval in Magento version 1.4.x
Download this release
Release Info
Developer | Magento Core Team |
Extension | Brainsins_Recommender |
Version | 1.4.7 |
Comparing to | |
See all releases |
Version 1.4.7
- app/code/community/Brainsins/.DS_Store +0 -0
- app/code/community/Brainsins/Recsins/.DS_Store +0 -0
- app/code/community/Brainsins/Recsins/Block/.DS_Store +0 -0
- app/code/community/Brainsins/Recsins/Block/.LCKRecsins.php~ +1 -0
- app/code/community/Brainsins/Recsins/Block/Adminhtml/.DS_Store +0 -0
- app/code/community/Brainsins/Recsins/Block/Adminhtml/Recsins.php +57 -0
- app/code/community/Brainsins/Recsins/Block/Adminhtml/Recsins/.DS_Store +0 -0
- app/code/community/Brainsins/Recsins/Block/Adminhtml/Recsins/Edit.php +45 -0
- app/code/community/Brainsins/Recsins/Block/Adminhtml/Recsins/Edit/.DS_Store +0 -0
- app/code/community/Brainsins/Recsins/Block/Adminhtml/Recsins/Edit/Form.php +636 -0
- app/code/community/Brainsins/Recsins/Block/Adminhtml/Recsins/Edit/Tab/.DS_Store +0 -0
- app/code/community/Brainsins/Recsins/Block/Adminhtml/Recsins/Edit/Tab/Form.php +80 -0
- app/code/community/Brainsins/Recsins/Block/Adminhtml/Recsins/Edit/Tabs.php +48 -0
- app/code/community/Brainsins/Recsins/Block/Adminhtml/Recsins/Grid.php +116 -0
- app/code/community/Brainsins/Recsins/Block/Category.php +37 -0
- app/code/community/Brainsins/Recsins/Block/Checkout.php +30 -0
- app/code/community/Brainsins/Recsins/Block/Home.php +36 -0
- app/code/community/Brainsins/Recsins/Block/Product.php +37 -0
- app/code/community/Brainsins/Recsins/Block/Recsins.php +431 -0
- app/code/community/Brainsins/Recsins/COPYING.txt +674 -0
- app/code/community/Brainsins/Recsins/Entity/.DS_Store +0 -0
- app/code/community/Brainsins/Recsins/Entity/Setup.php +29 -0
- app/code/community/Brainsins/Recsins/Helper/.DS_Store +0 -0
- app/code/community/Brainsins/Recsins/Helper/Data.php +30 -0
- app/code/community/Brainsins/Recsins/Helper/Recsins.php +64 -0
- app/code/community/Brainsins/Recsins/Model/.DS_Store +0 -0
- app/code/community/Brainsins/Recsins/Model/Api/.DS_Store +0 -0
- app/code/community/Brainsins/Recsins/Model/Api/Api.php +286 -0
- app/code/community/Brainsins/Recsins/Model/Api/ProductsApi.php +186 -0
- app/code/community/Brainsins/Recsins/Model/Cart.php +31 -0
- app/code/community/Brainsins/Recsins/Model/CartProduct.php +31 -0
- app/code/community/Brainsins/Recsins/Model/Client.php +591 -0
- app/code/community/Brainsins/Recsins/Model/Mysql4/Recsins.php +34 -0
- app/code/community/Brainsins/Recsins/Model/Mysql4/Recsins/Collection.php +34 -0
- app/code/community/Brainsins/Recsins/Model/NewFile.xml +1 -0
- app/code/community/Brainsins/Recsins/Model/Observer.php +116 -0
- app/code/community/Brainsins/Recsins/Model/Order.php +32 -0
- app/code/community/Brainsins/Recsins/Model/OrderProduct.php +32 -0
- app/code/community/Brainsins/Recsins/Model/Product.php +31 -0
- app/code/community/Brainsins/Recsins/Model/Recommender.php +66 -0
- app/code/community/Brainsins/Recsins/Model/Recsins.php +651 -0
- app/code/community/Brainsins/Recsins/Model/Recsins_1.php +569 -0
- app/code/community/Brainsins/Recsins/Model/Resource/Eav/Mysql4/Recommender.php +34 -0
- app/code/community/Brainsins/Recsins/Model/Resource/Eav/Mysql4/Recommender/Collection.php +32 -0
- app/code/community/Brainsins/Recsins/Model/Resource/Setup.php +29 -0
- app/code/community/Brainsins/Recsins/Model/Status.php +39 -0
- app/code/community/Brainsins/Recsins/Model/User.php +35 -0
- app/code/community/Brainsins/Recsins/brainsins.js.js +2 -0
- app/code/community/Brainsins/Recsins/controllers/.DS_Store +0 -0
- app/code/community/Brainsins/Recsins/controllers/Adminhtml/.DS_Store +0 -0
- app/code/community/Brainsins/Recsins/controllers/Adminhtml/RecsinsController.php +697 -0
- app/code/community/Brainsins/Recsins/controllers/IndexController.php +45 -0
- app/code/community/Brainsins/Recsins/etc/.DS_Store +0 -0
- app/code/community/Brainsins/Recsins/etc/api.xml +69 -0
- app/code/community/Brainsins/Recsins/etc/config.xml +254 -0
- app/code/community/Brainsins/Recsins/etc/widget.xml +31 -0
- app/code/community/Brainsins/Recsins/sql/.DS_Store +0 -0
- app/code/community/Brainsins/Recsins/sql/recsins_setup/.DS_Store +0 -0
- app/code/community/Brainsins/Recsins/sql/recsins_setup/mysql4-install-1.4.0.php +47 -0
- app/code/community/Brainsins/Recsins/sql/recsins_setup/mysql4-upgrade-1.4.0-1.4.1.php +47 -0
- app/code/community/Brainsins/Recsins/sql/recsins_setup/mysql4-upgrade-1.4.1-1.4.2.php +47 -0
- app/code/community/Brainsins/Recsins/sql/recsins_setup/mysql4-upgrade-1.4.2-1.4.3.php +47 -0
- app/code/community/Brainsins/Recsins/sql/recsins_setup/mysql4-upgrade-1.4.3-1.4.4.php +47 -0
- app/code/community/Brainsins/Recsins/sql/recsins_setup/mysql4-upgrade-1.4.4-1.4.5.php +47 -0
- app/code/community/Brainsins/Recsins/sql/recsins_setup/mysql4-upgrade-1.4.5-1.4.6.php +47 -0
- app/code/community/Brainsins/Recsins/sql/recsins_setup/mysql4-upgrade-1.4.6-1.4.7.php +47 -0
- app/design/adminhtml/default/default/layout/recsins.xml +32 -0
- app/design/frontend/base/default/layout/recsins.xml +57 -0
- app/design/frontend/base/default/template/recsins/.DS_Store +0 -0
- app/design/frontend/base/default/template/recsins/cart.phtml +1 -0
- app/design/frontend/base/default/template/recsins/category.phtml +1 -0
- app/design/frontend/base/default/template/recsins/product.phtml +1 -0
- app/design/frontend/base/default/template/recsins/recsins.phtml +0 -0
- app/etc/modules/Brainsins_Recsins.xml +33 -0
- app/locale/en_US/Brainsins_Recsins.csv +52 -0
- app/locale/es_ES/Brainsins_Recsins.csv +52 -0
- package.xml +29 -0
app/code/community/Brainsins/.DS_Store
ADDED
Binary file
|
app/code/community/Brainsins/Recsins/.DS_Store
ADDED
Binary file
|
app/code/community/Brainsins/Recsins/Block/.DS_Store
ADDED
Binary file
|
app/code/community/Brainsins/Recsins/Block/.LCKRecsins.php~
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
/Applications/MAMP/htdocs/Magento-Entity/Brainsins_Recsins/app/code/community/Brainsins/Recsins/Block/Recsins.php
|
app/code/community/Brainsins/Recsins/Block/Adminhtml/.DS_Store
ADDED
Binary file
|
app/code/community/Brainsins/Recsins/Block/Adminhtml/Recsins.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Block_Adminhtml_Recsins extends Mage_Adminhtml_Block_Widget_Form_Container {//extends Mage_Adminhtml_Block_Widget_Grid_Container {
|
28 |
+
|
29 |
+
public function __construct()
|
30 |
+
{
|
31 |
+
$this->_controller = 'adminhtml_recsins';
|
32 |
+
$this->_blockGroup = 'recsins';
|
33 |
+
$this->_headerText = Mage::helper('recsins')->__('Configuration');
|
34 |
+
$this->_addButtonLabel = Mage::helper('recsins')->__('Add Item');
|
35 |
+
parent::__construct();
|
36 |
+
}
|
37 |
+
|
38 |
+
protected function _prepareForm()
|
39 |
+
{
|
40 |
+
$form = new Varien_Data_Form(array(
|
41 |
+
'id' => 'edit_form',
|
42 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
43 |
+
'method' => 'post',
|
44 |
+
'enctype' => 'multipart/form-data'
|
45 |
+
)
|
46 |
+
);
|
47 |
+
|
48 |
+
$form->setUseContainer(true);
|
49 |
+
$this->setForm($form);
|
50 |
+
return parent::_prepareForm();
|
51 |
+
}
|
52 |
+
|
53 |
+
public function _loadCache() {
|
54 |
+
//always force to reload cache
|
55 |
+
return false;
|
56 |
+
}
|
57 |
+
}
|
app/code/community/Brainsins/Recsins/Block/Adminhtml/Recsins/.DS_Store
ADDED
Binary file
|
app/code/community/Brainsins/Recsins/Block/Adminhtml/Recsins/Edit.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Brainsins_Recsins_Block_Adminhtml_Recsins_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
|
9 |
+
$this->_objectId = 'id';
|
10 |
+
$this->_blockGroup = 'recsins';
|
11 |
+
$this->_controller = 'adminhtml_recsins';
|
12 |
+
|
13 |
+
$this->_updateButton('save', 'label', Mage::helper('recsins')->__('Save Item'));
|
14 |
+
$this->_updateButton('delete', 'label', Mage::helper('recsins')->__('Delete Item'));
|
15 |
+
|
16 |
+
$this->_addButton('saveandcontinue', array(
|
17 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
18 |
+
'onclick' => 'saveAndContinueEdit()',
|
19 |
+
'class' => 'save',
|
20 |
+
), -100);
|
21 |
+
|
22 |
+
$this->_formScripts[] = "
|
23 |
+
function toggleEditor() {
|
24 |
+
if (tinyMCE.getInstanceById('recsins_content') == null) {
|
25 |
+
tinyMCE.execCommand('mceAddControl', false, 'recsins_content');
|
26 |
+
} else {
|
27 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'recsins_content');
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
function saveAndContinueEdit(){
|
32 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
33 |
+
}
|
34 |
+
";
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getHeaderText()
|
38 |
+
{
|
39 |
+
if( Mage::registry('recsins_data') && Mage::registry('recsins_data')->getId() ) {
|
40 |
+
return Mage::helper('recsins')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('recsins_data')->getTitle()));
|
41 |
+
} else {
|
42 |
+
return Mage::helper('recsins')->__('Add Item');
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
app/code/community/Brainsins/Recsins/Block/Adminhtml/Recsins/Edit/.DS_Store
ADDED
Binary file
|
app/code/community/Brainsins/Recsins/Block/Adminhtml/Recsins/Edit/Form.php
ADDED
@@ -0,0 +1,636 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
final class BS_Radios extends Varien_Data_Form_Element_Radios {
|
28 |
+
|
29 |
+
public function __construct($attributes=array()) {
|
30 |
+
parent::__construct($attributes);
|
31 |
+
}
|
32 |
+
|
33 |
+
protected function _optionToHtml($option, $selected) {
|
34 |
+
$html = '<input type="radio"' . $this->serialize(array('name', 'class', 'style'));
|
35 |
+
if (is_array($option)) {
|
36 |
+
$html.= 'value="' . $this->_escape($option['value']) . '" id="' . $this->getHtmlId() . $option['value'] . '"';
|
37 |
+
if ($option['value'] == $selected) {
|
38 |
+
$html.= ' checked="checked"';
|
39 |
+
}
|
40 |
+
$html.= ' />';
|
41 |
+
$html.= '<label class="inline" for="' . $this->getHtmlId() . $option['value'] . '">' . $option['label'] . '</label>';
|
42 |
+
} elseif ($option instanceof Varien_Object && $selected) {
|
43 |
+
$html.= 'id="' . $this->getHtmlId() . $option->getValue() . '"' . $option->serialize(array('label', 'title', 'value', 'class', 'style'));
|
44 |
+
if (in_array($option->getValue(), $selected)) {
|
45 |
+
$html.= ' checked="checked"';
|
46 |
+
}
|
47 |
+
$html.= ' />';
|
48 |
+
$html.= '<label style = "margin-left:10px" class="inline" for="' . $this->getHtmlId() . $option->getValue() . '">' . $option->getLabel() . '</label>';
|
49 |
+
} else {
|
50 |
+
$html.= 'id="' . $this->getHtmlId() . $option->getValue() . '"' . $option->serialize(array('label', 'title', 'value', 'class', 'style'));
|
51 |
+
$html.= ' />';
|
52 |
+
$html.= '<label style = "margin-left:10px" class="inline" for="' . $this->getHtmlId() . $option->getValue() . '">' . $option->getLabel() . '</label>';
|
53 |
+
}
|
54 |
+
if ($option['additional_text']) {
|
55 |
+
$html .= $option['additional_text'];
|
56 |
+
}
|
57 |
+
$html.= $this->getSeparator() . "\n";
|
58 |
+
return $html;
|
59 |
+
}
|
60 |
+
|
61 |
+
}
|
62 |
+
|
63 |
+
final class BS_Form extends Varien_Data_Form {
|
64 |
+
|
65 |
+
private $_extraHtml = "";
|
66 |
+
|
67 |
+
public function __construct($attributes=array()) {
|
68 |
+
parent::__construct($attributes);
|
69 |
+
}
|
70 |
+
|
71 |
+
public function toHtml() {
|
72 |
+
|
73 |
+
return parent::toHtml() . $this->_extraHtml;
|
74 |
+
}
|
75 |
+
|
76 |
+
public function setExtraHtml($html) {
|
77 |
+
$this->_extraHtml = $html;
|
78 |
+
}
|
79 |
+
|
80 |
+
}
|
81 |
+
|
82 |
+
class Brainsins_Recsins_Block_Adminhtml_Recsins_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
|
83 |
+
|
84 |
+
//private $dev = true;
|
85 |
+
private $dev = false;
|
86 |
+
|
87 |
+
protected function _prepareForm() {
|
88 |
+
|
89 |
+
Mage::getConfig()->cleanCache();
|
90 |
+
|
91 |
+
$linkBaseUrl;
|
92 |
+
|
93 |
+
if ($this->dev) {
|
94 |
+
$linkBaseUrl = "http://dev-analytics.brainsins.com";
|
95 |
+
} else {
|
96 |
+
$linkBaseUrl = "http://analytics.brainsins.com";
|
97 |
+
}
|
98 |
+
|
99 |
+
$form = new BS_Form(array(
|
100 |
+
'id' => 'edit_form',
|
101 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
102 |
+
'method' => 'post',
|
103 |
+
'enctype' => 'multipart/form-data'
|
104 |
+
)
|
105 |
+
);
|
106 |
+
|
107 |
+
$uploading = Mage::getSingleton("core/session", array("name" => "adminhtml"))->getData('brainsins_UPLOADING_STATUS');
|
108 |
+
|
109 |
+
if (isset($uploading) && $uploading == '1') {
|
110 |
+
|
111 |
+
$continueUploadScript = "
|
112 |
+
<script type='text/javascript'>
|
113 |
+
try{
|
114 |
+
var upload_catalog = document.getElementById('upload_catalog');
|
115 |
+
var edit_form = document.getElementById('edit_form');
|
116 |
+
if (upload_catalog.value != 'abort') {
|
117 |
+
upload_catalog.value = 'uploading';
|
118 |
+
}
|
119 |
+
edit_form.submit();
|
120 |
+
} catch (e){};
|
121 |
+
</script>
|
122 |
+
";
|
123 |
+
|
124 |
+
//$form->setExtraHtml($continueUploadScript);
|
125 |
+
}
|
126 |
+
|
127 |
+
$data = $this->getRequest()->getPost();
|
128 |
+
|
129 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
130 |
+
$key = $key ? $key : '';
|
131 |
+
|
132 |
+
|
133 |
+
// print some non-visible html code to the page
|
134 |
+
|
135 |
+
|
136 |
+
$js = "<script type='text/javascript'>" . PHP_EOL;
|
137 |
+
$js .= "function bsImportConfig(){" . PHP_EOL;
|
138 |
+
$js .= "var import_config = document.getElementById('import_config');" . PHP_EOL;
|
139 |
+
$js .= "var edit_form = document.getElementById('edit_form');" . PHP_EOL;
|
140 |
+
$js .= "import_config.value = '1';" . PHP_EOL;
|
141 |
+
$js .= "edit_form.submit();" . PHP_EOL;
|
142 |
+
$js .= "}" . PHP_EOL;
|
143 |
+
$js .= "function bsUploadCatalog(){" . PHP_EOL;
|
144 |
+
$js .= "var upload_catalog = document.getElementById('upload_catalog');" . PHP_EOL;
|
145 |
+
$js .= "var edit_form = document.getElementById('edit_form');" . PHP_EOL;
|
146 |
+
$js .= "upload_catalog.value = 'upload';" . PHP_EOL;
|
147 |
+
$js .= "edit_form.submit();" . PHP_EOL;
|
148 |
+
$js .= "}" . PHP_EOL;
|
149 |
+
$js .= "function bsUploadingCatalog(){" . PHP_EOL;
|
150 |
+
$js .= "var upload_catalog = document.getElementById('upload_catalog');" . PHP_EOL;
|
151 |
+
$js .= "var edit_form = document.getElementById('edit_form');" . PHP_EOL;
|
152 |
+
$js .= "upload_catalog.value = 'uploading';" . PHP_EOL;
|
153 |
+
$js .= "edit_form.submit();" . PHP_EOL;
|
154 |
+
$js .= "}" . PHP_EOL;
|
155 |
+
$js .= "function bsAbortCatalogUpload(){" . PHP_EOL;
|
156 |
+
$js .= "var upload_catalog = document.getElementById('upload_catalog');" . PHP_EOL;
|
157 |
+
$js .= "var edit_form = document.getElementById('edit_form');" . PHP_EOL;
|
158 |
+
$js .= "upload_catalog.value = 'abort';" . PHP_EOL;
|
159 |
+
$js .= "edit_form.submit();" . PHP_EOL;
|
160 |
+
$js .= "}" . PHP_EOL;
|
161 |
+
$js.= "</script>" . PHP_EOL;
|
162 |
+
echo($js);
|
163 |
+
|
164 |
+
$style = "<style>";
|
165 |
+
$style .= ".entry-edit .field-row label {width: 250px;}";
|
166 |
+
|
167 |
+
$style .= "</style>";
|
168 |
+
echo($style);
|
169 |
+
|
170 |
+
// create form elements
|
171 |
+
|
172 |
+
$clientsLinkUrl = "javascript:window.open('" . $linkBaseUrl . "/settings/accountinfo')";
|
173 |
+
$nonClientsLinkUrl = "javascript:window.open('http://www.brainsins.es/tarifas')";
|
174 |
+
|
175 |
+
|
176 |
+
$form->setUseContainer(true);
|
177 |
+
$helper = $this->helper("recsins");
|
178 |
+
|
179 |
+
$text = new Varien_Data_Form_Element_Text(array('name' => 'bskey_text'));
|
180 |
+
$text->setId('bskey_text');
|
181 |
+
$text->setValue($key);
|
182 |
+
|
183 |
+
$keyQuestion = new Varien_Data_Form_Element_Label(array('value' => $helper->__('Do not have a BrainSINS KEY?')));
|
184 |
+
$clientsLink = new Varien_Data_Form_Element_Link(array('value' => $helper->__('I am a BrainSINS client'), 'href' => $clientsLinkUrl, 'style' => 'padding-left:20px;'));
|
185 |
+
$nonClientsLink = new Varien_Data_Form_Element_Link(array('value' => $helper->__('I am not a BrainSINS client yet'), 'href' => $nonClientsLinkUrl, 'style' => 'padding-left:20px;'));
|
186 |
+
|
187 |
+
|
188 |
+
$enabledValue = Mage::getStoreConfig('brainsins/BS_ENABLED');
|
189 |
+
|
190 |
+
if (!$enabledValue && $enabledValue !== '0') {
|
191 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_ENABLED', '1');
|
192 |
+
$enabledValue = '1';
|
193 |
+
}
|
194 |
+
|
195 |
+
$enabledOptions = new BS_Radios(array('id' => 'bsenableoptions', 'name' => 'bsenableoptions', 'separator' => '<br><br>'));
|
196 |
+
$enabledOption = new Varien_Data_Form_Element_Radio(array('id' => 'bsenabledoption', 'name' => 'bsenabledoption', 'label' => $helper->__("Enabled"), 'value' => '1'));
|
197 |
+
$disabledOption = new Varien_Data_Form_Element_Radio(array('id' => 'bsdisabledoption', 'name' => 'bsdisabledoption', 'label' => $helper->__("Disabled"), 'value' => '0'));
|
198 |
+
|
199 |
+
if ($enabledValue === '1') {
|
200 |
+
$enabledOptions->setValue(array('1'));
|
201 |
+
} else {
|
202 |
+
$enabledOptions->setValue(array('0'));
|
203 |
+
}
|
204 |
+
|
205 |
+
$enabledOptions->setValues(array($enabledOption, $disabledOption));
|
206 |
+
|
207 |
+
|
208 |
+
|
209 |
+
$keyFieldSet = new Varien_Data_Form_Element_Fieldset(array('name' => 'bskeyfs'));
|
210 |
+
$keyFieldSet->setId('bskeyfs');
|
211 |
+
$keyFieldSet->addElement(new Varien_Data_Form_Element_Label(array('value' => $helper->__('BrainSINS KEY'), 'bold' => true)));
|
212 |
+
$keyFieldSet->addElement($text);
|
213 |
+
$keyFieldSet->addElement($keyQuestion);
|
214 |
+
$keyFieldSet->addElement($clientsLink);
|
215 |
+
$keyFieldSet->addElement($nonClientsLink);
|
216 |
+
|
217 |
+
$enableFieldSet = new Varien_Data_Form_Element_Fieldset(array('name' => 'bsenablefs'));
|
218 |
+
$enableFieldSet->setId('bsenablefs');
|
219 |
+
$enableFieldSet->addElement(new Varien_Data_Form_Element_Label(array('value' => $helper->__('Enable / Disable Extension'), 'bold' => true)));
|
220 |
+
$enableFieldSet->addElement($enabledOptions);
|
221 |
+
|
222 |
+
|
223 |
+
$model = Mage::getModel('recsins/recommender');
|
224 |
+
$entries = $model->getAllRecommenders();
|
225 |
+
$defaultText = $helper->__("Do not show");
|
226 |
+
|
227 |
+
$defaultHomeOption = new Varien_Data_Form_Element_Radio();
|
228 |
+
$defaultHomeOption->setLabel($defaultText);
|
229 |
+
$defaultHomeOption->setValue(0);
|
230 |
+
|
231 |
+
$defaultCategoryOption = new Varien_Data_Form_Element_Radio();
|
232 |
+
$defaultCategoryOption->setLabel($defaultText);
|
233 |
+
$defaultCategoryOption->setValue(0);
|
234 |
+
|
235 |
+
$defaultProductOption = new Varien_Data_Form_Element_Radio();
|
236 |
+
$defaultProductOption->setLabel($defaultText);
|
237 |
+
$defaultProductOption->setValue(0);
|
238 |
+
|
239 |
+
$defaultCartOption = new Varien_Data_Form_Element_Radio();
|
240 |
+
$defaultCartOption->setLabel($defaultText);
|
241 |
+
$defaultCartOption->setValue(0);
|
242 |
+
|
243 |
+
$defaultCheckoutOption = new Varien_Data_Form_Element_Radio();
|
244 |
+
$defaultCheckoutOption->setLabel($defaultText);
|
245 |
+
$defaultCheckoutOption->setValue(0);
|
246 |
+
|
247 |
+
|
248 |
+
$homeRadioOptions = array();
|
249 |
+
$categoryRadioOptions = array();
|
250 |
+
$productRadioOptions = array();
|
251 |
+
$cartRadioOptions = array();
|
252 |
+
$checkoutRadioOptions = array();
|
253 |
+
|
254 |
+
$homeRadioOptions[] = $defaultHomeOption;
|
255 |
+
$categoryRadioOptions[] = $defaultHomeOption;
|
256 |
+
$productRadioOptions[] = $defaultProductOption;
|
257 |
+
$cartRadioOptions[] = $defaultCartOption;
|
258 |
+
$checkoutRadioOptions[] = $defaultCheckoutOption;
|
259 |
+
|
260 |
+
$homeSelected = Mage::getStoreConfig('brainsins/BS_HOME_RECOMMENDER');
|
261 |
+
$categorySelected = Mage::getStoreConfig('brainsins/BS_CATEGORY_RECOMMENDER');
|
262 |
+
$productSelected = Mage::getStoreConfig('brainsins/BS_PRODUCT_RECOMMENDER');
|
263 |
+
$cartSelected = Mage::getStoreConfig('brainsins/BS_CART_RECOMMENDER');
|
264 |
+
$checkoutSelected = Mage::getStoreConfig('brainsins/BS_CHECKOUT_RECOMMENDER');
|
265 |
+
|
266 |
+
$outOfStockSelected = Mage::getStoreConfig('brainsins/BS_SEND_OUT_OF_STOCK_PRODUCTS');
|
267 |
+
|
268 |
+
|
269 |
+
|
270 |
+
foreach ($entries as $entry) {
|
271 |
+
$id = $entry['id'];
|
272 |
+
$name = $entry['name'];
|
273 |
+
$page = $entry['page'];
|
274 |
+
|
275 |
+
$radio = new Varien_Data_Form_Element_Radio();
|
276 |
+
$radioLink = "javascript:window.open(\"" . $linkBaseUrl . "/settings/editrecommenderstyle?idRecommender=" . $id . "\")";
|
277 |
+
$radio->setLabel($name);
|
278 |
+
$radio->setValue($id);
|
279 |
+
$radio->setAdditional_text("<input type='button' onclick='" . $radioLink . "' value='" . $helper->__("Edit Style") . "' style='margin-left:20px'>");
|
280 |
+
|
281 |
+
switch ($page) {
|
282 |
+
case 1:
|
283 |
+
$optionsHome[$id] = $name;
|
284 |
+
$homeRadioOptions[] = $radio;
|
285 |
+
$optionsCategory[$id] = $name;
|
286 |
+
$categoryRadioOptions[] = $radio;
|
287 |
+
break;
|
288 |
+
case 2:
|
289 |
+
$optionsProduct[$id] = $name;
|
290 |
+
$productRadioOptions[] = $radio;
|
291 |
+
break;
|
292 |
+
case 3:
|
293 |
+
$optionsCart[$id] = $name;
|
294 |
+
$cartRadioOptions[] = $radio;
|
295 |
+
break;
|
296 |
+
case 4:
|
297 |
+
$checkoutRadioOptions[] = $radio;
|
298 |
+
$optionsCheckout[$id] = $name;
|
299 |
+
break;
|
300 |
+
}
|
301 |
+
}
|
302 |
+
|
303 |
+
// home
|
304 |
+
|
305 |
+
$homeRecommenders = new BS_Radios(array('name' => 'bshome_recommenders', 'separator' => '<br><br>'));
|
306 |
+
$homeRecommenders->setId('bshome_recommenders');
|
307 |
+
$homeRecommenders->setValues($homeRadioOptions);
|
308 |
+
if ($homeSelected !== null) {
|
309 |
+
$homeRecommenders->setValue(array($homeSelected));
|
310 |
+
} else {
|
311 |
+
$homeRecommenders->setValue(array(0));
|
312 |
+
}
|
313 |
+
|
314 |
+
$homeFieldSet = new Varien_Data_Form_Element_Fieldset(array('name' => 'bshomerecommendersfs'));
|
315 |
+
$homeFieldSet->setId('bshomerecommendersfs');
|
316 |
+
$homeFieldSet->addElement(new Varien_Data_Form_Element_Label(array('value' => $helper->__('Home Page Recommender'), 'bold' => true)));
|
317 |
+
$homeFieldSet->addElement($homeRecommenders);
|
318 |
+
|
319 |
+
|
320 |
+
// category
|
321 |
+
|
322 |
+
$categoryRecommenders = new BS_Radios(array('name' => 'bscategory_recommenders', 'separator' => '<br><br>'));
|
323 |
+
$categoryRecommenders->setId('bscategory_recommenders');
|
324 |
+
$categoryRecommenders->setValues($categoryRadioOptions);
|
325 |
+
if ($categorySelected !== null) {
|
326 |
+
$categoryRecommenders->setValue(array($categorySelected));
|
327 |
+
} else {
|
328 |
+
$categoryRecommenders->setValue(array(0));
|
329 |
+
}
|
330 |
+
|
331 |
+
$categoryFieldSet = new Varien_Data_Form_Element_Fieldset(array('name' => 'bscategoryrecommendersfs'));
|
332 |
+
$categoryFieldSet->setId('bscategoryrecommendersfs');
|
333 |
+
$categoryFieldSet->addElement(new Varien_Data_Form_Element_Label(array('value' => $helper->__('Category Page Recommender'), 'bold' => true)));
|
334 |
+
$categoryFieldSet->addElement($categoryRecommenders);
|
335 |
+
|
336 |
+
// product
|
337 |
+
|
338 |
+
$productRecommenders = new BS_Radios(array('name' => 'bsproduct_recommenders', 'separator' => '<br><br>'));
|
339 |
+
$productRecommenders->setId('bsproduct_recommenders');
|
340 |
+
$productRecommenders->setValues($productRadioOptions);
|
341 |
+
if ($productSelected !== null) {
|
342 |
+
$productRecommenders->setValue(array($productSelected));
|
343 |
+
} else {
|
344 |
+
$productRecommenders->setValue(array(0));
|
345 |
+
}
|
346 |
+
|
347 |
+
$productFieldSet = new Varien_Data_Form_Element_Fieldset(array('name' => 'bsproductrecommendersfs'));
|
348 |
+
$productFieldSet->setId('bsproductrecommendersfs');
|
349 |
+
$productFieldSet->addElement(new Varien_Data_Form_Element_Label(array('value' => $helper->__('Product Page Recommender'), 'bold' => true)));
|
350 |
+
$productFieldSet->addElement($productRecommenders);
|
351 |
+
|
352 |
+
// cart
|
353 |
+
|
354 |
+
$cartRecommenders = new BS_Radios(array('name' => 'bscart_recommenders', 'separator' => '<br><br>'));
|
355 |
+
$cartRecommenders->setId('bscart_recommenders');
|
356 |
+
$cartRecommenders->setValues($cartRadioOptions);
|
357 |
+
if ($cartSelected !== null) {
|
358 |
+
$cartRecommenders->setValue(array($cartSelected));
|
359 |
+
} else {
|
360 |
+
$cartRecommenders->setValue(array(0));
|
361 |
+
}
|
362 |
+
|
363 |
+
$cartFieldSet = new Varien_Data_Form_Element_Fieldset(array('name' => 'bscartrecommendersfs'));
|
364 |
+
$cartFieldSet->setId('bscartrecommendersfs');
|
365 |
+
$cartFieldSet->addElement(new Varien_Data_Form_Element_Label(array('value' => $helper->__('Cart Page Recommender'), 'bold' => true)));
|
366 |
+
$cartFieldSet->addElement($cartRecommenders);
|
367 |
+
|
368 |
+
// checkout
|
369 |
+
|
370 |
+
$checkoutRecommenders = new BS_Radios(array('name' => 'bscheckout_recommenders', 'separator' => '<br><br>'));
|
371 |
+
$checkoutRecommenders->setId('bscheckout_recommenders');
|
372 |
+
$checkoutRecommenders->setValues($checkoutRadioOptions);
|
373 |
+
if ($checkoutSelected !== null) {
|
374 |
+
$checkoutRecommenders->setValue(array($checkoutSelected));
|
375 |
+
} else {
|
376 |
+
$checkoutRecommenders->setValue(array(0));
|
377 |
+
}
|
378 |
+
|
379 |
+
$checkoutFieldSet = new Varien_Data_Form_Element_Fieldset(array('name' => 'bscheckoutrecommendersfs'));
|
380 |
+
$checkoutFieldSet->setId('bscheckoutrecommendersfs');
|
381 |
+
$checkoutFieldSet->addElement(new Varien_Data_Form_Element_Label(array('value' => $helper->__('Checkout Page Recommender'), 'bold' => true)));
|
382 |
+
$checkoutFieldSet->addElement($checkoutRecommenders);
|
383 |
+
|
384 |
+
|
385 |
+
$advancedFieldSet = new Varien_Data_Form_Element_Fieldset(array('name' => 'bsadvancedoptionsfs'));
|
386 |
+
$advancedFieldSet->setId('bsadvancedoptionsfs');
|
387 |
+
$advancedFieldSet->addElement(new Varien_Data_Form_Element_Label(array('value' => $helper->__('Advanced Options'), 'bold' => true)));
|
388 |
+
|
389 |
+
$cautionText = "(" . $helper->__("please do not modify these values unless you are told so by BrainSINS' support team") . ")";
|
390 |
+
|
391 |
+
$advancedFieldSet->addElement(new Varien_Data_Form_Element_Label(array('value' => $cautionText)));
|
392 |
+
$advancedFieldSet->addElement(new Varien_Data_Form_Element_Label(array('value' => $helper->__("Catalog upload page size"), 'bold' => 'true')));
|
393 |
+
|
394 |
+
$radio1 = new Varien_Data_Form_Element_Radio();
|
395 |
+
$radio1->setLabel("1");
|
396 |
+
$radio1->setValue("page1");
|
397 |
+
$radio1->setAdditional_text("");
|
398 |
+
|
399 |
+
$radio10 = new Varien_Data_Form_Element_Radio();
|
400 |
+
$radio10->setLabel("10");
|
401 |
+
$radio10->setValue("page10");
|
402 |
+
$radio10->setAdditional_text("");
|
403 |
+
|
404 |
+
$radio20 = new Varien_Data_Form_Element_Radio();
|
405 |
+
$radio20->setLabel("20");
|
406 |
+
$radio20->setValue("page20");
|
407 |
+
$radio20->setAdditional_text("");
|
408 |
+
|
409 |
+
$radio50 = new Varien_Data_Form_Element_Radio();
|
410 |
+
$radio50->setLabel("50");
|
411 |
+
$radio50->setValue("page50");
|
412 |
+
$radio50->setAdditional_text("");
|
413 |
+
|
414 |
+
$radio100 = new Varien_Data_Form_Element_Radio();
|
415 |
+
$radio100->setLabel("100");
|
416 |
+
$radio100->setValue("page100");
|
417 |
+
$radio100->setAdditional_text("");
|
418 |
+
|
419 |
+
$radio200 = new Varien_Data_Form_Element_Radio();
|
420 |
+
$radio200->setLabel("200");
|
421 |
+
$radio200->setValue("page200");
|
422 |
+
$radio200->setAdditional_text("");
|
423 |
+
|
424 |
+
$advancedOptions = array();
|
425 |
+
$advancedOptions[] = $radio1;
|
426 |
+
$advancedOptions[] = $radio10;
|
427 |
+
$advancedOptions[] = $radio20;
|
428 |
+
$advancedOptions[] = $radio50;
|
429 |
+
$advancedOptions[] = $radio100;
|
430 |
+
$advancedOptions[] = $radio200;
|
431 |
+
|
432 |
+
$advancedRadios = new BS_Radios(array('name' => 'bsadvanced', 'separator' => '<br>'));
|
433 |
+
$advancedRadios->setId("bsadvanced_options");
|
434 |
+
$advancedRadios->setValues($advancedOptions);
|
435 |
+
|
436 |
+
$pageSize = Mage::getStoreConfig('brainsins/BS_PAGE_SIZE');
|
437 |
+
|
438 |
+
if (!isset($pageSize) || !($pageSize != 'page1' || $pageSize != 'page10' || $pageSize != 'page20' || $pageSize != 'page50' || $pageSize != 'page100' || $pageSize != 'page200')) {
|
439 |
+
$pageSize = 'page50';
|
440 |
+
}
|
441 |
+
|
442 |
+
$advancedRadios->setValue(array($pageSize));
|
443 |
+
|
444 |
+
$includeOutOfStockLabel = new Varien_Data_Form_Element_Label(array('value' => $helper->__("Include out of stock products in catalog upload (out of stock products will be recommended)"), 'bold' => 'true'));
|
445 |
+
|
446 |
+
$outOfStockCheckbox = new Varien_Data_Form_Element_Checkbox(array('name' => 'out_of_stock_checkbox'));
|
447 |
+
$outOfStockCheckbox->setId('out_of_stock_checkbox');
|
448 |
+
$outOfStockCheckbox->setValue("checked");
|
449 |
+
if (isset($outOfStockSelected) && $outOfStockSelected != null) {
|
450 |
+
if ($outOfStockSelected == "1") {
|
451 |
+
$outOfStockCheckbox->setIsChecked(true);
|
452 |
+
}
|
453 |
+
} else {
|
454 |
+
$outOfStockCheckbox->setIsChecked(true);
|
455 |
+
}
|
456 |
+
|
457 |
+
$imagesLabel = new Varien_Data_Form_Element_Label(array('value' => $helper->__("Select Image url type"), 'bold' => 'true'));
|
458 |
+
|
459 |
+
$radioNotResize = new Varien_Data_Form_Element_Radio();
|
460 |
+
$radioNotResize->setLabel($helper->__("Default value for product ''small'' image"));
|
461 |
+
$radioNotResize->setValue("image_no_resize");
|
462 |
+
$radioNotResize->setAdditional_text("");
|
463 |
+
|
464 |
+
$radioResize = new Varien_Data_Form_Element_Radio();
|
465 |
+
$radioResize->setLabel($helper->__("Resize product ''small'' image"));
|
466 |
+
$radioResize->setValue("image_resize");
|
467 |
+
$radioResize->setAdditional_text("");
|
468 |
+
|
469 |
+
$imageOptions = array();
|
470 |
+
$imageOptions[] = $radioNotResize;
|
471 |
+
$imageOptions[] = $radioResize;
|
472 |
+
$imageRadios = new BS_Radios(array('name' => 'bsimageoptions', 'separator' => '<br>'));
|
473 |
+
$imageRadios->setId("image_options");
|
474 |
+
$imageRadios->setValues($imageOptions);
|
475 |
+
|
476 |
+
$widthText = new Varien_Data_Form_Element_Text(array('name' => 'image_width_text', "label" => $helper->__('Width')));
|
477 |
+
$heigthText = new Varien_Data_Form_Element_Text(array('name' => 'image_heigth_text', "label" => $helper->__("Heigth")));
|
478 |
+
|
479 |
+
$imageSelectedOption = Mage::getStoreConfig('brainsins/BS_IMAGE_RESIZE');
|
480 |
+
if (!isset($imageSelectedOption) || !($imageSelectedOption == 'image_no_resize' || $imageSelectedOption == 'image_resize')) {
|
481 |
+
$imageSelectedOption = 'image_no_resize';
|
482 |
+
}
|
483 |
+
|
484 |
+
$imageRadios->setValue(array($imageSelectedOption));
|
485 |
+
|
486 |
+
|
487 |
+
$imageSelectedWidth = Mage::getStoreConfig('brainsins/BS_IMAGE_RESIZE_WIDTH');
|
488 |
+
$imageSelectedHeigth = Mage::getStoreConfig('brainsins/BS_IMAGE_RESIZE_HEIGTH');
|
489 |
+
|
490 |
+
if (isset($imageSelectedWidth) && is_numeric($imageSelectedWidth) && $imageSelectedWidth > 0) {
|
491 |
+
$widthText->setValue($imageSelectedWidth);
|
492 |
+
}
|
493 |
+
|
494 |
+
if (isset($imageSelectedHeigth) && is_numeric($imageSelectedHeigth) && $imageSelectedHeigth > 0) {
|
495 |
+
$heigthText->setValue($imageSelectedHeigth);
|
496 |
+
}
|
497 |
+
|
498 |
+
|
499 |
+
$specialPriceLabel = new Varien_Data_Form_Element_Label(array('value' => $helper->__("Upload special price"), 'bold' => 'true'));
|
500 |
+
|
501 |
+
$specialPriceYes = new Varien_Data_Form_Element_Radio();
|
502 |
+
$specialPriceYes->setLabel($helper->__("Yes"));
|
503 |
+
$specialPriceYes->setValue("special_price_yes");
|
504 |
+
$specialPriceYes->setAdditional_text("");
|
505 |
+
|
506 |
+
$specialPriceNo = new Varien_Data_Form_Element_Radio();
|
507 |
+
$specialPriceNo->setLabel($helper->__("No"));
|
508 |
+
$specialPriceNo->setValue("special_price_no");
|
509 |
+
$specialPriceNo->setAdditional_text("");
|
510 |
+
|
511 |
+
$specialPriceOptions = array();
|
512 |
+
$specialPriceOptions[] = $specialPriceYes;
|
513 |
+
$specialPriceOptions[] = $specialPriceNo;
|
514 |
+
$specialPriceRadios = new BS_Radios(array('name' => 'bsspecialpriceoptions', 'separator' => '<br>'));
|
515 |
+
$specialPriceRadios->setId("special_price_options");
|
516 |
+
$specialPriceRadios->setValues($specialPriceOptions);
|
517 |
+
|
518 |
+
$specialPriceSelectedOption = Mage::getStoreConfig('brainsins/BS_USE_SPECIAL_PRICE');
|
519 |
+
if (isset($specialPriceSelectedOption) && $specialPriceSelectedOption == '1') {
|
520 |
+
$specialPriceSelectedOption = 'special_price_yes';
|
521 |
+
} else {
|
522 |
+
$specialPriceSelectedOption = 'special_price_no';
|
523 |
+
}
|
524 |
+
|
525 |
+
$specialPriceRadios->setValue(array($specialPriceSelectedOption));
|
526 |
+
|
527 |
+
$taxPriceLabel = new Varien_Data_Form_Element_Label(array('value' => $helper->__("Tax Prices"), 'bold' => 'true'));
|
528 |
+
|
529 |
+
$taxPriceEqual = new Varien_Data_Form_Element_Radio();
|
530 |
+
$taxPriceEqual->setLabel($helper->__("Display Prices are equal to Catalog Prices"));
|
531 |
+
$taxPriceEqual->setValue("tax_price_equal");
|
532 |
+
$taxPriceEqual->setAdditional_text("");
|
533 |
+
|
534 |
+
$taxPriceInDisplay = new Varien_Data_Form_Element_Radio();
|
535 |
+
$taxPriceInDisplay->setLabel($helper->__("Display Prices include taxes and Catalog Prices do not include taxes"));
|
536 |
+
$taxPriceInDisplay->setValue("tax_price_plus");
|
537 |
+
$taxPriceInDisplay->setAdditional_text("");
|
538 |
+
|
539 |
+
$taxPriceInCatalog = new Varien_Data_Form_Element_Radio();
|
540 |
+
$taxPriceInCatalog->setLabel($helper->__("Display Prices do not include taxes and Catalog Prices include taxes"));
|
541 |
+
$taxPriceInCatalog->setValue("tax_price_minus");
|
542 |
+
$taxPriceInCatalog->setAdditional_text("");
|
543 |
+
|
544 |
+
$taxPriceOptions = array();
|
545 |
+
$taxPriceOptions[] = $taxPriceEqual;
|
546 |
+
$taxPriceOptions[] = $taxPriceInDisplay;
|
547 |
+
$taxPriceOptions[] = $taxPriceInCatalog;
|
548 |
+
|
549 |
+
$taxPriceRadios = new BS_Radios(array('name' => 'bstaxpriceoptions', 'separator' => '<br>'));
|
550 |
+
$taxPriceRadios->setId("tax_price_options");
|
551 |
+
$taxPriceRadios->setValues($taxPriceOptions);
|
552 |
+
|
553 |
+
$taxPriceSelectedOption = Mage::getStoreConfig('brainsins/BS_TAX_PRICE');
|
554 |
+
$taxPriceDisplayOption;
|
555 |
+
if (isset($taxPriceSelectedOption) && ($taxPriceSelectedOption == 'tax_price_equal' || $taxPriceSelectedOption == 'tax_price_plus' || $taxPriceSelectedOption == 'tax_price_minus')) {
|
556 |
+
$taxPriceDisplayOption = $taxPriceSelectedOption;
|
557 |
+
} else {
|
558 |
+
$taxPriceDisplayOption = 'tax_price_equal';
|
559 |
+
}
|
560 |
+
|
561 |
+
$taxPriceRadios->setValue(array($taxPriceDisplayOption));
|
562 |
+
|
563 |
+
$advancedFieldSet->addElement($advancedRadios);
|
564 |
+
$advancedFieldSet->addElement($includeOutOfStockLabel);
|
565 |
+
$advancedFieldSet->addElement($outOfStockCheckbox);
|
566 |
+
$advancedFieldSet->addElement($imagesLabel);
|
567 |
+
$advancedFieldSet->addElement($imageRadios);
|
568 |
+
$advancedFieldSet->addElement($widthText);
|
569 |
+
$advancedFieldSet->addElement($heigthText);
|
570 |
+
$advancedFieldSet->addElement($specialPriceLabel);
|
571 |
+
$advancedFieldSet->addElement($specialPriceRadios);
|
572 |
+
$advancedFieldSet->addElement($taxPriceLabel);
|
573 |
+
$advancedFieldSet->addElement($taxPriceRadios);
|
574 |
+
|
575 |
+
//$advancedFieldSet->addElement($imagesExplainLabel1);
|
576 |
+
//$advancedFieldSet->addElement($imagesExplainLabel2);
|
577 |
+
// buttons
|
578 |
+
|
579 |
+
$hiddenImport = new Varien_Data_Form_Element_Hidden(array('name' => 'import_config'));
|
580 |
+
$hiddenImport->setId("import_config");
|
581 |
+
$hiddenImport->setValue("0");
|
582 |
+
|
583 |
+
$hiddenUpload = new Varien_Data_Form_Element_Hidden(array('name' => 'upload_catalog'));
|
584 |
+
$hiddenUpload->setId("upload_catalog");
|
585 |
+
$hiddenUpload->setValue("0");
|
586 |
+
|
587 |
+
$importButton = new Varien_Data_Form_Element_Button(array('name' => 'import_config_button'));
|
588 |
+
$importButton->setId('import_config_button');
|
589 |
+
$importButton->setValue($helper->__('Import Recommenders'));
|
590 |
+
$importButton->setOnclick("bsImportConfig()");
|
591 |
+
|
592 |
+
$uploadButton = new Varien_Data_Form_Element_Button(array('name' => 'upload_catalog_button'));
|
593 |
+
$uploadButton->setId('upload_catalog_button');
|
594 |
+
$uploadButton->setValue($helper->__('Send Catalog'));
|
595 |
+
$uploadButton->setOnclick("bsUploadCatalog()");
|
596 |
+
|
597 |
+
$abortButton = new Varien_Data_Form_Element_Button(array('name' => 'abort_upload_button'));
|
598 |
+
$abortButton->setId('upload_catalog_button');
|
599 |
+
$abortButton->setValue($helper->__('Abort Catalog Upload'));
|
600 |
+
$abortButton->setOnclick("bsAbortCatalogUpload()");
|
601 |
+
|
602 |
+
$abortButton2 = new Varien_Data_Form_Element_Button(array('name' => 'abort_upload_button2'));
|
603 |
+
$abortButton2->setId('upload_catalog_button2');
|
604 |
+
$abortButton2->setValue($helper->__('Abort Catalog Upload'));
|
605 |
+
$abortButton2->setOnclick("bsAbortCatalogUpload()");
|
606 |
+
|
607 |
+
|
608 |
+
// build the final form
|
609 |
+
|
610 |
+
if (isset($uploading) && $uploading == '1') {
|
611 |
+
$form->addElement($abortButton2);
|
612 |
+
}
|
613 |
+
|
614 |
+
$form->addElement($keyFieldSet);
|
615 |
+
$form->addElement($enableFieldSet);
|
616 |
+
$form->addElement($homeFieldSet);
|
617 |
+
$form->addElement($categoryFieldSet);
|
618 |
+
$form->addElement($productFieldSet);
|
619 |
+
$form->addElement($cartFieldSet);
|
620 |
+
$form->addElement($checkoutFieldSet);
|
621 |
+
$form->addElement($advancedFieldSet);
|
622 |
+
$form->addElement($hiddenImport);
|
623 |
+
//$form->addElement($hiddenUpload);
|
624 |
+
$form->addElement($importButton);
|
625 |
+
|
626 |
+
/*if (isset($uploading) && $uploading == '1') {
|
627 |
+
$form->addElement($abortButton);
|
628 |
+
} else {
|
629 |
+
$form->addElement($uploadButton);
|
630 |
+
}*/
|
631 |
+
$this->setForm($form);
|
632 |
+
|
633 |
+
return $form;
|
634 |
+
}
|
635 |
+
|
636 |
+
}
|
app/code/community/Brainsins/Recsins/Block/Adminhtml/Recsins/Edit/Tab/.DS_Store
ADDED
Binary file
|
app/code/community/Brainsins/Recsins/Block/Adminhtml/Recsins/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Block_Adminhtml_Recsins_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
|
28 |
+
|
29 |
+
protected function _prepareForm() {
|
30 |
+
$form = new Varien_Data_Form();
|
31 |
+
$this->setForm($form);
|
32 |
+
$fieldset = $form->addFieldset('recsins_form', array('legend' => Mage::helper('recsins')->__('Item information')));
|
33 |
+
|
34 |
+
$fieldset->addField('title', 'text', array(
|
35 |
+
'label' => Mage::helper('recsins')->__('Title'),
|
36 |
+
'class' => 'required-entry',
|
37 |
+
'required' => true,
|
38 |
+
'name' => 'title',
|
39 |
+
));
|
40 |
+
|
41 |
+
$fieldset->addField('filename', 'file', array(
|
42 |
+
'label' => Mage::helper('recsins')->__('File'),
|
43 |
+
'required' => false,
|
44 |
+
'name' => 'filename',
|
45 |
+
));
|
46 |
+
|
47 |
+
$fieldset->addField('status', 'select', array(
|
48 |
+
'label' => Mage::helper('recsins')->__('Status'),
|
49 |
+
'name' => 'status',
|
50 |
+
'values' => array(
|
51 |
+
array(
|
52 |
+
'value' => 1,
|
53 |
+
'label' => Mage::helper('recsins')->__('Enabled'),
|
54 |
+
),
|
55 |
+
array(
|
56 |
+
'value' => 2,
|
57 |
+
'label' => Mage::helper('recsins')->__('Disabled'),
|
58 |
+
),
|
59 |
+
),
|
60 |
+
));
|
61 |
+
|
62 |
+
$fieldset->addField('content', 'editor', array(
|
63 |
+
'name' => 'content',
|
64 |
+
'label' => Mage::helper('recsins')->__('Content'),
|
65 |
+
'title' => Mage::helper('recsins')->__('Content'),
|
66 |
+
'style' => 'width:700px; height:500px;',
|
67 |
+
'wysiwyg' => false,
|
68 |
+
'required' => true,
|
69 |
+
));
|
70 |
+
|
71 |
+
if (Mage::getSingleton('adminhtml/session')->getRecsinsData()) {
|
72 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getRecsinsData());
|
73 |
+
Mage::getSingleton('adminhtml/session')->setRecsinsData(null);
|
74 |
+
} elseif (Mage::registry('recsins_data')) {
|
75 |
+
$form->setValues(Mage::registry('recsins_data')->getData());
|
76 |
+
}
|
77 |
+
return parent::_prepareForm();
|
78 |
+
}
|
79 |
+
|
80 |
+
}
|
app/code/community/Brainsins/Recsins/Block/Adminhtml/Recsins/Edit/Tabs.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Block_Adminhtml_Recsins_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
28 |
+
{
|
29 |
+
|
30 |
+
public function __construct()
|
31 |
+
{
|
32 |
+
parent::__construct();
|
33 |
+
$this->setId('recsins_tabs');
|
34 |
+
$this->setDestElementId('edit_form');
|
35 |
+
$this->setTitle(Mage::helper('recsins')->__('Item Information'));
|
36 |
+
}
|
37 |
+
|
38 |
+
protected function _beforeToHtml()
|
39 |
+
{
|
40 |
+
$this->addTab('form_section', array(
|
41 |
+
'label' => Mage::helper('recsins')->__('Item Information'),
|
42 |
+
'title' => Mage::helper('recsins')->__('Item Information'),
|
43 |
+
'content' => $this->getLayout()->createBlock('recsins/adminhtml_recsins_edit_tab_form')->toHtml(),
|
44 |
+
));
|
45 |
+
|
46 |
+
return parent::_beforeToHtml();
|
47 |
+
}
|
48 |
+
}
|
app/code/community/Brainsins/Recsins/Block/Adminhtml/Recsins/Grid.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Brainsins_Recsins_Block_Adminhtml_Recsins_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('recsinsGrid');
|
9 |
+
$this->setDefaultSort('recsins_id');
|
10 |
+
$this->setDefaultDir('ASC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _prepareCollection()
|
15 |
+
{
|
16 |
+
$collection = Mage::getModel('recsins/recsins')->getCollection();
|
17 |
+
$this->setCollection($collection);
|
18 |
+
return parent::_prepareCollection();
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _prepareColumns()
|
22 |
+
{
|
23 |
+
$this->addColumn('recsins_id', array(
|
24 |
+
'header' => Mage::helper('recsins')->__('ID'),
|
25 |
+
'align' =>'right',
|
26 |
+
'width' => '50px',
|
27 |
+
'index' => 'recsins_id',
|
28 |
+
));
|
29 |
+
|
30 |
+
$this->addColumn('title', array(
|
31 |
+
'header' => Mage::helper('recsins')->__('Title'),
|
32 |
+
'align' =>'left',
|
33 |
+
'index' => 'title',
|
34 |
+
));
|
35 |
+
|
36 |
+
/*
|
37 |
+
$this->addColumn('content', array(
|
38 |
+
'header' => Mage::helper('recsins')->__('Item Content'),
|
39 |
+
'width' => '150px',
|
40 |
+
'index' => 'content',
|
41 |
+
));
|
42 |
+
*/
|
43 |
+
|
44 |
+
$this->addColumn('status', array(
|
45 |
+
'header' => Mage::helper('recsins')->__('Status'),
|
46 |
+
'align' => 'left',
|
47 |
+
'width' => '80px',
|
48 |
+
'index' => 'status',
|
49 |
+
'type' => 'options',
|
50 |
+
'options' => array(
|
51 |
+
1 => 'Enabled',
|
52 |
+
2 => 'Disabled',
|
53 |
+
),
|
54 |
+
));
|
55 |
+
|
56 |
+
$this->addColumn('action',
|
57 |
+
array(
|
58 |
+
'header' => Mage::helper('recsins')->__('Action'),
|
59 |
+
'width' => '100',
|
60 |
+
'type' => 'action',
|
61 |
+
'getter' => 'getId',
|
62 |
+
'actions' => array(
|
63 |
+
array(
|
64 |
+
'caption' => Mage::helper('recsins')->__('Edit'),
|
65 |
+
'url' => array('base'=> '*/*/edit'),
|
66 |
+
'field' => 'id'
|
67 |
+
)
|
68 |
+
),
|
69 |
+
'filter' => false,
|
70 |
+
'sortable' => false,
|
71 |
+
'index' => 'stores',
|
72 |
+
'is_system' => true,
|
73 |
+
));
|
74 |
+
|
75 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('recsins')->__('CSV'));
|
76 |
+
$this->addExportType('*/*/exportXml', Mage::helper('recsins')->__('XML'));
|
77 |
+
|
78 |
+
return parent::_prepareColumns();
|
79 |
+
}
|
80 |
+
|
81 |
+
protected function _prepareMassaction()
|
82 |
+
{
|
83 |
+
$this->setMassactionIdField('recsins_id');
|
84 |
+
$this->getMassactionBlock()->setFormFieldName('recsins');
|
85 |
+
|
86 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
87 |
+
'label' => Mage::helper('recsins')->__('Delete'),
|
88 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
89 |
+
'confirm' => Mage::helper('recsins')->__('Are you sure?')
|
90 |
+
));
|
91 |
+
|
92 |
+
$statuses = Mage::getSingleton('recsins/status')->getOptionArray();
|
93 |
+
|
94 |
+
array_unshift($statuses, array('label'=>'', 'value'=>''));
|
95 |
+
$this->getMassactionBlock()->addItem('status', array(
|
96 |
+
'label'=> Mage::helper('recsins')->__('Change status'),
|
97 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
98 |
+
'additional' => array(
|
99 |
+
'visibility' => array(
|
100 |
+
'name' => 'status',
|
101 |
+
'type' => 'select',
|
102 |
+
'class' => 'required-entry',
|
103 |
+
'label' => Mage::helper('recsins')->__('Status'),
|
104 |
+
'values' => $statuses
|
105 |
+
)
|
106 |
+
)
|
107 |
+
));
|
108 |
+
return $this;
|
109 |
+
}
|
110 |
+
|
111 |
+
public function getRowUrl($row)
|
112 |
+
{
|
113 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
114 |
+
}
|
115 |
+
|
116 |
+
}
|
app/code/community/Brainsins/Recsins/Block/Category.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Block_Category extends Mage_Core_Block_Abstract implements Mage_Widget_Block_Interface {
|
28 |
+
|
29 |
+
protected function _toHtml() {
|
30 |
+
$enabled = Mage::getStoreConfig('brainsins/BS_ENABLED');
|
31 |
+
if ($enabled !== '1') {
|
32 |
+
return "";
|
33 |
+
}
|
34 |
+
return "<div id='category_recommendations'></div>";
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
app/code/community/Brainsins/Recsins/Block/Checkout.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* This file is part of BrainSINS' Magento Extension.
|
4 |
+
*
|
5 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
6 |
+
* and/or modify it under the terms of the GNU General Public License
|
7 |
+
* as published by the Free Software Foundation, either version 3 of the
|
8 |
+
* License, or (at your option) any later version.
|
9 |
+
*
|
10 |
+
* Foobar is distributed in the hope that it will be useful,
|
11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
+
* GNU General Public License for more details.
|
14 |
+
*
|
15 |
+
* You should have received a copy of the GNU General Public License
|
16 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
17 |
+
*
|
18 |
+
*/
|
19 |
+
|
20 |
+
class Brainsins_Recsins_Block_Checkout extends Mage_Core_Block_Abstract implements Mage_Widget_Block_Interface {
|
21 |
+
|
22 |
+
protected function _toHtml() {
|
23 |
+
$enabled = Mage::getStoreConfig('brainsins/BS_ENABLED');
|
24 |
+
if ($enabled !== '1') {
|
25 |
+
return "";
|
26 |
+
}
|
27 |
+
return "<div id='checkout_recommendations'></div>";
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
app/code/community/Brainsins/Recsins/Block/Home.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Block_Home extends Mage_Core_Block_Abstract implements Mage_Widget_Block_Interface {
|
28 |
+
|
29 |
+
protected function _toHtml() {
|
30 |
+
$enabled = Mage::getStoreConfig('brainsins/BS_ENABLED');
|
31 |
+
if ($enabled !== '1') {
|
32 |
+
return "";
|
33 |
+
}
|
34 |
+
return "<div id='home_recommendations'></div>";
|
35 |
+
}
|
36 |
+
}
|
app/code/community/Brainsins/Recsins/Block/Product.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Block_Product extends Mage_Core_Block_Abstract implements Mage_Widget_Block_Interface {
|
28 |
+
|
29 |
+
protected function _toHtml() {
|
30 |
+
$enabled = Mage::getStoreConfig('brainsins/BS_ENABLED');
|
31 |
+
if ($enabled !== '1') {
|
32 |
+
return "";
|
33 |
+
}
|
34 |
+
return "<div id='product_recommendations'></div>";
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
app/code/community/Brainsins/Recsins/Block/Recsins.php
ADDED
@@ -0,0 +1,431 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
/*
|
28 |
+
* This block is attached to the footer of all front-end pages
|
29 |
+
*/
|
30 |
+
|
31 |
+
class Brainsins_Recsins_Block_Recsins extends Mage_Core_Block_Abstract {
|
32 |
+
|
33 |
+
//private $dev = true;
|
34 |
+
private $dev = false;
|
35 |
+
|
36 |
+
protected function _construct() {
|
37 |
+
|
38 |
+
$userId = Mage::getSingleton('customer/session')->getCustomer()->getId();
|
39 |
+
|
40 |
+
if (!isset($userId) || !$userId) {
|
41 |
+
if (array_key_exists('coId', $_COOKIE)) {
|
42 |
+
$userId = $_COOKIE['coId'];
|
43 |
+
} else {
|
44 |
+
$userId = '0';
|
45 |
+
}
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
public function _prepareLayout() {
|
50 |
+
return parent::_prepareLayout();
|
51 |
+
}
|
52 |
+
|
53 |
+
public function _loadCache() {
|
54 |
+
//always force to reload cache
|
55 |
+
return false;
|
56 |
+
}
|
57 |
+
|
58 |
+
public function getRecsins() {
|
59 |
+
if (!$this->hasData('recsins')) {
|
60 |
+
$this->setData('recsins', Mage::registry('recsins'));
|
61 |
+
}
|
62 |
+
return $this->getData('recsins');
|
63 |
+
}
|
64 |
+
|
65 |
+
public function getUserId() {
|
66 |
+
|
67 |
+
$userId = Mage::getSingleton('customer/session')->getCustomer()->getId();
|
68 |
+
if (!isset($userId) || !$userId) {
|
69 |
+
if (array_key_exists('coId', $_COOKIE)) {
|
70 |
+
$userId = $_COOKIE['coId'];
|
71 |
+
} else {
|
72 |
+
$userId = '0';
|
73 |
+
}
|
74 |
+
}
|
75 |
+
return $userId ? $userId : '0';
|
76 |
+
}
|
77 |
+
|
78 |
+
public function getCustomerId() {
|
79 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
80 |
+
if (isset($customer)) {
|
81 |
+
return Mage::getSingleton('customer/session')->getCustomer()->getId();
|
82 |
+
} else {
|
83 |
+
return "";
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
public function getCustomerEmail() {
|
88 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
89 |
+
if (isset($customer)) {
|
90 |
+
return Mage::getSingleton('customer/session')->getCustomer()->getEmail();
|
91 |
+
} else {
|
92 |
+
return "";
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
private function getTrackerUrl() {
|
97 |
+
if ($this->dev) {
|
98 |
+
return "dev-tracker.brainsins.com";
|
99 |
+
} else {
|
100 |
+
return "tracker.brainsins.com";
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
private function getRecommenderUrl() {
|
105 |
+
if ($this->dev) {
|
106 |
+
return "dev-recommender.brainsins.com";
|
107 |
+
} else {
|
108 |
+
return "recommender.brainsins.com";
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
public function _toHtml() {
|
113 |
+
|
114 |
+
$enabled = Mage::getStoreConfig('brainsins/BS_ENABLED');
|
115 |
+
if ($enabled !== '1') {
|
116 |
+
return "";
|
117 |
+
}
|
118 |
+
|
119 |
+
$trackerUrl = $this->getTrackerUrl();
|
120 |
+
$recUrl = $this->getRecommenderUrl();
|
121 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
122 |
+
$session = Mage::getSingleton("core/session", array("name" => "frontend"));
|
123 |
+
|
124 |
+
$recScript = "";
|
125 |
+
|
126 |
+
if (!isset($key) || !$key || $key == '') {
|
127 |
+
return "";
|
128 |
+
}
|
129 |
+
|
130 |
+
$html = "";
|
131 |
+
$url = Mage::helper('core/url')->getCurrentUrl();
|
132 |
+
|
133 |
+
$jscriptFilePath = Mage::getBaseDir() . "/js/brainsins/brainsins.js";
|
134 |
+
$customCssFilePath = Mage::getBAseDir() . "/js/brainsins/brainsins.css";
|
135 |
+
|
136 |
+
if (file_exists($jscriptFilePath)) {
|
137 |
+
$jscriptUrlPath = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS) . "brainsins/brainsins.js";
|
138 |
+
$html .= '<script type="text/javascript" src="' . $jscriptUrlPath . '"></script>' . PHP_EOL;
|
139 |
+
}
|
140 |
+
|
141 |
+
if (file_exists($customCssFilePath)) {
|
142 |
+
$cssUrlPath = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS) . "brainsins/brainsins.css";
|
143 |
+
|
144 |
+
$script = "<script type='text/javascript'>";
|
145 |
+
$script .= "var head = document.getElementsByTagName('head')[0];";
|
146 |
+
$script .= "var link = document.createElement('link');";
|
147 |
+
$script .= "link.rel = 'stylesheet';";
|
148 |
+
$script .= "link.type = 'text/css';";
|
149 |
+
$script .= "link.href = '" . $cssUrlPath . "';";
|
150 |
+
$script .= "link.media = 'all';";
|
151 |
+
$script .= "head.appendChild(link);";
|
152 |
+
$script .= "</script>";
|
153 |
+
$html .= $script;
|
154 |
+
}
|
155 |
+
|
156 |
+
$html .= '<script type="text/javascript">';
|
157 |
+
$html .= 'var bsHost = (("https:" == document.location.protocol) ? "https://" : "http://");' . PHP_EOL;
|
158 |
+
$html .= 'document.write(unescape("%3Cscript src=\'" + bsHost + "' . $trackerUrl . '/bstracker.js\' type=\'text/javascript\'%3E%3C/script%3E"));' . PHP_EOL;
|
159 |
+
$html .= "</script>";
|
160 |
+
|
161 |
+
|
162 |
+
//$html .= '<script type="text/javascript" src="' . $trackerUrl . '"></script>' . PHP_EOL;
|
163 |
+
$html .='<script type="text/javascript"> try{ var BrainSINSTracker = BrainSINS.getTracker( "' . $key . '");} catch (err) { }</script>' . PHP_EOL;
|
164 |
+
|
165 |
+
$recommendersSccript = '<script type="text/javascript" src="' . $recUrl . '">';
|
166 |
+
|
167 |
+
$page = Mage::app()->getFrontController()->getRequest()->getRouteName();
|
168 |
+
|
169 |
+
$script = "<script type='text/javascript'>" . PHP_EOL;
|
170 |
+
|
171 |
+
//captured events have set flags
|
172 |
+
|
173 |
+
$loginFlag = $session->getData("recsins_login");
|
174 |
+
$logoutFlag = $session->getData("recsins_logout");
|
175 |
+
$cartFlag = $session->getData("recsins_cart");
|
176 |
+
$checkoutSuccessFlag = $session->getData("recsins_checkout_success");
|
177 |
+
|
178 |
+
$isValidUl = array_key_exists('ul', $_COOKIE) && isset($_COOKIE['ul']) && $_COOKIE['ul'];
|
179 |
+
|
180 |
+
if ($this->getCustomerId() && (!$isValidUl || ($loginFlag && $loginFlag == '1'))) {
|
181 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
182 |
+
$isNewUser = Mage::getModel("recsins/recsins")->checkNewUser($customer, $this->getCustomerEmail());
|
183 |
+
|
184 |
+
if (!$isNewUser) {
|
185 |
+
$script .= "BrainSINSTracker.trackUserLoggedIn(" . $this->getCustomerId() . ");" . PHP_EOL;
|
186 |
+
}
|
187 |
+
// if it is a new user, login is performed automatically in the checkNewUser method
|
188 |
+
}
|
189 |
+
|
190 |
+
if (!$this->getCustomerId() && $isValidUl) {
|
191 |
+
$script .= "if (BrainSINSTracker.isLogged()) { BrainSINSTracker.trackUserLoggedOut();}" . PHP_EOL;
|
192 |
+
}
|
193 |
+
|
194 |
+
$userId = $this->getUserId();
|
195 |
+
|
196 |
+
//end captured events
|
197 |
+
|
198 |
+
if ($page == 'cms') {
|
199 |
+
$pageId = Mage::getSingleton('cms/page')->getIdentifier();
|
200 |
+
$current_page = "cms->" . $pageId;
|
201 |
+
$url = Mage::helper('core/url')->getCurrentUrl();
|
202 |
+
|
203 |
+
if ($pageId == 'home') {
|
204 |
+
$recScript = $this->getJSRecommendations('brainsins/BS_HOME_RECOMMENDER', 'home_recommendations', $userId, null);
|
205 |
+
}
|
206 |
+
} else if ($page == 'catalog') {
|
207 |
+
|
208 |
+
$product = Mage::registry('current_product');
|
209 |
+
$category = Mage::registry('current_category');
|
210 |
+
|
211 |
+
if (isset($product) && $product) {
|
212 |
+
|
213 |
+
$productId = $product->getId();
|
214 |
+
$store = Mage::app()->getStore();
|
215 |
+
$url = $product->getUrlModel()->getUrl($product, array('_ignore_category' => true)) . "?___store=" . Mage::app()->getStore()->getCode();
|
216 |
+
|
217 |
+
$recScript = $this->getJSRecommendations('brainsins/BS_PRODUCT_RECOMMENDER', 'product_recommendations', $userId, $productId);
|
218 |
+
} else if(isset($category) && $category) {
|
219 |
+
$categoryId = $category->getId();
|
220 |
+
$recScript = $this->getJSRecommendations('brainsins/BS_CATEGORY_RECOMMENDER', 'category_recommendations', $userId, $categoryId);
|
221 |
+
} else {
|
222 |
+
$current_page = "into catalog but no product nor category";
|
223 |
+
}
|
224 |
+
} else if ($page == "checkout" || $page == "gomage_checkout") {
|
225 |
+
$request = Mage::app()->getFrontController()->getRequest();
|
226 |
+
|
227 |
+
if ($request->getControllerName() == "cart") {
|
228 |
+
$recScript = $this->getJSRecommendations('brainsins/BS_CART_RECOMMENDER', 'cart_recommendations', $userId, null);
|
229 |
+
} else if ($request->getControllerName() == "onepage" || $request->getControllerName() == "multishipping") {
|
230 |
+
if ($request->getActionName() == "success") {
|
231 |
+
$recScript = $this->getJSRecommendations('brainsins/BS_CHECKOUT_RECOMMENDER', 'checkout_recommendations', $userId, null);
|
232 |
+
}
|
233 |
+
}
|
234 |
+
}
|
235 |
+
|
236 |
+
//track page url
|
237 |
+
$product = Mage::registry('current_product');
|
238 |
+
if (isset($product) && $product) {
|
239 |
+
|
240 |
+
|
241 |
+
$pid = $product->getId();
|
242 |
+
$name = $product->getName();
|
243 |
+
$name = str_replace("\r\n", " ", $name);
|
244 |
+
$name = str_replace("\n", " ", $name);
|
245 |
+
$name = strip_tags($name);
|
246 |
+
$description = $product->getShortDescription();
|
247 |
+
$description = str_replace("\r\n", " ", $description);
|
248 |
+
$description = str_replace("\n", " ", $description);
|
249 |
+
$description = strip_tags($description);
|
250 |
+
|
251 |
+
$imageUrl = $product->getImageUrl();
|
252 |
+
$price = "";
|
253 |
+
|
254 |
+
$priceModel = $product->getPriceModel();
|
255 |
+
if (method_exists($priceModel, "getPrices")) {
|
256 |
+
$prices = $priceModel->getPrices($product);
|
257 |
+
if (is_array($prices) && isset($prices[0])) {
|
258 |
+
$price = $prices[0];
|
259 |
+
}
|
260 |
+
}
|
261 |
+
|
262 |
+
if ($price === "") {
|
263 |
+
if (method_exists($price, "getFinalPrice")) {
|
264 |
+
$price = $product->getFinalPrice();
|
265 |
+
if (!isset($price) || !$price) {
|
266 |
+
$price = $product->getPrice();
|
267 |
+
}
|
268 |
+
} else {
|
269 |
+
$price = $product->getPrice();
|
270 |
+
}
|
271 |
+
}
|
272 |
+
|
273 |
+
$categoryList = array();
|
274 |
+
$categoryIds = $product->getCategoryIds();
|
275 |
+
|
276 |
+
if (isset($categoryIds) && is_array($categoryIds)) {
|
277 |
+
foreach ($categoryIds as $catId) {
|
278 |
+
$category = Mage::getModel('catalog/category')->load($catId);
|
279 |
+
$parents = $category->getParentIds();
|
280 |
+
|
281 |
+
if (!in_array($catId, $categoryList)) {
|
282 |
+
if (is_numeric($catId)) {
|
283 |
+
$categoryList[] = $catId;
|
284 |
+
}
|
285 |
+
}
|
286 |
+
|
287 |
+
if (isset($parents) && is_array($parents)) {
|
288 |
+
foreach ($parents as $parent) {
|
289 |
+
if (is_numeric($parent)) {
|
290 |
+
if (!in_array($parent, $categoryList)) {
|
291 |
+
$categoryList[] = $parent;
|
292 |
+
}
|
293 |
+
}
|
294 |
+
}
|
295 |
+
}
|
296 |
+
}
|
297 |
+
}
|
298 |
+
|
299 |
+
$categories = "";
|
300 |
+
|
301 |
+
foreach ($categoryList as $category) {
|
302 |
+
$categories .= $category . ",";
|
303 |
+
}
|
304 |
+
|
305 |
+
$typeId = $product->getTypeId();
|
306 |
+
if (isset($typeId) && $typeId == "grouped") {
|
307 |
+
$type = $product->getTypeInstance();
|
308 |
+
if (isset($type) && is_object($type)) {
|
309 |
+
if (method_exists($type, "getChildrenIds")) {
|
310 |
+
$ids = $type->getChildrenIds($product->getId());
|
311 |
+
if (isset($ids) && is_array($ids)) {
|
312 |
+
foreach($ids as $idsList) {
|
313 |
+
if (is_array($idsList)) {
|
314 |
+
foreach($idsList as $id) {
|
315 |
+
$pid .= "," . $id;
|
316 |
+
}
|
317 |
+
}
|
318 |
+
}
|
319 |
+
}
|
320 |
+
}
|
321 |
+
}
|
322 |
+
}
|
323 |
+
|
324 |
+
$script .= 'BrainSINSTracker.trackProductview("' . $pid . '");' . PHP_EOL;
|
325 |
+
$script .= "if (typeof BrainSINS != undefined) {" . PHP_EOL;
|
326 |
+
$script .= "BrainSINS.BrainsinsProductInfo = Object();" . PHP_EOL;
|
327 |
+
$script .= "try{BrainSINS.BrainsinsProductInfo.id = '" . utf8_encode(htmlspecialchars($pid, ENT_QUOTES)) . "';}catch(err){}" . PHP_EOL;
|
328 |
+
$script .= "try{BrainSINS.BrainsinsProductInfo.price = '" . utf8_encode(htmlspecialchars($price, ENT_QUOTES)) . "';}catch(err){}" . PHP_EOL;
|
329 |
+
$script .= "try{BrainSINS.BrainsinsProductInfo.name = '" . utf8_encode(htmlspecialchars($name, ENT_QUOTES)) . "';}catch(err){}" . PHP_EOL;
|
330 |
+
$script .= "try{BrainSINS.BrainsinsProductInfo.description = '" . utf8_encode(htmlspecialchars($description, ENT_QUOTES)) . "';}catch(err){}" . PHP_EOL;
|
331 |
+
$script .= "try{BrainSINS.BrainsinsProductInfo.imageUrl = '" . utf8_encode(htmlspecialchars($imageUrl, ENT_QUOTES)) . "';}catch(err){}" . PHP_EOL;
|
332 |
+
$script .= "try{BrainSINS.BrainsinsProductInfo.categories = '" . utf8_encode(htmlspecialchars($categories, ENT_QUOTES)) . "';}catch(err){}" . PHP_EOL;
|
333 |
+
$script .= "}" . PHP_EOL;
|
334 |
+
|
335 |
+
} else {
|
336 |
+
$script .= 'BrainSINSTracker.trackPageview("' . $url . '");' . PHP_EOL;
|
337 |
+
}
|
338 |
+
|
339 |
+
if ($cartFlag && $userId) {
|
340 |
+
$cart = Mage::helper('checkout/cart')->getCart();
|
341 |
+
$quote = $cart->getQuote();
|
342 |
+
$recsinsModel = Mage::getModel("recsins/recsins");
|
343 |
+
$cartUpload = $recsinsModel->uploadQuotes(array($quote), $userId);
|
344 |
+
}
|
345 |
+
|
346 |
+
if ($checkoutSuccessFlag && $userId) {
|
347 |
+
$recsinsModel = Mage::getModel("recsins/recsins");
|
348 |
+
$lastOrder = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
|
349 |
+
$recsinsModel->trackCheckoutBegin($userId);
|
350 |
+
$recsinsModel->trackCheckoutSuccess($lastOrder, $userId);
|
351 |
+
}
|
352 |
+
|
353 |
+
// reset flags
|
354 |
+
|
355 |
+
$session->setData("recsins_login", null);
|
356 |
+
$session->setData("recsins_logout", null);
|
357 |
+
$session->setData("recsins_cart", null);
|
358 |
+
$session->setData("recsins_checkout_success", null);
|
359 |
+
|
360 |
+
|
361 |
+
$script .= "</script>" . PHP_EOL;
|
362 |
+
|
363 |
+
$html .= $script;
|
364 |
+
|
365 |
+
if ($recScript !== "") {
|
366 |
+
$html .= $recScript;
|
367 |
+
}
|
368 |
+
|
369 |
+
return $html;
|
370 |
+
}
|
371 |
+
|
372 |
+
public function getJSRecommendations($placeKey, $divId, $userId, $productId) {
|
373 |
+
|
374 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
375 |
+
|
376 |
+
$recommenderId = Mage::getStoreConfig($placeKey);
|
377 |
+
|
378 |
+
if (!isset($recommenderId) || !$recommenderId) {
|
379 |
+
return "";
|
380 |
+
}
|
381 |
+
|
382 |
+
if (!isset($productId)) {
|
383 |
+
$productId = 0;
|
384 |
+
}
|
385 |
+
|
386 |
+
$prodId = $productId ? "'" . $productId . "'" : 'null';
|
387 |
+
|
388 |
+
$recUrl = $this->getRecommenderUrl();
|
389 |
+
|
390 |
+
$script = "";
|
391 |
+
$filter = '';
|
392 |
+
|
393 |
+
if (isset($key) && $key != null && isset($recommenderId)) {
|
394 |
+
|
395 |
+
$paintCallback = "null";
|
396 |
+
|
397 |
+
if ($placeKey == 'brainsins/BS_HOME_RECOMMENDER') {
|
398 |
+
$paintCallback = "typeof bsPaintHomeRecommendations == 'undefined' ? null : bsPaintHomeRecommendations";
|
399 |
+
} elseif ($placeKey == 'brainsins/BS_PRODUCT_RECOMMENDER') {
|
400 |
+
$paintCallback = "typeof bsPaintProductRecommendations == 'undefined' ? null : bsPaintProductRecommendations";
|
401 |
+
} elseif ($placeKey == 'brainsins/BS_CART_RECOMMENDER') {
|
402 |
+
$paintCallback = "typeof bsPaintCartRecommendations == 'undefined' ? null : bsPaintCartRecommendations";
|
403 |
+
} elseif ($placeKey == 'brainsins/BS_CHECKOUT_RECOMMENDER') {
|
404 |
+
$paintCallback = "typeof bsPaintCheckoutRecommendations == 'undefined' ? null : bsPaintCheckoutRecommendations";
|
405 |
+
} elseif ($placeKey == 'brainsins/BS_CATEGORY_RECOMMENDER') {
|
406 |
+
$paintCallback = "typeof bsPaintCategoryRecommendations == 'undefined' ? null : bsPaintCategoryRecommendations";
|
407 |
+
//category id is passed in the product id parameter
|
408 |
+
$categoryId = $productId;
|
409 |
+
$filter = 'BrainSINSRecommender.setFilterCategories( "' . $categoryId . '" );' . PHP_EOL;
|
410 |
+
$filter .= 'BrainSINSRecommender.setFilter(BrainSINS.RecommenderConstants.all);';
|
411 |
+
|
412 |
+
}
|
413 |
+
|
414 |
+
$script .= '<script type="text/javascript">' . PHP_EOL;
|
415 |
+
$script .= 'var bsHost = (("https:" == document.location.protocol) ? "https://" : "http://");' . PHP_EOL;
|
416 |
+
$script .= 'document.write(unescape("%3Cscript src=\'" + bsHost + "' . $recUrl . '/bsrecwidget.js\' type=\'text/javascript\'%3E%3C/script%3E"));' . PHP_EOL;
|
417 |
+
$script .= "</script>" . PHP_EOL;
|
418 |
+
|
419 |
+
$script .= '
|
420 |
+
<script type="text/javascript">
|
421 |
+
try{
|
422 |
+
var BrainSINSRecommender = BrainSINS.getRecommender( BrainSINSTracker );
|
423 |
+
' . $filter . '
|
424 |
+
BrainSINSRecommender.loadWidget("' . $recommenderId . '",' . $prodId . ',"' . Mage::app()->getStore()->getCode() . '","' . $divId . '",' . $userId . ',' . $paintCallback . ');
|
425 |
+
}catch(err) { }
|
426 |
+
</script>
|
427 |
+
';
|
428 |
+
}
|
429 |
+
return $script;
|
430 |
+
}
|
431 |
+
}
|
app/code/community/Brainsins/Recsins/COPYING.txt
ADDED
@@ -0,0 +1,674 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 3, 29 June 2007
|
3 |
+
|
4 |
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5 |
+
Everyone is permitted to copy and distribute verbatim copies
|
6 |
+
of this license document, but changing it is not allowed.
|
7 |
+
|
8 |
+
Preamble
|
9 |
+
|
10 |
+
The GNU General Public License is a free, copyleft license for
|
11 |
+
software and other kinds of works.
|
12 |
+
|
13 |
+
The licenses for most software and other practical works are designed
|
14 |
+
to take away your freedom to share and change the works. By contrast,
|
15 |
+
the GNU General Public License is intended to guarantee your freedom to
|
16 |
+
share and change all versions of a program--to make sure it remains free
|
17 |
+
software for all its users. We, the Free Software Foundation, use the
|
18 |
+
GNU General Public License for most of our software; it applies also to
|
19 |
+
any other work released this way by its authors. You can apply it to
|
20 |
+
your programs, too.
|
21 |
+
|
22 |
+
When we speak of free software, we are referring to freedom, not
|
23 |
+
price. Our General Public Licenses are designed to make sure that you
|
24 |
+
have the freedom to distribute copies of free software (and charge for
|
25 |
+
them if you wish), that you receive source code or can get it if you
|
26 |
+
want it, that you can change the software or use pieces of it in new
|
27 |
+
free programs, and that you know you can do these things.
|
28 |
+
|
29 |
+
To protect your rights, we need to prevent others from denying you
|
30 |
+
these rights or asking you to surrender the rights. Therefore, you have
|
31 |
+
certain responsibilities if you distribute copies of the software, or if
|
32 |
+
you modify it: responsibilities to respect the freedom of others.
|
33 |
+
|
34 |
+
For example, if you distribute copies of such a program, whether
|
35 |
+
gratis or for a fee, you must pass on to the recipients the same
|
36 |
+
freedoms that you received. You must make sure that they, too, receive
|
37 |
+
or can get the source code. And you must show them these terms so they
|
38 |
+
know their rights.
|
39 |
+
|
40 |
+
Developers that use the GNU GPL protect your rights with two steps:
|
41 |
+
(1) assert copyright on the software, and (2) offer you this License
|
42 |
+
giving you legal permission to copy, distribute and/or modify it.
|
43 |
+
|
44 |
+
For the developers' and authors' protection, the GPL clearly explains
|
45 |
+
that there is no warranty for this free software. For both users' and
|
46 |
+
authors' sake, the GPL requires that modified versions be marked as
|
47 |
+
changed, so that their problems will not be attributed erroneously to
|
48 |
+
authors of previous versions.
|
49 |
+
|
50 |
+
Some devices are designed to deny users access to install or run
|
51 |
+
modified versions of the software inside them, although the manufacturer
|
52 |
+
can do so. This is fundamentally incompatible with the aim of
|
53 |
+
protecting users' freedom to change the software. The systematic
|
54 |
+
pattern of such abuse occurs in the area of products for individuals to
|
55 |
+
use, which is precisely where it is most unacceptable. Therefore, we
|
56 |
+
have designed this version of the GPL to prohibit the practice for those
|
57 |
+
products. If such problems arise substantially in other domains, we
|
58 |
+
stand ready to extend this provision to those domains in future versions
|
59 |
+
of the GPL, as needed to protect the freedom of users.
|
60 |
+
|
61 |
+
Finally, every program is threatened constantly by software patents.
|
62 |
+
States should not allow patents to restrict development and use of
|
63 |
+
software on general-purpose computers, but in those that do, we wish to
|
64 |
+
avoid the special danger that patents applied to a free program could
|
65 |
+
make it effectively proprietary. To prevent this, the GPL assures that
|
66 |
+
patents cannot be used to render the program non-free.
|
67 |
+
|
68 |
+
The precise terms and conditions for copying, distribution and
|
69 |
+
modification follow.
|
70 |
+
|
71 |
+
TERMS AND CONDITIONS
|
72 |
+
|
73 |
+
0. Definitions.
|
74 |
+
|
75 |
+
"This License" refers to version 3 of the GNU General Public License.
|
76 |
+
|
77 |
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
78 |
+
works, such as semiconductor masks.
|
79 |
+
|
80 |
+
"The Program" refers to any copyrightable work licensed under this
|
81 |
+
License. Each licensee is addressed as "you". "Licensees" and
|
82 |
+
"recipients" may be individuals or organizations.
|
83 |
+
|
84 |
+
To "modify" a work means to copy from or adapt all or part of the work
|
85 |
+
in a fashion requiring copyright permission, other than the making of an
|
86 |
+
exact copy. The resulting work is called a "modified version" of the
|
87 |
+
earlier work or a work "based on" the earlier work.
|
88 |
+
|
89 |
+
A "covered work" means either the unmodified Program or a work based
|
90 |
+
on the Program.
|
91 |
+
|
92 |
+
To "propagate" a work means to do anything with it that, without
|
93 |
+
permission, would make you directly or secondarily liable for
|
94 |
+
infringement under applicable copyright law, except executing it on a
|
95 |
+
computer or modifying a private copy. Propagation includes copying,
|
96 |
+
distribution (with or without modification), making available to the
|
97 |
+
public, and in some countries other activities as well.
|
98 |
+
|
99 |
+
To "convey" a work means any kind of propagation that enables other
|
100 |
+
parties to make or receive copies. Mere interaction with a user through
|
101 |
+
a computer network, with no transfer of a copy, is not conveying.
|
102 |
+
|
103 |
+
An interactive user interface displays "Appropriate Legal Notices"
|
104 |
+
to the extent that it includes a convenient and prominently visible
|
105 |
+
feature that (1) displays an appropriate copyright notice, and (2)
|
106 |
+
tells the user that there is no warranty for the work (except to the
|
107 |
+
extent that warranties are provided), that licensees may convey the
|
108 |
+
work under this License, and how to view a copy of this License. If
|
109 |
+
the interface presents a list of user commands or options, such as a
|
110 |
+
menu, a prominent item in the list meets this criterion.
|
111 |
+
|
112 |
+
1. Source Code.
|
113 |
+
|
114 |
+
The "source code" for a work means the preferred form of the work
|
115 |
+
for making modifications to it. "Object code" means any non-source
|
116 |
+
form of a work.
|
117 |
+
|
118 |
+
A "Standard Interface" means an interface that either is an official
|
119 |
+
standard defined by a recognized standards body, or, in the case of
|
120 |
+
interfaces specified for a particular programming language, one that
|
121 |
+
is widely used among developers working in that language.
|
122 |
+
|
123 |
+
The "System Libraries" of an executable work include anything, other
|
124 |
+
than the work as a whole, that (a) is included in the normal form of
|
125 |
+
packaging a Major Component, but which is not part of that Major
|
126 |
+
Component, and (b) serves only to enable use of the work with that
|
127 |
+
Major Component, or to implement a Standard Interface for which an
|
128 |
+
implementation is available to the public in source code form. A
|
129 |
+
"Major Component", in this context, means a major essential component
|
130 |
+
(kernel, window system, and so on) of the specific operating system
|
131 |
+
(if any) on which the executable work runs, or a compiler used to
|
132 |
+
produce the work, or an object code interpreter used to run it.
|
133 |
+
|
134 |
+
The "Corresponding Source" for a work in object code form means all
|
135 |
+
the source code needed to generate, install, and (for an executable
|
136 |
+
work) run the object code and to modify the work, including scripts to
|
137 |
+
control those activities. However, it does not include the work's
|
138 |
+
System Libraries, or general-purpose tools or generally available free
|
139 |
+
programs which are used unmodified in performing those activities but
|
140 |
+
which are not part of the work. For example, Corresponding Source
|
141 |
+
includes interface definition files associated with source files for
|
142 |
+
the work, and the source code for shared libraries and dynamically
|
143 |
+
linked subprograms that the work is specifically designed to require,
|
144 |
+
such as by intimate data communication or control flow between those
|
145 |
+
subprograms and other parts of the work.
|
146 |
+
|
147 |
+
The Corresponding Source need not include anything that users
|
148 |
+
can regenerate automatically from other parts of the Corresponding
|
149 |
+
Source.
|
150 |
+
|
151 |
+
The Corresponding Source for a work in source code form is that
|
152 |
+
same work.
|
153 |
+
|
154 |
+
2. Basic Permissions.
|
155 |
+
|
156 |
+
All rights granted under this License are granted for the term of
|
157 |
+
copyright on the Program, and are irrevocable provided the stated
|
158 |
+
conditions are met. This License explicitly affirms your unlimited
|
159 |
+
permission to run the unmodified Program. The output from running a
|
160 |
+
covered work is covered by this License only if the output, given its
|
161 |
+
content, constitutes a covered work. This License acknowledges your
|
162 |
+
rights of fair use or other equivalent, as provided by copyright law.
|
163 |
+
|
164 |
+
You may make, run and propagate covered works that you do not
|
165 |
+
convey, without conditions so long as your license otherwise remains
|
166 |
+
in force. You may convey covered works to others for the sole purpose
|
167 |
+
of having them make modifications exclusively for you, or provide you
|
168 |
+
with facilities for running those works, provided that you comply with
|
169 |
+
the terms of this License in conveying all material for which you do
|
170 |
+
not control copyright. Those thus making or running the covered works
|
171 |
+
for you must do so exclusively on your behalf, under your direction
|
172 |
+
and control, on terms that prohibit them from making any copies of
|
173 |
+
your copyrighted material outside their relationship with you.
|
174 |
+
|
175 |
+
Conveying under any other circumstances is permitted solely under
|
176 |
+
the conditions stated below. Sublicensing is not allowed; section 10
|
177 |
+
makes it unnecessary.
|
178 |
+
|
179 |
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
180 |
+
|
181 |
+
No covered work shall be deemed part of an effective technological
|
182 |
+
measure under any applicable law fulfilling obligations under article
|
183 |
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
184 |
+
similar laws prohibiting or restricting circumvention of such
|
185 |
+
measures.
|
186 |
+
|
187 |
+
When you convey a covered work, you waive any legal power to forbid
|
188 |
+
circumvention of technological measures to the extent such circumvention
|
189 |
+
is effected by exercising rights under this License with respect to
|
190 |
+
the covered work, and you disclaim any intention to limit operation or
|
191 |
+
modification of the work as a means of enforcing, against the work's
|
192 |
+
users, your or third parties' legal rights to forbid circumvention of
|
193 |
+
technological measures.
|
194 |
+
|
195 |
+
4. Conveying Verbatim Copies.
|
196 |
+
|
197 |
+
You may convey verbatim copies of the Program's source code as you
|
198 |
+
receive it, in any medium, provided that you conspicuously and
|
199 |
+
appropriately publish on each copy an appropriate copyright notice;
|
200 |
+
keep intact all notices stating that this License and any
|
201 |
+
non-permissive terms added in accord with section 7 apply to the code;
|
202 |
+
keep intact all notices of the absence of any warranty; and give all
|
203 |
+
recipients a copy of this License along with the Program.
|
204 |
+
|
205 |
+
You may charge any price or no price for each copy that you convey,
|
206 |
+
and you may offer support or warranty protection for a fee.
|
207 |
+
|
208 |
+
5. Conveying Modified Source Versions.
|
209 |
+
|
210 |
+
You may convey a work based on the Program, or the modifications to
|
211 |
+
produce it from the Program, in the form of source code under the
|
212 |
+
terms of section 4, provided that you also meet all of these conditions:
|
213 |
+
|
214 |
+
a) The work must carry prominent notices stating that you modified
|
215 |
+
it, and giving a relevant date.
|
216 |
+
|
217 |
+
b) The work must carry prominent notices stating that it is
|
218 |
+
released under this License and any conditions added under section
|
219 |
+
7. This requirement modifies the requirement in section 4 to
|
220 |
+
"keep intact all notices".
|
221 |
+
|
222 |
+
c) You must license the entire work, as a whole, under this
|
223 |
+
License to anyone who comes into possession of a copy. This
|
224 |
+
License will therefore apply, along with any applicable section 7
|
225 |
+
additional terms, to the whole of the work, and all its parts,
|
226 |
+
regardless of how they are packaged. This License gives no
|
227 |
+
permission to license the work in any other way, but it does not
|
228 |
+
invalidate such permission if you have separately received it.
|
229 |
+
|
230 |
+
d) If the work has interactive user interfaces, each must display
|
231 |
+
Appropriate Legal Notices; however, if the Program has interactive
|
232 |
+
interfaces that do not display Appropriate Legal Notices, your
|
233 |
+
work need not make them do so.
|
234 |
+
|
235 |
+
A compilation of a covered work with other separate and independent
|
236 |
+
works, which are not by their nature extensions of the covered work,
|
237 |
+
and which are not combined with it such as to form a larger program,
|
238 |
+
in or on a volume of a storage or distribution medium, is called an
|
239 |
+
"aggregate" if the compilation and its resulting copyright are not
|
240 |
+
used to limit the access or legal rights of the compilation's users
|
241 |
+
beyond what the individual works permit. Inclusion of a covered work
|
242 |
+
in an aggregate does not cause this License to apply to the other
|
243 |
+
parts of the aggregate.
|
244 |
+
|
245 |
+
6. Conveying Non-Source Forms.
|
246 |
+
|
247 |
+
You may convey a covered work in object code form under the terms
|
248 |
+
of sections 4 and 5, provided that you also convey the
|
249 |
+
machine-readable Corresponding Source under the terms of this License,
|
250 |
+
in one of these ways:
|
251 |
+
|
252 |
+
a) Convey the object code in, or embodied in, a physical product
|
253 |
+
(including a physical distribution medium), accompanied by the
|
254 |
+
Corresponding Source fixed on a durable physical medium
|
255 |
+
customarily used for software interchange.
|
256 |
+
|
257 |
+
b) Convey the object code in, or embodied in, a physical product
|
258 |
+
(including a physical distribution medium), accompanied by a
|
259 |
+
written offer, valid for at least three years and valid for as
|
260 |
+
long as you offer spare parts or customer support for that product
|
261 |
+
model, to give anyone who possesses the object code either (1) a
|
262 |
+
copy of the Corresponding Source for all the software in the
|
263 |
+
product that is covered by this License, on a durable physical
|
264 |
+
medium customarily used for software interchange, for a price no
|
265 |
+
more than your reasonable cost of physically performing this
|
266 |
+
conveying of source, or (2) access to copy the
|
267 |
+
Corresponding Source from a network server at no charge.
|
268 |
+
|
269 |
+
c) Convey individual copies of the object code with a copy of the
|
270 |
+
written offer to provide the Corresponding Source. This
|
271 |
+
alternative is allowed only occasionally and noncommercially, and
|
272 |
+
only if you received the object code with such an offer, in accord
|
273 |
+
with subsection 6b.
|
274 |
+
|
275 |
+
d) Convey the object code by offering access from a designated
|
276 |
+
place (gratis or for a charge), and offer equivalent access to the
|
277 |
+
Corresponding Source in the same way through the same place at no
|
278 |
+
further charge. You need not require recipients to copy the
|
279 |
+
Corresponding Source along with the object code. If the place to
|
280 |
+
copy the object code is a network server, the Corresponding Source
|
281 |
+
may be on a different server (operated by you or a third party)
|
282 |
+
that supports equivalent copying facilities, provided you maintain
|
283 |
+
clear directions next to the object code saying where to find the
|
284 |
+
Corresponding Source. Regardless of what server hosts the
|
285 |
+
Corresponding Source, you remain obligated to ensure that it is
|
286 |
+
available for as long as needed to satisfy these requirements.
|
287 |
+
|
288 |
+
e) Convey the object code using peer-to-peer transmission, provided
|
289 |
+
you inform other peers where the object code and Corresponding
|
290 |
+
Source of the work are being offered to the general public at no
|
291 |
+
charge under subsection 6d.
|
292 |
+
|
293 |
+
A separable portion of the object code, whose source code is excluded
|
294 |
+
from the Corresponding Source as a System Library, need not be
|
295 |
+
included in conveying the object code work.
|
296 |
+
|
297 |
+
A "User Product" is either (1) a "consumer product", which means any
|
298 |
+
tangible personal property which is normally used for personal, family,
|
299 |
+
or household purposes, or (2) anything designed or sold for incorporation
|
300 |
+
into a dwelling. In determining whether a product is a consumer product,
|
301 |
+
doubtful cases shall be resolved in favor of coverage. For a particular
|
302 |
+
product received by a particular user, "normally used" refers to a
|
303 |
+
typical or common use of that class of product, regardless of the status
|
304 |
+
of the particular user or of the way in which the particular user
|
305 |
+
actually uses, or expects or is expected to use, the product. A product
|
306 |
+
is a consumer product regardless of whether the product has substantial
|
307 |
+
commercial, industrial or non-consumer uses, unless such uses represent
|
308 |
+
the only significant mode of use of the product.
|
309 |
+
|
310 |
+
"Installation Information" for a User Product means any methods,
|
311 |
+
procedures, authorization keys, or other information required to install
|
312 |
+
and execute modified versions of a covered work in that User Product from
|
313 |
+
a modified version of its Corresponding Source. The information must
|
314 |
+
suffice to ensure that the continued functioning of the modified object
|
315 |
+
code is in no case prevented or interfered with solely because
|
316 |
+
modification has been made.
|
317 |
+
|
318 |
+
If you convey an object code work under this section in, or with, or
|
319 |
+
specifically for use in, a User Product, and the conveying occurs as
|
320 |
+
part of a transaction in which the right of possession and use of the
|
321 |
+
User Product is transferred to the recipient in perpetuity or for a
|
322 |
+
fixed term (regardless of how the transaction is characterized), the
|
323 |
+
Corresponding Source conveyed under this section must be accompanied
|
324 |
+
by the Installation Information. But this requirement does not apply
|
325 |
+
if neither you nor any third party retains the ability to install
|
326 |
+
modified object code on the User Product (for example, the work has
|
327 |
+
been installed in ROM).
|
328 |
+
|
329 |
+
The requirement to provide Installation Information does not include a
|
330 |
+
requirement to continue to provide support service, warranty, or updates
|
331 |
+
for a work that has been modified or installed by the recipient, or for
|
332 |
+
the User Product in which it has been modified or installed. Access to a
|
333 |
+
network may be denied when the modification itself materially and
|
334 |
+
adversely affects the operation of the network or violates the rules and
|
335 |
+
protocols for communication across the network.
|
336 |
+
|
337 |
+
Corresponding Source conveyed, and Installation Information provided,
|
338 |
+
in accord with this section must be in a format that is publicly
|
339 |
+
documented (and with an implementation available to the public in
|
340 |
+
source code form), and must require no special password or key for
|
341 |
+
unpacking, reading or copying.
|
342 |
+
|
343 |
+
7. Additional Terms.
|
344 |
+
|
345 |
+
"Additional permissions" are terms that supplement the terms of this
|
346 |
+
License by making exceptions from one or more of its conditions.
|
347 |
+
Additional permissions that are applicable to the entire Program shall
|
348 |
+
be treated as though they were included in this License, to the extent
|
349 |
+
that they are valid under applicable law. If additional permissions
|
350 |
+
apply only to part of the Program, that part may be used separately
|
351 |
+
under those permissions, but the entire Program remains governed by
|
352 |
+
this License without regard to the additional permissions.
|
353 |
+
|
354 |
+
When you convey a copy of a covered work, you may at your option
|
355 |
+
remove any additional permissions from that copy, or from any part of
|
356 |
+
it. (Additional permissions may be written to require their own
|
357 |
+
removal in certain cases when you modify the work.) You may place
|
358 |
+
additional permissions on material, added by you to a covered work,
|
359 |
+
for which you have or can give appropriate copyright permission.
|
360 |
+
|
361 |
+
Notwithstanding any other provision of this License, for material you
|
362 |
+
add to a covered work, you may (if authorized by the copyright holders of
|
363 |
+
that material) supplement the terms of this License with terms:
|
364 |
+
|
365 |
+
a) Disclaiming warranty or limiting liability differently from the
|
366 |
+
terms of sections 15 and 16 of this License; or
|
367 |
+
|
368 |
+
b) Requiring preservation of specified reasonable legal notices or
|
369 |
+
author attributions in that material or in the Appropriate Legal
|
370 |
+
Notices displayed by works containing it; or
|
371 |
+
|
372 |
+
c) Prohibiting misrepresentation of the origin of that material, or
|
373 |
+
requiring that modified versions of such material be marked in
|
374 |
+
reasonable ways as different from the original version; or
|
375 |
+
|
376 |
+
d) Limiting the use for publicity purposes of names of licensors or
|
377 |
+
authors of the material; or
|
378 |
+
|
379 |
+
e) Declining to grant rights under trademark law for use of some
|
380 |
+
trade names, trademarks, or service marks; or
|
381 |
+
|
382 |
+
f) Requiring indemnification of licensors and authors of that
|
383 |
+
material by anyone who conveys the material (or modified versions of
|
384 |
+
it) with contractual assumptions of liability to the recipient, for
|
385 |
+
any liability that these contractual assumptions directly impose on
|
386 |
+
those licensors and authors.
|
387 |
+
|
388 |
+
All other non-permissive additional terms are considered "further
|
389 |
+
restrictions" within the meaning of section 10. If the Program as you
|
390 |
+
received it, or any part of it, contains a notice stating that it is
|
391 |
+
governed by this License along with a term that is a further
|
392 |
+
restriction, you may remove that term. If a license document contains
|
393 |
+
a further restriction but permits relicensing or conveying under this
|
394 |
+
License, you may add to a covered work material governed by the terms
|
395 |
+
of that license document, provided that the further restriction does
|
396 |
+
not survive such relicensing or conveying.
|
397 |
+
|
398 |
+
If you add terms to a covered work in accord with this section, you
|
399 |
+
must place, in the relevant source files, a statement of the
|
400 |
+
additional terms that apply to those files, or a notice indicating
|
401 |
+
where to find the applicable terms.
|
402 |
+
|
403 |
+
Additional terms, permissive or non-permissive, may be stated in the
|
404 |
+
form of a separately written license, or stated as exceptions;
|
405 |
+
the above requirements apply either way.
|
406 |
+
|
407 |
+
8. Termination.
|
408 |
+
|
409 |
+
You may not propagate or modify a covered work except as expressly
|
410 |
+
provided under this License. Any attempt otherwise to propagate or
|
411 |
+
modify it is void, and will automatically terminate your rights under
|
412 |
+
this License (including any patent licenses granted under the third
|
413 |
+
paragraph of section 11).
|
414 |
+
|
415 |
+
However, if you cease all violation of this License, then your
|
416 |
+
license from a particular copyright holder is reinstated (a)
|
417 |
+
provisionally, unless and until the copyright holder explicitly and
|
418 |
+
finally terminates your license, and (b) permanently, if the copyright
|
419 |
+
holder fails to notify you of the violation by some reasonable means
|
420 |
+
prior to 60 days after the cessation.
|
421 |
+
|
422 |
+
Moreover, your license from a particular copyright holder is
|
423 |
+
reinstated permanently if the copyright holder notifies you of the
|
424 |
+
violation by some reasonable means, this is the first time you have
|
425 |
+
received notice of violation of this License (for any work) from that
|
426 |
+
copyright holder, and you cure the violation prior to 30 days after
|
427 |
+
your receipt of the notice.
|
428 |
+
|
429 |
+
Termination of your rights under this section does not terminate the
|
430 |
+
licenses of parties who have received copies or rights from you under
|
431 |
+
this License. If your rights have been terminated and not permanently
|
432 |
+
reinstated, you do not qualify to receive new licenses for the same
|
433 |
+
material under section 10.
|
434 |
+
|
435 |
+
9. Acceptance Not Required for Having Copies.
|
436 |
+
|
437 |
+
You are not required to accept this License in order to receive or
|
438 |
+
run a copy of the Program. Ancillary propagation of a covered work
|
439 |
+
occurring solely as a consequence of using peer-to-peer transmission
|
440 |
+
to receive a copy likewise does not require acceptance. However,
|
441 |
+
nothing other than this License grants you permission to propagate or
|
442 |
+
modify any covered work. These actions infringe copyright if you do
|
443 |
+
not accept this License. Therefore, by modifying or propagating a
|
444 |
+
covered work, you indicate your acceptance of this License to do so.
|
445 |
+
|
446 |
+
10. Automatic Licensing of Downstream Recipients.
|
447 |
+
|
448 |
+
Each time you convey a covered work, the recipient automatically
|
449 |
+
receives a license from the original licensors, to run, modify and
|
450 |
+
propagate that work, subject to this License. You are not responsible
|
451 |
+
for enforcing compliance by third parties with this License.
|
452 |
+
|
453 |
+
An "entity transaction" is a transaction transferring control of an
|
454 |
+
organization, or substantially all assets of one, or subdividing an
|
455 |
+
organization, or merging organizations. If propagation of a covered
|
456 |
+
work results from an entity transaction, each party to that
|
457 |
+
transaction who receives a copy of the work also receives whatever
|
458 |
+
licenses to the work the party's predecessor in interest had or could
|
459 |
+
give under the previous paragraph, plus a right to possession of the
|
460 |
+
Corresponding Source of the work from the predecessor in interest, if
|
461 |
+
the predecessor has it or can get it with reasonable efforts.
|
462 |
+
|
463 |
+
You may not impose any further restrictions on the exercise of the
|
464 |
+
rights granted or affirmed under this License. For example, you may
|
465 |
+
not impose a license fee, royalty, or other charge for exercise of
|
466 |
+
rights granted under this License, and you may not initiate litigation
|
467 |
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
468 |
+
any patent claim is infringed by making, using, selling, offering for
|
469 |
+
sale, or importing the Program or any portion of it.
|
470 |
+
|
471 |
+
11. Patents.
|
472 |
+
|
473 |
+
A "contributor" is a copyright holder who authorizes use under this
|
474 |
+
License of the Program or a work on which the Program is based. The
|
475 |
+
work thus licensed is called the contributor's "contributor version".
|
476 |
+
|
477 |
+
A contributor's "essential patent claims" are all patent claims
|
478 |
+
owned or controlled by the contributor, whether already acquired or
|
479 |
+
hereafter acquired, that would be infringed by some manner, permitted
|
480 |
+
by this License, of making, using, or selling its contributor version,
|
481 |
+
but do not include claims that would be infringed only as a
|
482 |
+
consequence of further modification of the contributor version. For
|
483 |
+
purposes of this definition, "control" includes the right to grant
|
484 |
+
patent sublicenses in a manner consistent with the requirements of
|
485 |
+
this License.
|
486 |
+
|
487 |
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
488 |
+
patent license under the contributor's essential patent claims, to
|
489 |
+
make, use, sell, offer for sale, import and otherwise run, modify and
|
490 |
+
propagate the contents of its contributor version.
|
491 |
+
|
492 |
+
In the following three paragraphs, a "patent license" is any express
|
493 |
+
agreement or commitment, however denominated, not to enforce a patent
|
494 |
+
(such as an express permission to practice a patent or covenant not to
|
495 |
+
sue for patent infringement). To "grant" such a patent license to a
|
496 |
+
party means to make such an agreement or commitment not to enforce a
|
497 |
+
patent against the party.
|
498 |
+
|
499 |
+
If you convey a covered work, knowingly relying on a patent license,
|
500 |
+
and the Corresponding Source of the work is not available for anyone
|
501 |
+
to copy, free of charge and under the terms of this License, through a
|
502 |
+
publicly available network server or other readily accessible means,
|
503 |
+
then you must either (1) cause the Corresponding Source to be so
|
504 |
+
available, or (2) arrange to deprive yourself of the benefit of the
|
505 |
+
patent license for this particular work, or (3) arrange, in a manner
|
506 |
+
consistent with the requirements of this License, to extend the patent
|
507 |
+
license to downstream recipients. "Knowingly relying" means you have
|
508 |
+
actual knowledge that, but for the patent license, your conveying the
|
509 |
+
covered work in a country, or your recipient's use of the covered work
|
510 |
+
in a country, would infringe one or more identifiable patents in that
|
511 |
+
country that you have reason to believe are valid.
|
512 |
+
|
513 |
+
If, pursuant to or in connection with a single transaction or
|
514 |
+
arrangement, you convey, or propagate by procuring conveyance of, a
|
515 |
+
covered work, and grant a patent license to some of the parties
|
516 |
+
receiving the covered work authorizing them to use, propagate, modify
|
517 |
+
or convey a specific copy of the covered work, then the patent license
|
518 |
+
you grant is automatically extended to all recipients of the covered
|
519 |
+
work and works based on it.
|
520 |
+
|
521 |
+
A patent license is "discriminatory" if it does not include within
|
522 |
+
the scope of its coverage, prohibits the exercise of, or is
|
523 |
+
conditioned on the non-exercise of one or more of the rights that are
|
524 |
+
specifically granted under this License. You may not convey a covered
|
525 |
+
work if you are a party to an arrangement with a third party that is
|
526 |
+
in the business of distributing software, under which you make payment
|
527 |
+
to the third party based on the extent of your activity of conveying
|
528 |
+
the work, and under which the third party grants, to any of the
|
529 |
+
parties who would receive the covered work from you, a discriminatory
|
530 |
+
patent license (a) in connection with copies of the covered work
|
531 |
+
conveyed by you (or copies made from those copies), or (b) primarily
|
532 |
+
for and in connection with specific products or compilations that
|
533 |
+
contain the covered work, unless you entered into that arrangement,
|
534 |
+
or that patent license was granted, prior to 28 March 2007.
|
535 |
+
|
536 |
+
Nothing in this License shall be construed as excluding or limiting
|
537 |
+
any implied license or other defenses to infringement that may
|
538 |
+
otherwise be available to you under applicable patent law.
|
539 |
+
|
540 |
+
12. No Surrender of Others' Freedom.
|
541 |
+
|
542 |
+
If conditions are imposed on you (whether by court order, agreement or
|
543 |
+
otherwise) that contradict the conditions of this License, they do not
|
544 |
+
excuse you from the conditions of this License. If you cannot convey a
|
545 |
+
covered work so as to satisfy simultaneously your obligations under this
|
546 |
+
License and any other pertinent obligations, then as a consequence you may
|
547 |
+
not convey it at all. For example, if you agree to terms that obligate you
|
548 |
+
to collect a royalty for further conveying from those to whom you convey
|
549 |
+
the Program, the only way you could satisfy both those terms and this
|
550 |
+
License would be to refrain entirely from conveying the Program.
|
551 |
+
|
552 |
+
13. Use with the GNU Affero General Public License.
|
553 |
+
|
554 |
+
Notwithstanding any other provision of this License, you have
|
555 |
+
permission to link or combine any covered work with a work licensed
|
556 |
+
under version 3 of the GNU Affero General Public License into a single
|
557 |
+
combined work, and to convey the resulting work. The terms of this
|
558 |
+
License will continue to apply to the part which is the covered work,
|
559 |
+
but the special requirements of the GNU Affero General Public License,
|
560 |
+
section 13, concerning interaction through a network will apply to the
|
561 |
+
combination as such.
|
562 |
+
|
563 |
+
14. Revised Versions of this License.
|
564 |
+
|
565 |
+
The Free Software Foundation may publish revised and/or new versions of
|
566 |
+
the GNU General Public License from time to time. Such new versions will
|
567 |
+
be similar in spirit to the present version, but may differ in detail to
|
568 |
+
address new problems or concerns.
|
569 |
+
|
570 |
+
Each version is given a distinguishing version number. If the
|
571 |
+
Program specifies that a certain numbered version of the GNU General
|
572 |
+
Public License "or any later version" applies to it, you have the
|
573 |
+
option of following the terms and conditions either of that numbered
|
574 |
+
version or of any later version published by the Free Software
|
575 |
+
Foundation. If the Program does not specify a version number of the
|
576 |
+
GNU General Public License, you may choose any version ever published
|
577 |
+
by the Free Software Foundation.
|
578 |
+
|
579 |
+
If the Program specifies that a proxy can decide which future
|
580 |
+
versions of the GNU General Public License can be used, that proxy's
|
581 |
+
public statement of acceptance of a version permanently authorizes you
|
582 |
+
to choose that version for the Program.
|
583 |
+
|
584 |
+
Later license versions may give you additional or different
|
585 |
+
permissions. However, no additional obligations are imposed on any
|
586 |
+
author or copyright holder as a result of your choosing to follow a
|
587 |
+
later version.
|
588 |
+
|
589 |
+
15. Disclaimer of Warranty.
|
590 |
+
|
591 |
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
592 |
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
593 |
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
594 |
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
595 |
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
596 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
597 |
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
598 |
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
599 |
+
|
600 |
+
16. Limitation of Liability.
|
601 |
+
|
602 |
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
603 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
604 |
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
605 |
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
606 |
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
607 |
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
608 |
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
609 |
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
610 |
+
SUCH DAMAGES.
|
611 |
+
|
612 |
+
17. Interpretation of Sections 15 and 16.
|
613 |
+
|
614 |
+
If the disclaimer of warranty and limitation of liability provided
|
615 |
+
above cannot be given local legal effect according to their terms,
|
616 |
+
reviewing courts shall apply local law that most closely approximates
|
617 |
+
an absolute waiver of all civil liability in connection with the
|
618 |
+
Program, unless a warranty or assumption of liability accompanies a
|
619 |
+
copy of the Program in return for a fee.
|
620 |
+
|
621 |
+
END OF TERMS AND CONDITIONS
|
622 |
+
|
623 |
+
How to Apply These Terms to Your New Programs
|
624 |
+
|
625 |
+
If you develop a new program, and you want it to be of the greatest
|
626 |
+
possible use to the public, the best way to achieve this is to make it
|
627 |
+
free software which everyone can redistribute and change under these terms.
|
628 |
+
|
629 |
+
To do so, attach the following notices to the program. It is safest
|
630 |
+
to attach them to the start of each source file to most effectively
|
631 |
+
state the exclusion of warranty; and each file should have at least
|
632 |
+
the "copyright" line and a pointer to where the full notice is found.
|
633 |
+
|
634 |
+
<one line to give the program's name and a brief idea of what it does.>
|
635 |
+
Copyright (C) <year> <name of author>
|
636 |
+
|
637 |
+
This program is free software: you can redistribute it and/or modify
|
638 |
+
it under the terms of the GNU General Public License as published by
|
639 |
+
the Free Software Foundation, either version 3 of the License, or
|
640 |
+
(at your option) any later version.
|
641 |
+
|
642 |
+
This program is distributed in the hope that it will be useful,
|
643 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
644 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
645 |
+
GNU General Public License for more details.
|
646 |
+
|
647 |
+
You should have received a copy of the GNU General Public License
|
648 |
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
649 |
+
|
650 |
+
Also add information on how to contact you by electronic and paper mail.
|
651 |
+
|
652 |
+
If the program does terminal interaction, make it output a short
|
653 |
+
notice like this when it starts in an interactive mode:
|
654 |
+
|
655 |
+
<program> Copyright (C) <year> <name of author>
|
656 |
+
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
657 |
+
This is free software, and you are welcome to redistribute it
|
658 |
+
under certain conditions; type `show c' for details.
|
659 |
+
|
660 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
661 |
+
parts of the General Public License. Of course, your program's commands
|
662 |
+
might be different; for a GUI interface, you would use an "about box".
|
663 |
+
|
664 |
+
You should also get your employer (if you work as a programmer) or school,
|
665 |
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
666 |
+
For more information on this, and how to apply and follow the GNU GPL, see
|
667 |
+
<http://www.gnu.org/licenses/>.
|
668 |
+
|
669 |
+
The GNU General Public License does not permit incorporating your program
|
670 |
+
into proprietary programs. If your program is a subroutine library, you
|
671 |
+
may consider it more useful to permit linking proprietary applications with
|
672 |
+
the library. If this is what you want to do, use the GNU Lesser General
|
673 |
+
Public License instead of this License. But first, please read
|
674 |
+
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
app/code/community/Brainsins/Recsins/Entity/.DS_Store
ADDED
Binary file
|
app/code/community/Brainsins/Recsins/Entity/Setup.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup {
|
28 |
+
|
29 |
+
}
|
app/code/community/Brainsins/Recsins/Helper/.DS_Store
ADDED
Binary file
|
app/code/community/Brainsins/Recsins/Helper/Data.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Helper_Data extends Mage_Core_Helper_Abstract
|
28 |
+
{
|
29 |
+
|
30 |
+
}
|
app/code/community/Brainsins/Recsins/Helper/Recsins.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Helper_Recsins extends Mage_Core_Helper_Abstract {
|
28 |
+
|
29 |
+
public function getImageUrl($id) {
|
30 |
+
if (isset($id) && $id) {
|
31 |
+
$product = Mage::getModel("catalog/product")->load($id);
|
32 |
+
if (isset($product)) {
|
33 |
+
$imageSelectedOption = Mage::getStoreConfig('brainsins/BS_IMAGE_RESIZE');
|
34 |
+
if (isset($imageSelectedOption) && $imageSelectedOption == 'image_resize') {
|
35 |
+
|
36 |
+
$width = 0;
|
37 |
+
$heigth = 0;
|
38 |
+
|
39 |
+
$imageSelectedWidth = Mage::getStoreConfig('brainsins/BS_IMAGE_RESIZE_WIDTH');
|
40 |
+
$imageSelectedHeigth = Mage::getStoreConfig('brainsins/BS_IMAGE_RESIZE_HEIGTH');
|
41 |
+
|
42 |
+
if (isset($imageSelectedWidth) && is_numeric($imageSelectedWidth) && $imageSelectedWidth > 0) {
|
43 |
+
$width = $imageSelectedWidth;
|
44 |
+
$url = "";
|
45 |
+
|
46 |
+
if (isset($imageSelectedHeigth) && is_numeric($imageSelectedHeigth) && $imageSelectedHeigth > 0) {
|
47 |
+
$heigth = $imageSelectedHeigth;
|
48 |
+
$url = (string) Mage::helper('catalog/image')->init($product, "small_image")->resize($width, $heigth);
|
49 |
+
} else {
|
50 |
+
$url = (string) Mage::helper('catalog/image')->init($product, "small_image")->resize($width);
|
51 |
+
}
|
52 |
+
return $url;
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
$prodImage = $product->getSmallImage();
|
57 |
+
if (isset($prodImage) && $prodImage != null && $prodImage != "no_selection") {
|
58 |
+
return ((string) Mage::helper('catalog/image')->init($product, "small_image"));
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
62 |
+
return false;
|
63 |
+
}
|
64 |
+
}
|
app/code/community/Brainsins/Recsins/Model/.DS_Store
ADDED
Binary file
|
app/code/community/Brainsins/Recsins/Model/Api/.DS_Store
ADDED
Binary file
|
app/code/community/Brainsins/Recsins/Model/Api/Api.php
ADDED
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Model_Api_Api extends Mage_Api_Model_Resource_Abstract {
|
28 |
+
|
29 |
+
public function test($param) {
|
30 |
+
return array("text" => "hey, i was invoked and i return something! like " . $param);
|
31 |
+
}
|
32 |
+
|
33 |
+
public function storeList() {
|
34 |
+
$stores = Mage::app()->getStore()->getCollection();
|
35 |
+
$result = array();
|
36 |
+
foreach($stores as $store) {
|
37 |
+
$result[$store->getId()] = array("id" => $store->getId(), "code" => $store->getCode());
|
38 |
+
}
|
39 |
+
return $result;
|
40 |
+
}
|
41 |
+
|
42 |
+
public function productInfo($productId, $store = null, $attributes = null) {
|
43 |
+
|
44 |
+
$productsApi = new Brainsins_Recsins_Model_Api_ProductsApi();
|
45 |
+
|
46 |
+
return ($productsApi->bsInfo($productId, $store));
|
47 |
+
|
48 |
+
$result = $this->info($productId, $store, $identifierType);
|
49 |
+
|
50 |
+
/*if ($result['price'] == 0) {
|
51 |
+
$product = $this->_getProduct($productId, $store);
|
52 |
+
list($minPrice, $maxPrice) = $product->getPriceModel()->getPrices($product);
|
53 |
+
$price = $minPrice;
|
54 |
+
$result['bsPrice'] = $price;
|
55 |
+
} */
|
56 |
+
return $result;
|
57 |
+
}
|
58 |
+
|
59 |
+
public function productList($filters = null, $store = null)
|
60 |
+
{
|
61 |
+
$productsApi = new Brainsins_Recsins_Model_Api_ProductsApi();
|
62 |
+
|
63 |
+
return ($productsApi->items($productId, $store));
|
64 |
+
}
|
65 |
+
|
66 |
+
public function productCount() {
|
67 |
+
return array(Mage::getModel("catalog/product")->getCollection()
|
68 |
+
->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
|
69 |
+
->count());
|
70 |
+
}
|
71 |
+
|
72 |
+
public function productPage($numPage, $size, $visibility = 2, $uploadOutOfStock = true) {
|
73 |
+
$products = Mage::getModel('catalog/product')->getCollection()
|
74 |
+
->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
|
75 |
+
->addAttributeToSelect('id')->
|
76 |
+
addAttributeToSelect('visibility')->
|
77 |
+
addAttributeToSelect('store_ids')->
|
78 |
+
setPage($numPage, $size);
|
79 |
+
|
80 |
+
$result = array();
|
81 |
+
$productsApi = new Brainsins_Recsins_Model_Api_ProductsApi();
|
82 |
+
|
83 |
+
foreach($products as $product) {
|
84 |
+
$id = $product->getId();
|
85 |
+
$prodVisibility = $product->getVisibility();
|
86 |
+
|
87 |
+
if ($prodVisibility >= $visibility) {
|
88 |
+
$stores = $product->getStoreIds();
|
89 |
+
|
90 |
+
if (isset($stores) && is_array($stores)) {
|
91 |
+
$result[$id] = array();
|
92 |
+
|
93 |
+
foreach($stores as $storeId) {
|
94 |
+
$product->setStoreId($storeId);
|
95 |
+
$prodInfo = $productsApi->bsInfo($id, $storeId);
|
96 |
+
$prodInfo['bs_in_stock'] = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getIs_in_stock() !== '0' ? "1" : "0";
|
97 |
+
|
98 |
+
if (method_exists($product, "isAvailable")) {
|
99 |
+
$prodInfo['bs_is_salable'] = $product->isAvailable() ? "1" : "0";
|
100 |
+
} else if (method_exists($product, "isSalable")) {
|
101 |
+
$prodInfo['bs_is_salable'] = $product->isSalable() ? "1" : "0";
|
102 |
+
}
|
103 |
+
$result[$id][$storeId] = $prodInfo;
|
104 |
+
}
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
108 |
+
return $result;
|
109 |
+
}
|
110 |
+
|
111 |
+
public function userCount() {
|
112 |
+
return array(Mage::getModel("customer/customer")->getCollection()->count());
|
113 |
+
}
|
114 |
+
|
115 |
+
public function userPage($numPage, $size) {
|
116 |
+
$customers = Mage::getModel("customer/customer")->getCollection()->setPage($numPage, $size);
|
117 |
+
$result = array();
|
118 |
+
|
119 |
+
foreach($customers as $customer) {
|
120 |
+
$customerInfo = array();
|
121 |
+
$customerInfo['id'] = $customer->getId();
|
122 |
+
|
123 |
+
$subscriber = Mage::getModel("newsletter/subscriber");
|
124 |
+
$subscriber->loadByCustomer($customer);
|
125 |
+
|
126 |
+
$email = "";
|
127 |
+
if ($subscriber->isSubscribed()) {
|
128 |
+
$email = $subscriber->getEmail();
|
129 |
+
}
|
130 |
+
|
131 |
+
$customerInfo['email'] = $email;
|
132 |
+
$result[] = $customerInfo;
|
133 |
+
}
|
134 |
+
|
135 |
+
return $result;
|
136 |
+
}
|
137 |
+
|
138 |
+
/*public function userPage()
|
139 |
+
{
|
140 |
+
for ($i = 0; $i < 1000; $i++) {
|
141 |
+
$collection = Mage::getModel('customer/customer')->getCollection();
|
142 |
+
|
143 |
+
$result = array();
|
144 |
+
foreach ($collection as $customer) {
|
145 |
+
$id = $customer->getId();
|
146 |
+
$email = $customer->getEmail();
|
147 |
+
$info = array();
|
148 |
+
$info['id'] = $id;
|
149 |
+
$info['email'] = $email;
|
150 |
+
|
151 |
+
$result[] = $info;
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
return $result;
|
156 |
+
}*/
|
157 |
+
|
158 |
+
public function getExtensionOptions() {
|
159 |
+
|
160 |
+
$result = array();
|
161 |
+
|
162 |
+
$version = Mage::getStoreConfig('brainsins/BS_VERSION');
|
163 |
+
|
164 |
+
if (isset($version)) {
|
165 |
+
$result['version'] = $version;
|
166 |
+
} else {
|
167 |
+
$result['version'] = "0";
|
168 |
+
}
|
169 |
+
|
170 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
171 |
+
|
172 |
+
if (isset($key)) {
|
173 |
+
$result['key'] = $key;
|
174 |
+
} else {
|
175 |
+
$result['key'] = "0";
|
176 |
+
}
|
177 |
+
|
178 |
+
$enabledValue = Mage::getStoreConfig('brainsins/BS_ENABLED');
|
179 |
+
|
180 |
+
if (isset($enabledValue)) {
|
181 |
+
$result['enabled'] = $enabledValue;
|
182 |
+
} else {
|
183 |
+
$result['enabled'] = "0";
|
184 |
+
}
|
185 |
+
|
186 |
+
$homeSelected = Mage::getStoreConfig('brainsins/BS_HOME_RECOMMENDER');
|
187 |
+
|
188 |
+
if (isset($homeSelected)) {
|
189 |
+
$result['home_recommender'] = $homeSelected;
|
190 |
+
} else {
|
191 |
+
$result['home_recommender'] = "0";
|
192 |
+
}
|
193 |
+
|
194 |
+
$categorySelected = Mage::getStoreConfig('brainsins/BS_CATEGORY_RECOMMENDER');
|
195 |
+
|
196 |
+
if (isset($categorySelected)) {
|
197 |
+
$result['category_recommender'] = $categorySelected;
|
198 |
+
} else {
|
199 |
+
$result['category_recommender'] = "0";
|
200 |
+
}
|
201 |
+
|
202 |
+
$productSelected = Mage::getStoreConfig('brainsins/BS_PRODUCT_RECOMMENDER');
|
203 |
+
|
204 |
+
if (isset($productSelected)) {
|
205 |
+
$result['product_recommender'] = $productSelected;
|
206 |
+
} else {
|
207 |
+
$result['product_recommender'] = "0";
|
208 |
+
}
|
209 |
+
|
210 |
+
|
211 |
+
$cartSelected = Mage::getStoreConfig('brainsins/BS_CART_RECOMMENDER');
|
212 |
+
|
213 |
+
if (isset($cartSelected)) {
|
214 |
+
$result['cart_recommender'] = $cartSelected;
|
215 |
+
} else {
|
216 |
+
$result['cart_recommender'] = "0";
|
217 |
+
}
|
218 |
+
|
219 |
+
$checkoutSelected = Mage::getStoreConfig('brainsins/BS_CHECKOUT_RECOMMENDER');
|
220 |
+
|
221 |
+
if (isset($checkoutSelected)) {
|
222 |
+
$result['checkout_recommender'] = $checkoutSelected;
|
223 |
+
} else {
|
224 |
+
$result['checkout_recommender'] = "0";
|
225 |
+
}
|
226 |
+
|
227 |
+
|
228 |
+
$outOfStockSelected = Mage::getStoreConfig('brainsins/BS_SEND_OUT_OF_STOCK_PRODUCTS');
|
229 |
+
|
230 |
+
if (isset($outOfStockSelected)) {
|
231 |
+
$result['upload_out_of_stock'] = $outOfStockSelected;
|
232 |
+
} else {
|
233 |
+
$result['upload_out_of_stock'] = "0";
|
234 |
+
}
|
235 |
+
|
236 |
+
$imageSelectedOption = Mage::getStoreConfig('brainsins/BS_IMAGE_RESIZE');
|
237 |
+
|
238 |
+
if (isset($imageSelectedOption)) {
|
239 |
+
$result['image_option'] = $imageSelectedOption;
|
240 |
+
} else {
|
241 |
+
$result['image_option'] = "image_no_resize";
|
242 |
+
}
|
243 |
+
|
244 |
+
$imageSelectedWidth = Mage::getStoreConfig('brainsins/BS_IMAGE_RESIZE_WIDTH');
|
245 |
+
|
246 |
+
if (isset($imageSelectedWidth)) {
|
247 |
+
$result['image_resize_width'] = $imageSelectedWidth;
|
248 |
+
} else {
|
249 |
+
$result['image_resize_width'] = "0";
|
250 |
+
}
|
251 |
+
|
252 |
+
$imageSelectedHeigth = Mage::getStoreConfig('brainsins/BS_IMAGE_RESIZE_HEIGTH');
|
253 |
+
|
254 |
+
if (isset($imageSelectedHeigth)) {
|
255 |
+
$result['image_resize_heigth'] = $imageSelectedHeigth;
|
256 |
+
} else {
|
257 |
+
$result['image_resize_heigth'] = "0";
|
258 |
+
}
|
259 |
+
|
260 |
+
$specialPriceSelectedOption = Mage::getStoreConfig('brainsins/BS_USE_SPECIAL_PRICE');
|
261 |
+
|
262 |
+
if (isset($specialPriceSelectedOption)) {
|
263 |
+
$result['use_special_price'] = $specialPriceSelectedOption;
|
264 |
+
} else {
|
265 |
+
$result['use_special_price'] = "0";
|
266 |
+
}
|
267 |
+
|
268 |
+
$taxPriceSelectedOption = Mage::getStoreConfig('brainsins/BS_TAX_PRICE');
|
269 |
+
|
270 |
+
if (isset($taxPriceSelectedOption)) {
|
271 |
+
$result['tax_price'] = $taxPriceSelectedOption;
|
272 |
+
} else {
|
273 |
+
$result['tax_price'] = "tax_price_equal";
|
274 |
+
}
|
275 |
+
|
276 |
+
return $result;
|
277 |
+
}
|
278 |
+
|
279 |
+
public function notifyVersion($version) {
|
280 |
+
if (isset ($version)) {
|
281 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_LAST_AVAILABLE_VERSION', $version);
|
282 |
+
}
|
283 |
+
}
|
284 |
+
|
285 |
+
|
286 |
+
}
|
app/code/community/Brainsins/Recsins/Model/Api/ProductsApi.php
ADDED
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Model_Api_ProductsApi extends Mage_Catalog_Model_Product_Api {
|
28 |
+
|
29 |
+
|
30 |
+
protected function _getProduct($productId, $storeId = null, $identifierType = null)
|
31 |
+
{
|
32 |
+
$product = Mage::getModel('catalog/product');
|
33 |
+
|
34 |
+
if (isset($storeId) && $storeId != null) {
|
35 |
+
$product->setStoreId($storeId);
|
36 |
+
}
|
37 |
+
|
38 |
+
$product->load($productId);
|
39 |
+
return $product;
|
40 |
+
}
|
41 |
+
|
42 |
+
protected function _getRealImageUrl($product, $store) {
|
43 |
+
$prodImage = $product->getSmallImage();
|
44 |
+
|
45 |
+
$img = Mage::getModel("catalog/product_image");
|
46 |
+
$img->setDestinationSubdir("small_image");
|
47 |
+
$img->setBaseFile($prodImage);
|
48 |
+
|
49 |
+
$baseDir = Mage::getBaseDir('media');
|
50 |
+
$path = str_replace($baseDir . DS, "", $img->getBaseFile());
|
51 |
+
return $store->getBaseUrl('media') . str_replace(DS, '/', $path) ;
|
52 |
+
}
|
53 |
+
|
54 |
+
public function info($productId, $storeId = null, $attributes = null, $identifierType = null)
|
55 |
+
{
|
56 |
+
$product = $this->_getProduct($productId, $storeId, $identifierType);
|
57 |
+
$store = Mage::app()->getStore($storeId);
|
58 |
+
|
59 |
+
if (!$product->getId()) {
|
60 |
+
$this->_fault('not_exists');
|
61 |
+
}
|
62 |
+
|
63 |
+
$result = array( // Basic product data
|
64 |
+
'product_id' => $product->getId(),
|
65 |
+
'sku' => $product->getSku(),
|
66 |
+
'set' => $product->getAttributeSetId(),
|
67 |
+
'type' => $product->getTypeId(),
|
68 |
+
'categories' => $product->getCategoryIds(),
|
69 |
+
'websites' => $product->getWebsiteIds()
|
70 |
+
);
|
71 |
+
|
72 |
+
foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) {
|
73 |
+
if ($this->_isAllowedAttribute($attribute, $attributes)) {
|
74 |
+
$result[$attribute->getAttributeCode()] = $product->getData(
|
75 |
+
$attribute->getAttributeCode());
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
//add images and url info (store dependent)
|
80 |
+
|
81 |
+
$prodCachedImageUrl = (string)Mage::helper('catalog/image')->init($product, "small_image");
|
82 |
+
$prodImageUrl = $this->_getRealImageUrl($product, $store);
|
83 |
+
$imageControllerUrl = $store->getBaseUrl() . "recsins/index/getRecProdImg?id=" . $product->getId();
|
84 |
+
|
85 |
+
$result['bs_cached_image'] = $prodCachedImageUrl;
|
86 |
+
$result['bs_real_image'] = $prodImageUrl;
|
87 |
+
$result['bs_controller_image'] = $imageControllerUrl;
|
88 |
+
|
89 |
+
// add minimal price info for bundle products
|
90 |
+
|
91 |
+
$minPrice = 0;
|
92 |
+
|
93 |
+
if ($product->getTypeId() == "bundle") {
|
94 |
+
list($minPrice, $maxPrice) = $product->getPriceModel()->getPrices($product);
|
95 |
+
if (isset($minPrice)) {
|
96 |
+
$result['bs_min_price'] = $minPrice;
|
97 |
+
$minPrice = $minPrice;
|
98 |
+
} else {
|
99 |
+
$result['bs_min_price'] = 0;
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
$url = $store->getBaseUrl() . $product->getUrlPath();
|
104 |
+
|
105 |
+
$result['bs_product_url'] = $url;//$product->getProductUrl();
|
106 |
+
|
107 |
+
$tags = Mage::getModel("tag/tag")->getResourceCollection()
|
108 |
+
->joinRel()
|
109 |
+
->addProductFilter($productId)
|
110 |
+
->addTagGroup()
|
111 |
+
->load();
|
112 |
+
|
113 |
+
$result['tags'] = array();
|
114 |
+
foreach($tags as $tag) {
|
115 |
+
$result['bs_tags'][] = $tag->getName();
|
116 |
+
}
|
117 |
+
|
118 |
+
$result['bs_manufacter_name'] = $product->getAttributeText('manufacturer');
|
119 |
+
|
120 |
+
$price = $minPrice == 0 ? $product->getPrice() : $minPrice;
|
121 |
+
$specialPrice = 0;
|
122 |
+
|
123 |
+
$specialPrice = $product->getSpecialPrice();
|
124 |
+
if (!isset($specialPrice) || $specialPrice == null) {
|
125 |
+
$specialPrice = 0;
|
126 |
+
}
|
127 |
+
|
128 |
+
$store = Mage::app()->getStore($storeId);
|
129 |
+
|
130 |
+
$plusTaxPrice = Mage::helper("tax")->getPrice($product, $price, true, null, null, null, $store, false);
|
131 |
+
$minusTaxPrice = Mage::helper("tax")->getPrice($product, $price, false, null, null, null, $store, true);
|
132 |
+
$plusTaxSpecialPrice = Mage::helper("tax")->getPrice($product, $specialPrice, true, null, null, null, $store, false);
|
133 |
+
$minusTaxSpecialPrice = Mage::helper("tax")->getPrice($product, $specialPrice, false, null, null, null, $store, true);
|
134 |
+
|
135 |
+
$result['bs_price_plus_tax'] = $plusTaxPrice;
|
136 |
+
$result['bs_price_minus_tax'] = $minusTaxPrice;
|
137 |
+
$result['bs_special_price_plus_tax'] = $plusTaxSpecialPrice;
|
138 |
+
$result['bs_special_price_minus_tax'] = $minusTaxSpecialPrice;
|
139 |
+
|
140 |
+
return $result;
|
141 |
+
}
|
142 |
+
|
143 |
+
public function bsInfo($productId, $storeId) {
|
144 |
+
|
145 |
+
$result = $this->info($productId, $storeId);
|
146 |
+
return $result;
|
147 |
+
}
|
148 |
+
|
149 |
+
public function items($filters = null, $store = null)
|
150 |
+
{
|
151 |
+
$collection = Mage::getModel('catalog/product')->getCollection()
|
152 |
+
->addStoreFilter($this->_getStoreId($store))
|
153 |
+
->addAttributeToSelect('name')->addAttributeToSelect('visibility');
|
154 |
+
|
155 |
+
if (is_array($filters)) {
|
156 |
+
try {
|
157 |
+
foreach ($filters as $field => $value) {
|
158 |
+
if (isset($this->_filtersMap[$field])) {
|
159 |
+
$field = $this->_filtersMap[$field];
|
160 |
+
}
|
161 |
+
|
162 |
+
$collection->addFieldToFilter($field, $value);
|
163 |
+
}
|
164 |
+
} catch (Mage_Core_Exception $e) {
|
165 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
$result = array();
|
170 |
+
|
171 |
+
foreach ($collection as $product) {
|
172 |
+
// $result[] = $product->getData();
|
173 |
+
$result[] = array( // Basic product data
|
174 |
+
'product_id' => $product->getId(),
|
175 |
+
'sku' => $product->getSku(),
|
176 |
+
'name' => $product->getName(),
|
177 |
+
'set' => $product->getAttributeSetId(),
|
178 |
+
'type' => $product->getTypeId(),
|
179 |
+
'category_ids' => $product->getCategoryIds(),
|
180 |
+
'visibility' => $product->getVisibility()
|
181 |
+
);
|
182 |
+
}
|
183 |
+
|
184 |
+
return $result;
|
185 |
+
}
|
186 |
+
}
|
app/code/community/Brainsins/Recsins/Model/Cart.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Model_Cart extends Mage_Core_Model_Abstract {
|
28 |
+
|
29 |
+
protected function _construct() {
|
30 |
+
}
|
31 |
+
}
|
app/code/community/Brainsins/Recsins/Model/CartProduct.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Model_CartProduct extends Mage_Core_Model_Abstract {
|
28 |
+
|
29 |
+
protected function _construct() {
|
30 |
+
}
|
31 |
+
}
|
app/code/community/Brainsins/Recsins/Model/Client.php
ADDED
@@ -0,0 +1,591 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Model_Client extends Mage_Core_Model_Abstract {
|
28 |
+
|
29 |
+
private $products;
|
30 |
+
private $users;
|
31 |
+
private $orders;
|
32 |
+
private $carts;
|
33 |
+
private $storeKey;
|
34 |
+
private $server;
|
35 |
+
|
36 |
+
protected function _construct() {
|
37 |
+
$this->products = array();
|
38 |
+
$this->users = array();
|
39 |
+
$this->orders = array();
|
40 |
+
$this->carts = array();
|
41 |
+
$this->storeKey = $this->_data['storeKey'];
|
42 |
+
$this->server = $this->_data['server'];
|
43 |
+
}
|
44 |
+
|
45 |
+
public function addProduct($product) {
|
46 |
+
$this->products[] = $product;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function addUser($user) {
|
50 |
+
$this->users[] = $user;
|
51 |
+
}
|
52 |
+
|
53 |
+
public function addOrder($order) {
|
54 |
+
$this->orders[] = $order;
|
55 |
+
}
|
56 |
+
|
57 |
+
public function addCart($cart) {
|
58 |
+
$this->carts[] = $cart;
|
59 |
+
}
|
60 |
+
|
61 |
+
public function resetProducts() {
|
62 |
+
$this->products = array();
|
63 |
+
}
|
64 |
+
|
65 |
+
public function resetUsers() {
|
66 |
+
$this->users = array();
|
67 |
+
}
|
68 |
+
|
69 |
+
public function resetOrders() {
|
70 |
+
$this->orders = array();
|
71 |
+
}
|
72 |
+
|
73 |
+
public function resetAll() {
|
74 |
+
$this->resetProducts();
|
75 |
+
$this->resetUsers();
|
76 |
+
$this->resetOrders();
|
77 |
+
}
|
78 |
+
|
79 |
+
public function checkResult($res) {
|
80 |
+
$xml = simplexml_load_string($res);
|
81 |
+
|
82 |
+
if ($xml && $xml->status && $xml->status == '200') {
|
83 |
+
return true;
|
84 |
+
} else {
|
85 |
+
return false;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
public function sendUsers($firstTransaction = false) {
|
90 |
+
|
91 |
+
if (empty($this->users)) {
|
92 |
+
return true;
|
93 |
+
}
|
94 |
+
|
95 |
+
$xml = $this->createEmptyXML();
|
96 |
+
$entities = $xml->addChild('entities');
|
97 |
+
|
98 |
+
foreach ($this->users as $user) {
|
99 |
+
$entity = $entities->addChild('entity');
|
100 |
+
$entity->addAttribute('name', 'user');
|
101 |
+
$prop = $entity->addChild('property', $user->getUser_id());
|
102 |
+
$prop->addAttribute('name', 'iduser');
|
103 |
+
$email = $entity->addChild('property', $user->getEmail());
|
104 |
+
$email->addAttribute('name', 'email');
|
105 |
+
}
|
106 |
+
|
107 |
+
$resourceName = $firstTransaction ? "replace.xml" : "upload.xml";
|
108 |
+
|
109 |
+
$curl = curl_init();
|
110 |
+
curl_setopt($curl, CURLOPT_URL, $this->server . '/RecSinsAPI/api/entity/' . $resourceName . '?token=' . $this->storeKey);
|
111 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
112 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/xml", "Accept: application/xml"));
|
113 |
+
curl_setopt($curl, CURLOPT_POST, 1);
|
114 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml->asXML());
|
115 |
+
|
116 |
+
|
117 |
+
$result = curl_exec($curl);
|
118 |
+
|
119 |
+
curl_close($curl);
|
120 |
+
return $this->checkResult($result);
|
121 |
+
}
|
122 |
+
|
123 |
+
public function sendProducts($firstTransaction = false) {
|
124 |
+
|
125 |
+
if (empty($this->products)) {
|
126 |
+
return true;
|
127 |
+
}
|
128 |
+
|
129 |
+
$xml = $this->createEmptyXML();
|
130 |
+
|
131 |
+
$firstProduct = $this->products[0];
|
132 |
+
|
133 |
+
if (isset($firstProduct) && $firstProduct) {
|
134 |
+
if ($firstProduct->getIsMultilanguage()) {
|
135 |
+
$names = $firstProduct->getNames();
|
136 |
+
$langKeys = array_keys($names);
|
137 |
+
if (isset($langKeys[0]) && $langKeys[0]) {
|
138 |
+
$config = $xml->addChild("config");
|
139 |
+
$defaultLang = $config->addChild("property", utf8_encode($langKeys[0]));
|
140 |
+
$defaultLang->addAttribute("name", "defaultLanguage");
|
141 |
+
}
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
$entities = $xml->addChild('entities');
|
146 |
+
foreach ($this->products as $product) {
|
147 |
+
$entity = $entities->addChild('entity');
|
148 |
+
$entity->addAttribute('name', 'product');
|
149 |
+
|
150 |
+
$prop = $entity->addChild('property', utf8_encode(htmlspecialchars($product->getProduct_id())));
|
151 |
+
$prop->addAttribute('name', 'idproduct');
|
152 |
+
|
153 |
+
if ($product->getIsMultilanguage()) {
|
154 |
+
$multiprop = $entity->addChild('multi_property');
|
155 |
+
$multiprop->addAttribute('name', 'name');
|
156 |
+
|
157 |
+
foreach ($product->getNames() as $lang_code => $name) {
|
158 |
+
$prop = $multiprop->addChild('property', utf8_encode(htmlspecialchars($name, ENT_QUOTES)));
|
159 |
+
|
160 |
+
$prop->addAttribute('lang', $lang_code);
|
161 |
+
}
|
162 |
+
|
163 |
+
$multiprop = $entity->addChild('multi_property');
|
164 |
+
$multiprop->addAttribute('name', 'description');
|
165 |
+
|
166 |
+
foreach ($product->getDescriptions() as $lang_code => $description) {
|
167 |
+
$prop = $multiprop->addChild('property', utf8_encode(htmlspecialchars($description, ENT_QUOTES)));
|
168 |
+
$prop->addAttribute('lang', $lang_code);
|
169 |
+
}
|
170 |
+
|
171 |
+
$multiprop = $entity->addChild('multi_property');
|
172 |
+
$multiprop->addAttribute('name', 'url');
|
173 |
+
|
174 |
+
foreach ($product->getUrls() as $lang_code => $url) {
|
175 |
+
$prop = $multiprop->addChild('property', utf8_encode(htmlspecialchars($url)));
|
176 |
+
$prop->addAttribute('lang', $lang_code);
|
177 |
+
}
|
178 |
+
|
179 |
+
$multiprop = $entity->addChild('multi_property');
|
180 |
+
$multiprop->addAttribute('name', 'multiprice');
|
181 |
+
|
182 |
+
foreach ($product->getPrices() as $lang_code => $price) {
|
183 |
+
$prop = $multiprop->addChild('property', utf8_encode(htmlspecialchars($price)));
|
184 |
+
$prop->addAttribute('lang', $lang_code);
|
185 |
+
}
|
186 |
+
|
187 |
+
$multiprop = $entity->addChild('multi_property');
|
188 |
+
$multiprop->addAttribute('name', 'imageurl');
|
189 |
+
|
190 |
+
foreach ($product->getImageUrls() as $lang_code => $imageUrl) {
|
191 |
+
$prop = $multiprop->addChild('property', utf8_encode(htmlspecialchars($imageUrl)));
|
192 |
+
$prop->addAttribute('lang', $lang_code);
|
193 |
+
}
|
194 |
+
} else {
|
195 |
+
$prop = $entity->addChild('property', utf8_encode(htmlspecialchars($product->getNames())));
|
196 |
+
$prop->addAttribute('name', 'name');
|
197 |
+
|
198 |
+
$prop = $entity->addChild('property', utf8_encode(htmlspecialchars($product->getDescriptions())));
|
199 |
+
$prop->addAttribute('name', 'description');
|
200 |
+
|
201 |
+
$prop = $entity->addChild('property', utf8_encode(htmlspecialchars($product->getUrls())));
|
202 |
+
$prop->addAttribute('name', 'url');
|
203 |
+
|
204 |
+
$prop = $entity->addChild('property', utf8_encode(htmlspecialchars($product->getPrice())));
|
205 |
+
$prop->addAttribute('name', 'price');
|
206 |
+
|
207 |
+
$prop = $entity->addChild('property', utf8_encode(htmlspecialchars($product->getImage_url())));
|
208 |
+
$prop->addAttribute('name', 'imageurl');
|
209 |
+
}
|
210 |
+
|
211 |
+
$categories_text = '';
|
212 |
+
$categories = $product->getCategories();
|
213 |
+
|
214 |
+
if (isset($categories)) {
|
215 |
+
if (is_array($categories)) {
|
216 |
+
for ($i = 0; $i < count($categories); $i++) {
|
217 |
+
if (is_numeric($categories[$i])) {
|
218 |
+
$categories_text .= $categories[$i];
|
219 |
+
} else {
|
220 |
+
$categoryDump = var_export($categories[$i], true);
|
221 |
+
Mage::getModel('recsins/recsins')->log("Category is not numeric. Dump: " . PHP_EOL . $categoryDump);
|
222 |
+
}
|
223 |
+
if ($categories_text != '' && $i != count($categories) - 1) {
|
224 |
+
$categories_text .= ', ';
|
225 |
+
}
|
226 |
+
}
|
227 |
+
} else {
|
228 |
+
$categoriesDump = var_export($categories, true);
|
229 |
+
Mage::getModel('recsins/recsins')->log("Categories is not array. Dump: " . PHP_EOL . $categoriesDump);
|
230 |
+
}
|
231 |
+
}
|
232 |
+
|
233 |
+
$prop = $entity->addChild('property', utf8_encode(htmlspecialchars($categories_text)));
|
234 |
+
$prop->addAttribute('name', 'categories');
|
235 |
+
}
|
236 |
+
|
237 |
+
$resourceName = $firstTransaction ? "replace.xml" : "upload.xml";
|
238 |
+
$text = $xml->asXML();
|
239 |
+
$curl = curl_init();
|
240 |
+
curl_setopt($curl, CURLOPT_URL, $this->server . '/RecSinsAPI/api/entity/' . $resourceName . '?token=' . $this->storeKey);
|
241 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
242 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/xml", "Accept: application/xml"));
|
243 |
+
curl_setopt($curl, CURLOPT_POST, 1);
|
244 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $text);
|
245 |
+
$result = curl_exec($curl);
|
246 |
+
curl_close($curl);
|
247 |
+
return $this->checkResult($result);
|
248 |
+
}
|
249 |
+
|
250 |
+
public function sendCatalogPurchases($firstTransaction = false) {
|
251 |
+
if (empty($this->orders)) {
|
252 |
+
return true;
|
253 |
+
}
|
254 |
+
|
255 |
+
$xmlPurchases = $this->createEmptyXML();
|
256 |
+
|
257 |
+
$orders = $xmlPurchases->addChild('orders');
|
258 |
+
|
259 |
+
foreach ($this->orders as $order) {
|
260 |
+
|
261 |
+
$idPurchase = $order->getIdPurchase();
|
262 |
+
|
263 |
+
if (!isset($idPurchase)) {
|
264 |
+
continue;
|
265 |
+
}
|
266 |
+
|
267 |
+
$xml_order = $orders->addChild('order');
|
268 |
+
|
269 |
+
$orderDate = $order->getDate();
|
270 |
+
|
271 |
+
if (!$orderDate) {
|
272 |
+
$orderDate = $order->getFinishDate();
|
273 |
+
}
|
274 |
+
$normalizedDate = $this->normalizeDate($orderDate);
|
275 |
+
|
276 |
+
$xml_order->addChild('amount', $order->getAmount());
|
277 |
+
$xml_order->addChild('idBuyer', $order->getIdUser());
|
278 |
+
$xml_order->addChild('idPurchase', $order->getIdPurchase());
|
279 |
+
$xml_order->addChild('idOrder', $order->getIdCart());
|
280 |
+
$xml_order->addChild('startDate', $normalizedDate);
|
281 |
+
$xml_order->addChild('finishDate', $normalizedDate);
|
282 |
+
$xml_products = $xml_order->addChild('products');
|
283 |
+
|
284 |
+
foreach ($order->getProducts() as $id => $info) {
|
285 |
+
$xml_product = $xml_products->addChild('product');
|
286 |
+
$xml_product->addChild('date', $normalizedDate);
|
287 |
+
$xml_product->addChild('idProduct', $id);
|
288 |
+
$xml_product->addChild('price', $info['price']);
|
289 |
+
$xml_product->addChild('productType', 'product');
|
290 |
+
$xml_product->addChild('quantity', $info['qty']);
|
291 |
+
}
|
292 |
+
}
|
293 |
+
|
294 |
+
$resourceName = $firstTransaction ? "replace.xml" : "upload.xml";
|
295 |
+
|
296 |
+
$text = $xmlPurchases->asXML();
|
297 |
+
$curl = curl_init();
|
298 |
+
curl_setopt($curl, CURLOPT_URL, $this->server . '/RecSinsAPI/api/purchase/upload.xml?token=' . $this->storeKey);
|
299 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
300 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/xml", "Accept: application/xml"));
|
301 |
+
curl_setopt($curl, CURLOPT_POST, 1);
|
302 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $text);
|
303 |
+
$result = curl_exec($curl);
|
304 |
+
|
305 |
+
curl_close($curl);
|
306 |
+
return $this->checkResult($result);
|
307 |
+
}
|
308 |
+
|
309 |
+
public function sendPurchases($firstTransaction = false) {
|
310 |
+
|
311 |
+
if (empty($this->orders)) {
|
312 |
+
return true;
|
313 |
+
}
|
314 |
+
|
315 |
+
$xmlPurchases = $this->createEmptyXML();
|
316 |
+
$orders = $xmlPurchases->addChild('orders');
|
317 |
+
|
318 |
+
foreach ($this->orders as $order) {
|
319 |
+
|
320 |
+
if (!$order->getCartId()) {
|
321 |
+
continue;
|
322 |
+
}
|
323 |
+
|
324 |
+
$xml_order = $orders->addChild('order');
|
325 |
+
|
326 |
+
$orderDate = $order->getDate();
|
327 |
+
if (!$orderDate) {
|
328 |
+
$orderDate = $order->getFinishDate();
|
329 |
+
}
|
330 |
+
|
331 |
+
$normalizedDate = $this->normalizeDate($orderDate);
|
332 |
+
|
333 |
+
$xml_order->addChild('amount', $order->getAmount());
|
334 |
+
$xml_order->addChild('idBuyer', $order->getUserId());
|
335 |
+
$xml_order->addChild('idPurchase', $order->getOrderId());
|
336 |
+
$xml_order->addChild('startDate', $normalizedDate);
|
337 |
+
$xml_order->addChild('finishDate', $normalizedDate);
|
338 |
+
$xml_products = $xml_order->addChild('products');
|
339 |
+
$xml_order->addChild('idOrder', $order->getCartId());
|
340 |
+
|
341 |
+
|
342 |
+
foreach ($order->getProducts() as $product) {
|
343 |
+
$xml_product = $xml_products->addChild('product');
|
344 |
+
$xml_product->addChild('date', $normalizedDate);
|
345 |
+
$xml_product->addChild('idProduct', $product->getProduct_id());
|
346 |
+
$xml_product->addChild('price', $product->getPrice());
|
347 |
+
$xml_product->addChild('productType', 'product');
|
348 |
+
$xml_product->addChild('quantity', $product->getQuantity());
|
349 |
+
}
|
350 |
+
}
|
351 |
+
|
352 |
+
$resourceName = $firstTransaction ? "replace.xml" : "upload.xml";
|
353 |
+
|
354 |
+
$text = $xmlPurchases->asXML();
|
355 |
+
$curl = curl_init();
|
356 |
+
curl_setopt($curl, CURLOPT_URL, $this->server . '/RecSinsAPI/api/purchase/' . $resourceName . 'token=' . $this->storeKey);
|
357 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
358 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/xml", "Accept: application/xml"));
|
359 |
+
curl_setopt($curl, CURLOPT_POST, 1);
|
360 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $text);
|
361 |
+
$result = curl_exec($curl);
|
362 |
+
|
363 |
+
curl_close($curl);
|
364 |
+
return $this->checkResult($result);
|
365 |
+
}
|
366 |
+
|
367 |
+
public function sendCatalogCarts($firstTransaction = false) {
|
368 |
+
|
369 |
+
if (empty($this->carts)) {
|
370 |
+
return true;
|
371 |
+
}
|
372 |
+
|
373 |
+
$xml = $this->createEmptyXML();
|
374 |
+
$orders = $xml->addChild('orders');
|
375 |
+
|
376 |
+
foreach ($this->carts as $cart) {
|
377 |
+
|
378 |
+
$xml_order = $orders->addChild('order');
|
379 |
+
$xml_order->addChild('idBuyer', $cart->getIdUser());
|
380 |
+
$xml_order->addChild('idOrder', $cart->getIdCart());
|
381 |
+
|
382 |
+
if ($cart->getStart_date()) {
|
383 |
+
$xml_order->addChild('startDate', $this->normalizeDate($cart->getStartDate()));
|
384 |
+
} if ($cart->getFinish_date()) {
|
385 |
+
$xml_order->addChild('finishDate', $this->normalizeDate($cart->getFinishDate()));
|
386 |
+
}
|
387 |
+
|
388 |
+
$xml_products = $xml_order->addChild('products');
|
389 |
+
|
390 |
+
foreach ($cart->getProducts() as $id => $info) {
|
391 |
+
|
392 |
+
$xml_product = $xml_products->addChild('product');
|
393 |
+
|
394 |
+
$xml_product->addChild('date', $this->normalizeDate($cart->getStartDate()));
|
395 |
+
|
396 |
+
$xml_product->addChild('idProduct', $id);
|
397 |
+
$xml_product->addChild('productType', 'product');
|
398 |
+
$xml_product->addChild('quantity', $info['qty']);
|
399 |
+
if (isset($info['price'])) {
|
400 |
+
$xml_product->addChild('price', $info['price']);
|
401 |
+
}
|
402 |
+
}
|
403 |
+
}
|
404 |
+
$resourceName = $firstTransaction ? "replace.xml" : "upload.xml";
|
405 |
+
$text = $xml->asXML();
|
406 |
+
$curl = curl_init();
|
407 |
+
curl_setopt($curl, CURLOPT_URL, $this->server . '/RecSinsAPI/api/order/upload.xml?token=' . $this->storeKey);
|
408 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
409 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/xml", "Accept: application/xml"));
|
410 |
+
curl_setopt($curl, CURLOPT_POST, 1);
|
411 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $text);
|
412 |
+
$result = curl_exec($curl);
|
413 |
+
curl_close($curl);
|
414 |
+
return $this->checkResult($result);
|
415 |
+
}
|
416 |
+
|
417 |
+
public function sendFullCarts($firstTransaction = false) {
|
418 |
+
|
419 |
+
if (empty($this->carts)) {
|
420 |
+
return true;
|
421 |
+
}
|
422 |
+
|
423 |
+
$xml = $this->createEmptyXML();
|
424 |
+
$orders = $xml->addChild('orders');
|
425 |
+
|
426 |
+
foreach ($this->carts as $cart) {
|
427 |
+
|
428 |
+
$xml_order = $orders->addChild('order');
|
429 |
+
$xml_order->addChild('idBuyer', $cart->getUserId());
|
430 |
+
//$xml_order->addChild('idOrder', $cart->getIdCart());
|
431 |
+
|
432 |
+
if ($cart->getStart_date()) {
|
433 |
+
$xml_order->addChild('startDate', $this->normalizeDate($cart->getStart_date()));
|
434 |
+
} if ($cart->getFinish_date()) {
|
435 |
+
$xml_order->addChild('finishDate', $this->normalizeDate($cart->getFinish_date()));
|
436 |
+
}
|
437 |
+
|
438 |
+
$xml_products = $xml_order->addChild('products');
|
439 |
+
|
440 |
+
$eldestProduct;
|
441 |
+
|
442 |
+
foreach ($cart->getProducts() as $product) {
|
443 |
+
|
444 |
+
$normalizedDate = $this->normalizeDate($product->getDate_added());
|
445 |
+
|
446 |
+
$xml_product = $xml_products->addChild('product');
|
447 |
+
|
448 |
+
if ($product->getDate_added()) {
|
449 |
+
$xml_product->addChild('date', $this->normalizeDate($product->getDate_added()));
|
450 |
+
} else {
|
451 |
+
$xml_product->addChild('date', $this->normalizeDate($cart->getStart_date()));
|
452 |
+
}
|
453 |
+
|
454 |
+
$xml_product->addChild('idProduct', $product->getProduct_id());
|
455 |
+
$xml_product->addChild('productType', 'product');
|
456 |
+
$xml_product->addChild('quantity', $product->getQuantity());
|
457 |
+
if ($product->getPrice()) {
|
458 |
+
$xml_product->addChild('price', $product->getPrice());
|
459 |
+
}
|
460 |
+
}
|
461 |
+
}
|
462 |
+
$resourceName = $firstTransaction ? "replace.xml" : "upload.xml";
|
463 |
+
$text = $xml->asXML();
|
464 |
+
|
465 |
+
$curl = curl_init();
|
466 |
+
curl_setopt($curl, CURLOPT_URL, $this->server . '/RecSinsAPI/api/order/' . $resourceName . '?token=' . $this->storeKey);
|
467 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
468 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/xml", "Accept: application/xml"));
|
469 |
+
curl_setopt($curl, CURLOPT_POST, 1);
|
470 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $text);
|
471 |
+
$result = curl_exec($curl);
|
472 |
+
curl_close($curl);
|
473 |
+
return $this->checkResult($result);
|
474 |
+
}
|
475 |
+
|
476 |
+
private function normalizeDate($date) {
|
477 |
+
$serverTimezone = new DateTimeZone(date_default_timezone_get());
|
478 |
+
|
479 |
+
$dateOffset = $serverTimezone->getOffset(new DateTime("now", new DateTimeZone('GMT')));
|
480 |
+
$unixTime = strtotime($date);
|
481 |
+
$normalizedDate = date('Y-m-d H:i:s', $unixTime - $dateOffset);
|
482 |
+
return $normalizedDate;
|
483 |
+
}
|
484 |
+
|
485 |
+
private function createEmptyXML() {
|
486 |
+
$xmlstr = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
|
487 |
+
<recsins version='0.1'>
|
488 |
+
</recsins>";
|
489 |
+
|
490 |
+
return new SimpleXMLElement($xmlstr);
|
491 |
+
}
|
492 |
+
|
493 |
+
private function createOkXML() {
|
494 |
+
return "<?xml version='1.0' encoding='UTF-8' standalone='yes'?><recsins version='0.1'><message>Ok</message><status>200</status></recsins>";
|
495 |
+
}
|
496 |
+
|
497 |
+
public function getAllRecommenders() {
|
498 |
+
$curl = curl_init();
|
499 |
+
curl_setopt($curl, CURLOPT_URL, $this->server . '/RecSinsAPI/api/recommender/retrieve.xml?token=' . $this->storeKey);
|
500 |
+
$timeout = 5;
|
501 |
+
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout);
|
502 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
503 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/xml", "Accept: application/xml"));
|
504 |
+
$result = curl_exec($curl);
|
505 |
+
curl_close($curl);
|
506 |
+
return $result;
|
507 |
+
}
|
508 |
+
|
509 |
+
// curl track functions
|
510 |
+
|
511 |
+
public function beginCheckout($idUser) {
|
512 |
+
|
513 |
+
$xml = $this->createEmptyXML();
|
514 |
+
$xml_orders = $xml->addChild('orders');
|
515 |
+
$xml_order = $xml_orders->addChild('order');
|
516 |
+
$xml_order->addChild('idBuyer', $idUser);
|
517 |
+
|
518 |
+
$text = $xml->asXML();
|
519 |
+
|
520 |
+
$curl = curl_init();
|
521 |
+
curl_setopt($curl, CURLOPT_URL, $this->server . '/RecSinsAPI/api/purchase/create.xml?token=' . $this->storeKey);
|
522 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
523 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/xml", "Accept: application/xml"));
|
524 |
+
curl_setopt($curl, CURLOPT_POST, 1);
|
525 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $text);
|
526 |
+
$result = curl_exec($curl);
|
527 |
+
curl_close($curl);
|
528 |
+
return $result;
|
529 |
+
}
|
530 |
+
|
531 |
+
public function endCheckout($idOrder, $idUser, $amount) {
|
532 |
+
|
533 |
+
$xml = $this->createEmptyXML();
|
534 |
+
|
535 |
+
$orders = $xml->addChild("orders");
|
536 |
+
$order = $orders->addChild("order");
|
537 |
+
$order->addChild("idPurchase", $idOrder);
|
538 |
+
$order->addChild("idBuyer", $idUser);
|
539 |
+
$order->addChild("amount", $amount);
|
540 |
+
|
541 |
+
$curl = curl_init();
|
542 |
+
curl_setopt($curl, CURLOPT_URL, $this->server . '/RecSinsAPI/api/purchase/close/' . $idOrder . '/' . $idUser . '/' . $amount . '.xml?token=' . $this->storeKey);
|
543 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
544 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/xml", "Accept: application/xml"));
|
545 |
+
curl_setopt($curl, CURLOPT_POST, 1);
|
546 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, "");
|
547 |
+
$result = curl_exec($curl);
|
548 |
+
curl_close($curl);
|
549 |
+
return $result;
|
550 |
+
}
|
551 |
+
|
552 |
+
public function sendUserLogin($idUser, $cookieId) {
|
553 |
+
|
554 |
+
$curl = curl_init();
|
555 |
+
curl_setopt($curl, CURLOPT_URL, $this->server . '/RecSinsAPI/api/order/logIn.json?cookieId=' . $cookieId . '&userId=' . $idUser . '&token=' . $this->storeKey);
|
556 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
557 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', "Accept: application/json"));
|
558 |
+
curl_setopt($curl, CURLOPT_POST, 1);
|
559 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, "");
|
560 |
+
|
561 |
+
$result = curl_exec($curl);
|
562 |
+
return $result;
|
563 |
+
}
|
564 |
+
|
565 |
+
public function sendUser($idUser, $email) {
|
566 |
+
$xml = $this->createEmptyXML();
|
567 |
+
$entities = $xml->addChild('entities');
|
568 |
+
|
569 |
+
|
570 |
+
$entity = $entities->addChild('entity');
|
571 |
+
$entity->addAttribute('name', 'user');
|
572 |
+
$prop = $entity->addChild('property', $idUser);
|
573 |
+
$prop->addAttribute('name', 'iduser');
|
574 |
+
$email = $entity->addChild('property', $email);
|
575 |
+
$email->addAttribute('name', 'email');
|
576 |
+
$resourceName = "upload.xml";
|
577 |
+
|
578 |
+
$curl = curl_init();
|
579 |
+
curl_setopt($curl, CURLOPT_URL, $this->server . '/RecSinsAPI/api/entity/' . $resourceName . '?token=' . $this->storeKey);
|
580 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
581 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/xml", "Accept: application/xml"));
|
582 |
+
curl_setopt($curl, CURLOPT_POST, 1);
|
583 |
+
curl_setopt($curl, CURLOPT_TIMEOUT, 3);
|
584 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml->asXML());
|
585 |
+
|
586 |
+
$result = curl_exec($curl);
|
587 |
+
curl_close($curl);
|
588 |
+
return $this->checkResult($result);
|
589 |
+
}
|
590 |
+
|
591 |
+
}
|
app/code/community/Brainsins/Recsins/Model/Mysql4/Recsins.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Model_Mysql4_Recsins extends Mage_Core_Model_Mysql4_Abstract
|
28 |
+
{
|
29 |
+
public function _construct()
|
30 |
+
{
|
31 |
+
// Note that the recsins_id refers to the key field in your database table.
|
32 |
+
$this->_init('recsins/recsins', 'recsins_id');
|
33 |
+
}
|
34 |
+
}
|
app/code/community/Brainsins/Recsins/Model/Mysql4/Recsins/Collection.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Model_Mysql4_Recsins_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
28 |
+
{
|
29 |
+
public function _construct()
|
30 |
+
{
|
31 |
+
parent::_construct();
|
32 |
+
$this->_init('recsins/recsins');
|
33 |
+
}
|
34 |
+
}
|
app/code/community/Brainsins/Recsins/Model/NewFile.xml
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
app/code/community/Brainsins/Recsins/Model/Observer.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Model_Observer {
|
28 |
+
|
29 |
+
private function getUserId() {
|
30 |
+
|
31 |
+
$session = Mage::getSingleton('customer/session');
|
32 |
+
if (!isset($session)) {
|
33 |
+
return '0';
|
34 |
+
}
|
35 |
+
|
36 |
+
$customer = $session->getCustomer();
|
37 |
+
if (!isset($customer)) {
|
38 |
+
return '0';
|
39 |
+
}
|
40 |
+
|
41 |
+
$userId = $customer->getId();
|
42 |
+
|
43 |
+
if (!isset($userId) || !$userId) {
|
44 |
+
if (array_key_exists('coId', $_COOKIE)) {
|
45 |
+
$userId = $_COOKIE['coId'];
|
46 |
+
if (!is_numeric($userId)) {
|
47 |
+
$userId = '0';
|
48 |
+
}
|
49 |
+
} else {
|
50 |
+
$userId = '0';
|
51 |
+
}
|
52 |
+
}
|
53 |
+
return $userId ? $userId : '0';
|
54 |
+
}
|
55 |
+
|
56 |
+
public function onLogin($observer) {
|
57 |
+
$enabled = Mage::getStoreConfig('brainsins/BS_ENABLED');
|
58 |
+
if ($enabled !== '1') {
|
59 |
+
return $this;
|
60 |
+
}
|
61 |
+
$session = Mage::getSingleton("core/session", array("name" => "frontend"));
|
62 |
+
$session->setData("recsins_login", "1");
|
63 |
+
return $this;
|
64 |
+
}
|
65 |
+
|
66 |
+
public function onCart($observer) {
|
67 |
+
$enabled = Mage::getStoreConfig('brainsins/BS_ENABLED');
|
68 |
+
if ($enabled !== '1') {
|
69 |
+
return $this;
|
70 |
+
}
|
71 |
+
$session = Mage::getSingleton("core/session", array("name" => "frontend"));
|
72 |
+
$session->setData("recsins_cart", "1");
|
73 |
+
return $this;
|
74 |
+
}
|
75 |
+
|
76 |
+
public function onCheckoutSuccess($observer) {
|
77 |
+
$enabled = Mage::getStoreConfig('brainsins/BS_ENABLED');
|
78 |
+
if (!isset($enabled) || $enabled !== '1') {
|
79 |
+
return $this;
|
80 |
+
}
|
81 |
+
|
82 |
+
$userId = $this->getUserId();
|
83 |
+
$recsinsModel = Mage::getModel("recsins/recsins");
|
84 |
+
$recsinsModel->trackCheckoutBegin($userId);
|
85 |
+
$recsinsModel->trackCheckoutSuccess($observer->getEvent()->getPayment()->getOrder(), $userId);
|
86 |
+
return $this;
|
87 |
+
}
|
88 |
+
|
89 |
+
public function onCheckoutStart($observer) {
|
90 |
+
$enabled = Mage::getStoreConfig('brainsins/BS_ENABLED');
|
91 |
+
if (!isset($enabled) || $enabled !== '1') {
|
92 |
+
return $this;
|
93 |
+
}
|
94 |
+
|
95 |
+
$userId = $this->getUserId();
|
96 |
+
$recsinsModel = Mage::getModel("recsins/recsins");
|
97 |
+
$recsinsModel->trackCheckoutBegin($userId);
|
98 |
+
return $this;
|
99 |
+
}
|
100 |
+
|
101 |
+
public function onCreateAccount($observer) {
|
102 |
+
|
103 |
+
}
|
104 |
+
|
105 |
+
public function onCustomerSave($observer) {
|
106 |
+
$subscriber = $observer->getEvent()->getSubscriber();
|
107 |
+
$userId = $subscriber->getCustomerId();
|
108 |
+
$email = "";
|
109 |
+
if ($subscriber->isSubscribed()) {
|
110 |
+
$email = $subscriber->getEmail();
|
111 |
+
}
|
112 |
+
$recsinsModel = Mage::getModel("recsins/recsins");
|
113 |
+
$res = $recsinsModel->sendUpdatedUser($userId, $email);
|
114 |
+
|
115 |
+
}
|
116 |
+
}
|
app/code/community/Brainsins/Recsins/Model/Order.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Model_Order extends Mage_Core_Model_Abstract {
|
28 |
+
|
29 |
+
protected function _construct() {
|
30 |
+
}
|
31 |
+
|
32 |
+
}
|
app/code/community/Brainsins/Recsins/Model/OrderProduct.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Model_OrderProduct extends Mage_Core_Model_Abstract {
|
28 |
+
|
29 |
+
protected function _construct() {
|
30 |
+
}
|
31 |
+
|
32 |
+
}
|
app/code/community/Brainsins/Recsins/Model/Product.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Model_Product extends Mage_Core_Model_Abstract {
|
28 |
+
|
29 |
+
protected function _construct() {
|
30 |
+
}
|
31 |
+
}
|
app/code/community/Brainsins/Recsins/Model/Recommender.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Model_Recommender extends Mage_Core_Model_Abstract {
|
28 |
+
public function __construct() {
|
29 |
+
$this->_init('recsins/recommender');
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getAllRecommenders() {
|
33 |
+
$resource = Mage::getSingleton('core/resource');
|
34 |
+
$conn = Mage::getSingleton('core/resource')->getConnection('recsins_read');
|
35 |
+
$table = $resource->getTableName('recsins_recommender');
|
36 |
+
$dbRecommenders = $conn->fetchAll("SELECT * FROM $table;");
|
37 |
+
$result = array();
|
38 |
+
foreach($dbRecommenders as $dbRecommender) {
|
39 |
+
$recommender = array();
|
40 |
+
$recommender['id'] = $dbRecommender['id'];
|
41 |
+
$recommender['name'] = $dbRecommender['name'];
|
42 |
+
$recommender['page'] = $dbRecommender['page'];
|
43 |
+
$result[] = $recommender;
|
44 |
+
}
|
45 |
+
return $result;
|
46 |
+
}
|
47 |
+
|
48 |
+
public function setAllRecommenders($recommenders) {
|
49 |
+
$resource = Mage::getSingleton('core/resource');
|
50 |
+
$conn = Mage::getSingleton('core/resource')->getConnection('recsins_write');
|
51 |
+
$table = $resource->getTableName('recsins_recommender');
|
52 |
+
$delQuery = "delete from $table";
|
53 |
+
$conn->query($delQuery);
|
54 |
+
|
55 |
+
foreach($recommenders as $recommender) {
|
56 |
+
$id = $recommender['id'];
|
57 |
+
$name = $recommender['name'];
|
58 |
+
$page = $recommender['page'];
|
59 |
+
|
60 |
+
$query = "insert into $table (`id`, `name`, `page`) values ('$id', '$name', '$page') on duplicate key update name='$name', page='$page';";
|
61 |
+
$conn->query($query);
|
62 |
+
}
|
63 |
+
|
64 |
+
return true;
|
65 |
+
}
|
66 |
+
}
|
app/code/community/Brainsins/Recsins/Model/Recsins.php
ADDED
@@ -0,0 +1,651 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Model_Recsins extends Mage_Core_Model_Abstract {
|
28 |
+
|
29 |
+
private $bsClient;
|
30 |
+
//private $dev = true;
|
31 |
+
private $dev = false;
|
32 |
+
private $server;
|
33 |
+
|
34 |
+
protected function _construct() {
|
35 |
+
parent::_construct();
|
36 |
+
$this->_init('recsins/recsins');
|
37 |
+
|
38 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
39 |
+
|
40 |
+
|
41 |
+
if ($this->dev) {
|
42 |
+
$this->server = "dev-api.brainsins.com";
|
43 |
+
} else {
|
44 |
+
$this->server = "api.brainsins.com";
|
45 |
+
}
|
46 |
+
|
47 |
+
$this->bsClient = Mage::getSingleton("recsins/client", array("server" => $this->server, "storeKey" => $key));
|
48 |
+
}
|
49 |
+
|
50 |
+
public function importRecommenders() {
|
51 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
52 |
+
$client = Mage::getSingleton("recsins/client", array("server" => $this->server, "storeKey" => $key));
|
53 |
+
|
54 |
+
$recommenders = simplexml_load_string($client->getAllRecommenders());
|
55 |
+
$result = false;
|
56 |
+
if (isset($recommenders) && isset($recommenders->recommenders)) {
|
57 |
+
//delete previous recommenders
|
58 |
+
|
59 |
+
$recModel = Mage::getModel('recsins/recommender');
|
60 |
+
$dbRecommenders = array();
|
61 |
+
|
62 |
+
foreach ($recommenders->recommenders->recommender as $recommender) {
|
63 |
+
|
64 |
+
$dbRecommender = array();
|
65 |
+
$dbRecommender['id'] = $recommender->id_recommender;
|
66 |
+
$dbRecommender['name'] = $recommender->name;
|
67 |
+
$dbRecommender['page'] = $recommender->page;
|
68 |
+
|
69 |
+
$dbRecommenders[] = $dbRecommender;
|
70 |
+
}
|
71 |
+
|
72 |
+
$result = $recModel->setAllRecommenders($dbRecommenders);
|
73 |
+
}
|
74 |
+
return $result;
|
75 |
+
}
|
76 |
+
|
77 |
+
public function uploadCatalogUsers($pageSize, $lastPage, $firstTransaction = false) {
|
78 |
+
|
79 |
+
$lastCustomerId = 0;
|
80 |
+
|
81 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
82 |
+
$client = Mage::getSingleton("recsins/client", array("server" => $this->server, "storeKey" => $key));
|
83 |
+
|
84 |
+
$customers = Mage::getModel("customer/customer")->getCollection()->addAttributeToSelect('*')->setPage($lastPage + 1, $pageSize);
|
85 |
+
|
86 |
+
$result = true;
|
87 |
+
|
88 |
+
$firstUploadChanged = false;
|
89 |
+
|
90 |
+
foreach ($customers as $customer) {
|
91 |
+
|
92 |
+
if ($firstTransaction && !$firstUploadChanged) {
|
93 |
+
$firstUploadChanged = true;
|
94 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->getData('brainsins_FIRST_TRANSACTION', '0');
|
95 |
+
}
|
96 |
+
|
97 |
+
$user = Mage::getModel('recsins/user', array('user_id' => $customer->getId(), 'email' => $customer->getEmail()));
|
98 |
+
$client->addUser($user);
|
99 |
+
if ($customer->getId() > $lastCustomerId) {
|
100 |
+
$lastCustomerId = $customer->getId();
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
$result = $client->sendUsers($firstTransaction);
|
105 |
+
|
106 |
+
$lastUploadedId = Mage::getStoreConfig('brainsins/BS_LAST_CUSTOMER_ID_UPLOADED');
|
107 |
+
|
108 |
+
if (!isset($lastUploadedId) || $lastUploadedId < $lastCustomerId) {
|
109 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_LAST_CUSTOMER_ID_UPLOADED', $lastCustomerId);
|
110 |
+
}
|
111 |
+
|
112 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_LAST_PAGE_SENT', $lastPage + 1);
|
113 |
+
//Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_BS_LAST_CUSTOMER_ID_UPLOADED', $lastCustomerId);
|
114 |
+
|
115 |
+
return $result;
|
116 |
+
}
|
117 |
+
|
118 |
+
public function uploadCatalogProducts($pageSize, $lastPage, $firstTransaction = false, $uploadOutOfStock = false) {
|
119 |
+
$stores = Mage::app()->getStore()->getCollection();
|
120 |
+
|
121 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
122 |
+
$client = Mage::getSingleton("recsins/client", array("server" => $this->server, "storeKey" => $key));
|
123 |
+
|
124 |
+
$transactionCounter = 0;
|
125 |
+
|
126 |
+
$result = true;
|
127 |
+
|
128 |
+
//get first store id
|
129 |
+
$firstStoreId = $stores->getFirstItem();
|
130 |
+
|
131 |
+
if ($firstStoreId) {
|
132 |
+
$firstStoreId = $firstStoreId->getId();
|
133 |
+
} else {
|
134 |
+
return;
|
135 |
+
}
|
136 |
+
|
137 |
+
if (!isset($firstStoreId)) {
|
138 |
+
return;
|
139 |
+
}
|
140 |
+
|
141 |
+
$client->resetAll();
|
142 |
+
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->setPage($lastPage + 1, $pageSize)->addPriceData(null, $firstStoreId);
|
143 |
+
|
144 |
+
$firstUploadChanged = false;
|
145 |
+
|
146 |
+
|
147 |
+
foreach ($products as $product) {
|
148 |
+
$id = $product->getId();
|
149 |
+
|
150 |
+
$visibility = $product->getVisibility();
|
151 |
+
$configurable_product_model = Mage::getModel('catalog/product_type_configurable');
|
152 |
+
$parentIdArray = $configurable_product_model->getParentIdsByChild($product->getId());
|
153 |
+
|
154 |
+
if (!$uploadOutOfStock && (!Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getIs_in_stock() || Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty() <= 0)) {
|
155 |
+
continue;
|
156 |
+
}
|
157 |
+
|
158 |
+
if ($firstTransaction && !$firstUploadChanged) {
|
159 |
+
$firstUploadChanged = true;
|
160 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_FIRST_TRANSACTION', '0');
|
161 |
+
}
|
162 |
+
|
163 |
+
if (count($parentIdArray) == 0 && $visibility > 1 && $product->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_ENABLED) {
|
164 |
+
|
165 |
+
$bsProduct = Mage::getModel('recsins/product');
|
166 |
+
|
167 |
+
|
168 |
+
$bsProduct->setIsMultilanguage(true);
|
169 |
+
|
170 |
+
$names = array();
|
171 |
+
$descriptions = array();
|
172 |
+
$urls = array();
|
173 |
+
$prices = array();
|
174 |
+
$imageUrls = array();
|
175 |
+
|
176 |
+
$bsProduct->setProduct_id($product->getId());
|
177 |
+
|
178 |
+
$categoryList = array();
|
179 |
+
$categoryIds = $product->getCategoryIds();
|
180 |
+
|
181 |
+
|
182 |
+
if (isset($categoryIds) && is_array($categoryIds)) {
|
183 |
+
foreach ($categoryIds as $catId) {
|
184 |
+
$category = Mage::getModel('catalog/category')->load($catId);
|
185 |
+
$parents = $category->getParentIds();
|
186 |
+
|
187 |
+
if (!in_array($catId, $categoryList)) {
|
188 |
+
$categoryList[] = $catId;
|
189 |
+
}
|
190 |
+
|
191 |
+
if (isset($parents) && is_array($parents)) {
|
192 |
+
foreach ($parents as $parent) {
|
193 |
+
if (!in_array($parent, $categoryList)) {
|
194 |
+
$categoryList[] = $parent;
|
195 |
+
}
|
196 |
+
}
|
197 |
+
}
|
198 |
+
}
|
199 |
+
}
|
200 |
+
$bsProduct->setCategories($categoryList);
|
201 |
+
|
202 |
+
foreach ($stores as $store) {
|
203 |
+
|
204 |
+
$storeCode = $store->getCode();
|
205 |
+
$storeId = $store->getId();
|
206 |
+
|
207 |
+
$product->setStoreId($storeId);
|
208 |
+
$product->load($id);
|
209 |
+
|
210 |
+
$price = $product->getPrice();
|
211 |
+
|
212 |
+
if ($price == 0.0 && $product->getTypeId() == "bundle") {
|
213 |
+
list($minPrice, $maxPrice) = $product->getPriceModel()->getPrices($product);
|
214 |
+
$price = $minPrice;
|
215 |
+
}
|
216 |
+
|
217 |
+
$prices[$storeCode] = $price;
|
218 |
+
$useSpecialPrice = Mage::getStoreConfig('brainsins/BS_USE_SPECIAL_PRICE');
|
219 |
+
if (isset($useSpecialPrice) && $useSpecialPrice == '1') {
|
220 |
+
|
221 |
+
$specialPrice = $product->getSpecialPrice();
|
222 |
+
if (isset($specialPrice) && $specialPrice) {
|
223 |
+
|
224 |
+
$specialFrom = $product->getSpecialFromDate();
|
225 |
+
$specialTo = $product->getSpecialToDate();
|
226 |
+
$specialFromTS;
|
227 |
+
$specialToTS;
|
228 |
+
|
229 |
+
$nowTS = time();
|
230 |
+
|
231 |
+
$specialValidRange = true;
|
232 |
+
|
233 |
+
if (isset($specialFrom)) {
|
234 |
+
$specialFromTS = strtotime($specialFrom);
|
235 |
+
if ($specialFromTS > $nowTS) {
|
236 |
+
$specialValidRange = false;
|
237 |
+
}
|
238 |
+
}
|
239 |
+
|
240 |
+
if (isset($specialTo)) {
|
241 |
+
$specialToTS = strtotime($specialTo);
|
242 |
+
if ($specialToTS < $nowTS) {
|
243 |
+
$specialValidRange = false;
|
244 |
+
}
|
245 |
+
}
|
246 |
+
|
247 |
+
if ($specialValidRange && $product->getTypeId() != "bundle") {
|
248 |
+
$prices[$storeCode] = $specialPrice;
|
249 |
+
}
|
250 |
+
}
|
251 |
+
}
|
252 |
+
|
253 |
+
|
254 |
+
$resize = false;
|
255 |
+
$width = 0;
|
256 |
+
$heigth = 0;
|
257 |
+
|
258 |
+
$imageSelectedOption = Mage::getSingleton("core/session", array("name" => "adminhtml"))->getData('brainsins_BS_IMAGE_RESIZE');
|
259 |
+
if (isset($imageSelectedOption) && $imageSelectedOption == 'image_resize') {
|
260 |
+
$resize = true;
|
261 |
+
}
|
262 |
+
|
263 |
+
$imageSelectedWidth = Mage::getSingleton("core/session", array("name" => "adminhtml"))->getData('brainsins_BS_IMAGE_RESIZE_WIDTH');
|
264 |
+
$imageSelectedHeigth = Mage::getSingleton("core/session", array("name" => "adminhtml"))->getData('brainsins_BS_IMAGE_RESIZE_HEIGTH');
|
265 |
+
|
266 |
+
if (isset($imageSelectedWidth) && is_numeric($imageSelectedWidth) && $imageSelectedWidth > 0) {
|
267 |
+
$width = $imageSelectedWidth;
|
268 |
+
}
|
269 |
+
|
270 |
+
if (isset($imageSelectedHeigth) && is_numeric($imageSelectedHeigth) && $imageSelectedHeigth > 0) {
|
271 |
+
$heigth = $imageSelectedHeigth;
|
272 |
+
}
|
273 |
+
|
274 |
+
if ($resize && $width > 0) {
|
275 |
+
$prodImage = $product->getSmallImage();
|
276 |
+
if (isset($prodImage) && $prodImage != null && $prodImage != "no_selection") {
|
277 |
+
if ($heigth > 0) {
|
278 |
+
$imageUrls[$storeCode] = ((string) Mage::helper('catalog/image')->init($product, "small_image")->resize($width, $heigth));
|
279 |
+
} else {
|
280 |
+
$imageUrls[$storeCode] = ((string) Mage::helper('catalog/image')->init($product, "small_image")->resize($width));
|
281 |
+
}
|
282 |
+
}
|
283 |
+
} else {
|
284 |
+
$prodImage = $product->getSmallImage();
|
285 |
+
if (isset($prodImage) && $prodImage != null && $prodImage != "no_selection") {
|
286 |
+
|
287 |
+
$img = Mage::getModel("catalog/product_image");
|
288 |
+
$img->setDestinationSubdir("small_image");
|
289 |
+
$img->setBaseFile($prodImage);
|
290 |
+
|
291 |
+
$baseDir = Mage::getBaseDir('media');
|
292 |
+
$path = str_replace($baseDir . DS, "", $img->getBaseFile());
|
293 |
+
$url = $store->getBaseUrl('media') . str_replace(DS, '/', $path);
|
294 |
+
$imageUrls[$storeCode] = $url;
|
295 |
+
}
|
296 |
+
}
|
297 |
+
|
298 |
+
//if resize is selected, override image url with controller call. Previous code will leave a copy of the image ready in the cache
|
299 |
+
if ($resize) {
|
300 |
+
$imageUrls[$storeCode] = $store->getBaseUrl() . "recsins/index/getRecProdImg?id=" . $id;
|
301 |
+
}
|
302 |
+
$names[$storeCode] = utf8_decode($product->getName());
|
303 |
+
$descriptions[$storeCode] = utf8_decode($product->getShortDescription());
|
304 |
+
$urls[$storeCode] = $product->getProductUrl();
|
305 |
+
}
|
306 |
+
|
307 |
+
$bsProduct->setNames($names);
|
308 |
+
$bsProduct->setDescriptions($descriptions);
|
309 |
+
$bsProduct->setUrls($urls);
|
310 |
+
$bsProduct->setPrices($prices);
|
311 |
+
$bsProduct->setImageUrls($imageUrls);
|
312 |
+
|
313 |
+
$client->addProduct($bsProduct);
|
314 |
+
} else {
|
315 |
+
//this product is a configuration of a more general product(id)
|
316 |
+
// or a non visible product
|
317 |
+
}
|
318 |
+
}
|
319 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_LAST_PAGE_SENT', $lastPage + 1);
|
320 |
+
$result = $client->sendProducts($firstTransaction);
|
321 |
+
return $result;
|
322 |
+
}
|
323 |
+
|
324 |
+
private function getNextFakeId($lastFakeId) {
|
325 |
+
if (!isset($lastFakeId) || $lastFakeId == 0) {
|
326 |
+
return 999999999999;
|
327 |
+
} else {
|
328 |
+
return $lastFakeId - 1;
|
329 |
+
}
|
330 |
+
}
|
331 |
+
|
332 |
+
public function uploadCatalogQuotes($pageSize, $lastPage, $lastFakeId = 0, $firstTransaction = false) {
|
333 |
+
|
334 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
335 |
+
$client = Mage::getSingleton("recsins/client", array("server" => $this->server, "storeKey" => $key));
|
336 |
+
|
337 |
+
$quotes = Mage::getModel('sales/quote')->getCollection()->setPageSize($pageSize)->setCurPage($lastPage + 1); //($lastPage + 1, 1);
|
338 |
+
foreach ($quotes as $quote) {
|
339 |
+
|
340 |
+
$quote->load($quote->getId());
|
341 |
+
$items = $quote->getAllItems();
|
342 |
+
$idCustomer = $quote->getCustomerId();
|
343 |
+
|
344 |
+
if (!isset($idCustomer)) {
|
345 |
+
$lastFakeId = $this->getNextFakeId($lastFakeId);
|
346 |
+
$idCustomer = $lastFakeId;
|
347 |
+
}
|
348 |
+
$bsCart = Mage::getModel('recsins/cart');
|
349 |
+
$bsCart->setIdCart($quote->getId());
|
350 |
+
$bsCart->setIdUser($idCustomer);
|
351 |
+
$bsCart->setStartDate($quote->getCreated_at());
|
352 |
+
$bsCart->setFinishDate($quote->getUpdated_at());
|
353 |
+
|
354 |
+
$cartItems = array();
|
355 |
+
foreach ($items as $item) {
|
356 |
+
|
357 |
+
if ($item->getParentItemId()) {
|
358 |
+
continue;
|
359 |
+
}
|
360 |
+
|
361 |
+
//TODO ? $product = $item->getProduct();
|
362 |
+
$qty = $item->getQty();
|
363 |
+
$price = $item->getPrice();
|
364 |
+
$idProduct = $item->getProduct_id();
|
365 |
+
|
366 |
+
if (array_key_exists($idProduct, $cartItems)) {
|
367 |
+
$newQty = $cartItems[$idProduct]['qty'] + $qty;
|
368 |
+
$newPrice = ($cartItems[$idProduct]['price'] * $cartItems[$idProduct]['qty'] + $price * $qty) / $newQty;
|
369 |
+
$cartItems[$idProduct]['qty'] = $newQty;
|
370 |
+
$cartItems[$idProduct]['price'] = $newPrice;
|
371 |
+
} else {
|
372 |
+
$cartItems[$idProduct] = array();
|
373 |
+
$cartItems[$idProduct]['qty'] = $qty;
|
374 |
+
$cartItems[$idProduct]['price'] = $price;
|
375 |
+
}
|
376 |
+
}
|
377 |
+
|
378 |
+
$bsCart->setProducts($cartItems);
|
379 |
+
$client->addCart($bsCart);
|
380 |
+
}
|
381 |
+
|
382 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_LAST_PAGE_SENT', $lastPage + 1);
|
383 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_BS_LAST_FAKE_ID', $lastFakeId);
|
384 |
+
return $client->sendCatalogCarts($firstTransaction);
|
385 |
+
}
|
386 |
+
|
387 |
+
public function uploadCatalogOrders($pageSize, $lastPage, $lastFakeId, $firstTransaction = false) {
|
388 |
+
|
389 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
390 |
+
$client = Mage::getSingleton("recsins/client", array("server" => $this->server, "storeKey" => $key));
|
391 |
+
|
392 |
+
$orders = Mage::getModel('sales/order')->getCollection()->setPageSize($pageSize)->setCurPage($lastPage + 1);
|
393 |
+
|
394 |
+
foreach ($orders as $order) {
|
395 |
+
|
396 |
+
$order->load($order->getId());
|
397 |
+
$idCustomer = $order->getCustomer_id();
|
398 |
+
$quoteId = $order->getQuote_id();
|
399 |
+
|
400 |
+
if (!isset($idCustomer)) {
|
401 |
+
$idCustomer = $this->getNextFakeId($lastFakeId);
|
402 |
+
}
|
403 |
+
|
404 |
+
$bsOrder = Mage::getModel('recsins/order');
|
405 |
+
$bsOrder->setIdPurchase($order->getIncrementId());
|
406 |
+
$bsOrder->setIdCart($quoteId);
|
407 |
+
$bsOrder->setIdUser($idCustomer);
|
408 |
+
$bsOrder->setDate($order->getCreated_at());
|
409 |
+
$bsOrder->setAmount($order->getSubtotal());
|
410 |
+
|
411 |
+
$bsCart = Mage::getModel('recsins/cart');
|
412 |
+
$bsCart->setIdCart($quoteId);
|
413 |
+
$bsCart->setIdUser($idCustomer);
|
414 |
+
$bsCart->setStartDate($order->getCreated_at());
|
415 |
+
$bsCart->setFinishDate($order->getCreated_at());
|
416 |
+
|
417 |
+
$orderItems = array();
|
418 |
+
$cartItems = array();
|
419 |
+
|
420 |
+
$items = $order->getAllItems();
|
421 |
+
foreach ($items as $item) {
|
422 |
+
|
423 |
+
if ($item->getParentItemId()) {
|
424 |
+
continue;
|
425 |
+
}
|
426 |
+
|
427 |
+
$idProduct = $item->getProduct_id();
|
428 |
+
$price = $item->getPrice();
|
429 |
+
$qty = (int) $item->getQty_ordered();
|
430 |
+
|
431 |
+
if (array_key_exists($idProduct, $orderItems)) {
|
432 |
+
$newQty = $orderItems[$idProduct]['qty'] + $qty;
|
433 |
+
$newPrice = ($orderItems[$idProduct]['price'] * $orderItems[$idProduct]['qty'] + $price * $qty) / $newQty;
|
434 |
+
$orderItems[$idProduct]['qty'] = $newQty;
|
435 |
+
$orderItems[$idProduct]['price'] = $newPrice;
|
436 |
+
$cartItems[$idProduct]['qty'] = $newQty;
|
437 |
+
$cartItems[$idProduct]['price'] = $newPrice;
|
438 |
+
} else {
|
439 |
+
$orderItems[$idProduct] = array();
|
440 |
+
$cartItems[$idProduct] = array();
|
441 |
+
$orderItems[$idProduct]['qty'] = $qty;
|
442 |
+
$orderItems[$idProduct]['price'] = $price;
|
443 |
+
$cartItems[$idProduct]['qty'] = $qty;
|
444 |
+
$cartItems[$idProduct]['price'] = $price;
|
445 |
+
}
|
446 |
+
}
|
447 |
+
|
448 |
+
$bsCart->setProducts($cartItems);
|
449 |
+
$bsOrder->setProducts($orderItems);
|
450 |
+
|
451 |
+
$client->addCart($bsCart);
|
452 |
+
$client->addOrder($bsOrder);
|
453 |
+
}
|
454 |
+
|
455 |
+
$result = $client->sendCatalogCarts();
|
456 |
+
$result = $result && $client->sendCatalogPurchases($firstTransaction);
|
457 |
+
|
458 |
+
Mage::getModel('core/config')->saveConfig('brainsins/LAST_PAGE_SENT', $lastPage + 1);
|
459 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_LAST_FAKE_ID', $lastFakeId);
|
460 |
+
return $result;
|
461 |
+
}
|
462 |
+
|
463 |
+
public function uploadQuotes($quotes, $userId = null) {
|
464 |
+
|
465 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
466 |
+
$client = Mage::getSingleton("recsins/client", array("server" => $this->server, "storeKey" => $key));
|
467 |
+
|
468 |
+
foreach ($quotes as $quote) {
|
469 |
+
|
470 |
+
$orderId = $quote->getOrig_order_id();
|
471 |
+
if ($orderId == 0) {
|
472 |
+
$orderId = $quote->getReserved_order_id();
|
473 |
+
}
|
474 |
+
|
475 |
+
if ($orderId == 0) {
|
476 |
+
$items = $quote->getAllItems();
|
477 |
+
|
478 |
+
if (count($items) > 0) {
|
479 |
+
$idCustomer = $userId ? $userId : $quote->getCustomer()->getId();
|
480 |
+
if ($idCustomer) {
|
481 |
+
|
482 |
+
$cartCustomerId = $userId ? $userId : $quote->getCustomer()->getId();
|
483 |
+
|
484 |
+
$bsCart = Mage::getModel('recsins/cart');
|
485 |
+
$bsCart->setIdCart($quote->getId());
|
486 |
+
$bsCart->setUserId($cartCustomerId);
|
487 |
+
|
488 |
+
$bsCart->setStart_date($quote->getCreated_at());
|
489 |
+
$bsCart->setFinish_date($quote->getUpdated_at());
|
490 |
+
$cartItems = array();
|
491 |
+
|
492 |
+
|
493 |
+
foreach ($items as $item) {
|
494 |
+
if ($item->getParentItemId()) {
|
495 |
+
continue;
|
496 |
+
}
|
497 |
+
|
498 |
+
$qty = $item->getQty();
|
499 |
+
$price = $item->getPrice();
|
500 |
+
|
501 |
+
|
502 |
+
$product = $item->getProduct();
|
503 |
+
|
504 |
+
$productId = $product->getId();
|
505 |
+
$configurable_product_model = Mage::getModel('catalog/product_type_configurable');
|
506 |
+
$parentIdArray = $configurable_product_model->getParentIdsByChild($productId);
|
507 |
+
|
508 |
+
$found = false;
|
509 |
+
|
510 |
+
foreach ($cartItems as $storedItem) {
|
511 |
+
|
512 |
+
if ($productId == $storedItem->getProduct_id()) {
|
513 |
+
|
514 |
+
$storedQty = $storedItem->getQuantity();
|
515 |
+
$storedPrice = $storedItem->getPrice();
|
516 |
+
|
517 |
+
$newQty = $storedQty + $qty;
|
518 |
+
$newPrice = ($storedPrice * $storedQty + $price * $qty) / $newQty;
|
519 |
+
|
520 |
+
$storedItem->setQuantity($newQty);
|
521 |
+
$storedItem->setPrice($newPrice);
|
522 |
+
|
523 |
+
$found = true;
|
524 |
+
break;
|
525 |
+
}
|
526 |
+
}
|
527 |
+
|
528 |
+
if (!$found) {
|
529 |
+
$cartItem = Mage::getModel('recsins/cartProduct');
|
530 |
+
|
531 |
+
$cartItem->setProduct_id($productId);
|
532 |
+
$cartItem->setQuantity($qty);
|
533 |
+
$cartItem->setPrice($price);
|
534 |
+
|
535 |
+
$cartItems[] = $cartItem;
|
536 |
+
}
|
537 |
+
}
|
538 |
+
|
539 |
+
$bsCart->setProducts($cartItems);
|
540 |
+
$client->addCart($bsCart);
|
541 |
+
}
|
542 |
+
} else {
|
543 |
+
//empty cart -> nothing to upload
|
544 |
+
}
|
545 |
+
}
|
546 |
+
}
|
547 |
+
$result = $client->sendFullCarts();
|
548 |
+
return $result;
|
549 |
+
}
|
550 |
+
|
551 |
+
public function trackCheckoutBegin($userId) {
|
552 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
553 |
+
$client = Mage::getSingleton("recsins/client", array("server" => $this->server, "storeKey" => $key));
|
554 |
+
|
555 |
+
$result = $client->beginCheckout($userId);
|
556 |
+
}
|
557 |
+
|
558 |
+
public function trackCheckoutSuccess($order, $user) {
|
559 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
560 |
+
$client = Mage::getSingleton("recsins/client", array("server" => $this->server, "storeKey" => $key));
|
561 |
+
|
562 |
+
$idOrder;
|
563 |
+
|
564 |
+
$total = 0;
|
565 |
+
|
566 |
+
$idsMultipleArray = Mage::getSingleton('core/session')->getOrderIds(true);
|
567 |
+
$firstElement = true;
|
568 |
+
|
569 |
+
if ($idsMultipleArray && is_array($idsMultipleArray)) {
|
570 |
+
foreach ($idsMultipleArray as $id) {
|
571 |
+
if ($firstElement) {
|
572 |
+
$idOrder = $id;
|
573 |
+
$firstElement = false;
|
574 |
+
}
|
575 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($id);
|
576 |
+
$total += $order->getSubtotal();
|
577 |
+
}
|
578 |
+
} else {
|
579 |
+
$idOrder = $order->getIncrementId();
|
580 |
+
$total = $order->getSubtotal();
|
581 |
+
//$total = $order->getBase_grand_total();
|
582 |
+
}
|
583 |
+
|
584 |
+
$result = $client->endCheckout($idOrder, $user, $total);
|
585 |
+
|
586 |
+
return $result;
|
587 |
+
}
|
588 |
+
|
589 |
+
public function sendUpdatedUser($idUser, $email) {
|
590 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
591 |
+
$client = Mage::getModel("recsins/client", array("server" => $this->server, "storeKey" => $key));
|
592 |
+
$user = Mage::getModel('recsins/user', array('user_id' => $idUser, 'email' => $email));
|
593 |
+
$res = $client->sendUser($idUser, $email);
|
594 |
+
return $res;
|
595 |
+
}
|
596 |
+
|
597 |
+
public function checkNewUser($customer) {
|
598 |
+
|
599 |
+
if (!isset($customer) || !$customer) {
|
600 |
+
return;
|
601 |
+
}
|
602 |
+
|
603 |
+
$lastId = Mage::getStoreConfig('brainsins/BS_LAST_CUSTOMER_ID_UPLOADED');
|
604 |
+
$idUser = $customer->getId();
|
605 |
+
$email = "";
|
606 |
+
|
607 |
+
if (!isset($lastId) || !$lastId || $idUser > $lastId) {
|
608 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_LAST_CUSTOMER_ID_UPLOADED', $idUser);
|
609 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
610 |
+
$client = Mage::getSingleton("recsins/client", array("server" => $this->server, "storeKey" => $key));
|
611 |
+
|
612 |
+
$subscriber = Mage::getModel("newsletter/subscriber");
|
613 |
+
$subscriber->loadByCustomer($customer);
|
614 |
+
|
615 |
+
if ($subscriber->isSubscribed()) {
|
616 |
+
$email = $subscriber->getEmail();
|
617 |
+
}
|
618 |
+
|
619 |
+
$user = Mage::getModel('recsins/user', array('user_id' => $idUser, 'email' => $email));
|
620 |
+
|
621 |
+
$client->addUser($user);
|
622 |
+
$client->sendUsers();
|
623 |
+
$res = $client->sendUserLogin($idUser, $_COOKIE['coId']);
|
624 |
+
|
625 |
+
setcookie("ul", 1);
|
626 |
+
setcookie("uId", $idUser);
|
627 |
+
|
628 |
+
return true;
|
629 |
+
} else {
|
630 |
+
return false;
|
631 |
+
}
|
632 |
+
}
|
633 |
+
|
634 |
+
public function log($message) {
|
635 |
+
$pathToBsLogDir = Mage::getBaseDir('base') . "/errors/bsins";
|
636 |
+
|
637 |
+
if (isset($pathToBsLogDir) && !is_dir($pathToBsLogDir)) {
|
638 |
+
mkdir($pathToBsLogDir);
|
639 |
+
}
|
640 |
+
|
641 |
+
if (isset($pathToBsLogDir) && is_dir($pathToBsLogDir)) {
|
642 |
+
$f = fopen($pathToBsLogDir . "/bslog.txt", "a");
|
643 |
+
if ($f !== false) {
|
644 |
+
fwrite($f, "[" . date('j-m-y H:m:s') . "] -> ");
|
645 |
+
fwrite($f, $message);
|
646 |
+
fwrite($f, PHP_EOL);
|
647 |
+
}
|
648 |
+
}
|
649 |
+
}
|
650 |
+
|
651 |
+
}
|
app/code/community/Brainsins/Recsins/Model/Recsins_1.php
ADDED
@@ -0,0 +1,569 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Model_Recsins extends Mage_Core_Model_Abstract {
|
28 |
+
|
29 |
+
private $bsClient;
|
30 |
+
//private $dev = true;
|
31 |
+
private $dev = false;
|
32 |
+
private $server;
|
33 |
+
|
34 |
+
protected function _construct() {
|
35 |
+
parent::_construct();
|
36 |
+
$this->_init('recsins/recsins');
|
37 |
+
|
38 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
39 |
+
|
40 |
+
|
41 |
+
if ($this->dev) {
|
42 |
+
$this->server = "dev-api.brainsins.com";
|
43 |
+
} else {
|
44 |
+
$this->server = "api.brainsins.com";
|
45 |
+
}
|
46 |
+
|
47 |
+
$this->bsClient = Mage::getSingleton("recsins/client", array("server" => $this->server, "storeKey" => $key));
|
48 |
+
}
|
49 |
+
|
50 |
+
public function importRecommenders() {
|
51 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
52 |
+
$client = Mage::getSingleton("recsins/client", array("server" => $this->server, "storeKey" => $key));
|
53 |
+
|
54 |
+
$recommenders = simplexml_load_string($client->getAllRecommenders());
|
55 |
+
$result = false;
|
56 |
+
if (isset($recommenders) && isset($recommenders->recommenders)) {
|
57 |
+
//delete previous recommenders
|
58 |
+
|
59 |
+
$collection = Mage::getModel('recsins/recommender')->getCollection();
|
60 |
+
|
61 |
+
foreach ($collection as $recModel) {
|
62 |
+
$recModel->delete();
|
63 |
+
}
|
64 |
+
|
65 |
+
foreach ($recommenders->recommenders->recommender as $recommender) {
|
66 |
+
|
67 |
+
$recModel = Mage::getModel('recsins/recommender');
|
68 |
+
$recModel->setRecommender_id($recommender->id_recommender);
|
69 |
+
$recModel->setRecommender_name($recommender->name);
|
70 |
+
$recModel->setRecommender_page($recommender->page);
|
71 |
+
|
72 |
+
$recModel->save();
|
73 |
+
}
|
74 |
+
|
75 |
+
$result = true;
|
76 |
+
}
|
77 |
+
return $result;
|
78 |
+
}
|
79 |
+
|
80 |
+
public function uploadCatalogUsers($pageSize, $lastPage, $firstTransaction = false) {
|
81 |
+
|
82 |
+
$lastCustomerId = 0;
|
83 |
+
|
84 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
85 |
+
$client = Mage::getSingleton("recsins/client", array("server" => $this->server, "storeKey" => $key));
|
86 |
+
|
87 |
+
$customers = Mage::getModel("customer/customer")->getCollection()->addAttributeToSelect('*')->setPage($lastPage + 1, $pageSize);
|
88 |
+
|
89 |
+
$result = true;
|
90 |
+
|
91 |
+
$firstUploadChanged = false;
|
92 |
+
|
93 |
+
foreach ($customers as $customer) {
|
94 |
+
|
95 |
+
if ($firstTransaction && !$firstUploadChanged) {
|
96 |
+
$firstUploadChanged = true;
|
97 |
+
Mage::getModel('core/config')->saveConfig('brainsins/FIRST_TRANSACTION', '0');
|
98 |
+
}
|
99 |
+
|
100 |
+
$user = Mage::getModel('recsins/user', array('user_id' => $customer->getId(), 'email' => $customer->getEmail()));
|
101 |
+
$client->addUser($user);
|
102 |
+
}
|
103 |
+
|
104 |
+
$result = $client->sendUsers($firstTransaction);
|
105 |
+
Mage::getModel('core/config')->saveConfig('brainsins/LAST_PAGE_SENT', $lastPage + 1);
|
106 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_LAST_CUSTOMER_ID_UPLOADED', $lastCustomerId);
|
107 |
+
|
108 |
+
return $result;
|
109 |
+
}
|
110 |
+
|
111 |
+
public function uploadCatalogProducts($pageSize, $lastPage, $firstTransaction = false, $uploadOutOfStock = false) {
|
112 |
+
$stores = Mage::app()->getStore()->getCollection();
|
113 |
+
|
114 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
115 |
+
$client = Mage::getSingleton("recsins/client", array("server" => $this->server, "storeKey" => $key));
|
116 |
+
|
117 |
+
$transactionCounter = 0;
|
118 |
+
|
119 |
+
$result = true;
|
120 |
+
|
121 |
+
//get first store id
|
122 |
+
$firstStoreId = $stores->getFirstItem();
|
123 |
+
|
124 |
+
if ($firstStoreId) {
|
125 |
+
$firstStoreId = $firstStoreId->getId();
|
126 |
+
} else {
|
127 |
+
return;
|
128 |
+
}
|
129 |
+
|
130 |
+
if (!isset($firstStoreId)) {
|
131 |
+
return;
|
132 |
+
}
|
133 |
+
|
134 |
+
$client->resetAll();
|
135 |
+
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->setPage($lastPage + 1, $pageSize)->addPriceData(null, $firstStoreId);
|
136 |
+
|
137 |
+
$firstUploadChanged = false;
|
138 |
+
|
139 |
+
|
140 |
+
foreach ($products as $product) {
|
141 |
+
$id = $product->getId();
|
142 |
+
|
143 |
+
$visibility = $product->getVisibility();
|
144 |
+
$configurable_product_model = Mage::getModel('catalog/product_type_configurable');
|
145 |
+
$parentIdArray = $configurable_product_model->getParentIdsByChild($product->getId());
|
146 |
+
|
147 |
+
if (!$uploadOutOfStock && (!Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getIs_in_stock() || Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty() <= 0)) {
|
148 |
+
continue;
|
149 |
+
}
|
150 |
+
|
151 |
+
if ($firstTransaction && !$firstUploadChanged) {
|
152 |
+
$firstUploadChanged = true;
|
153 |
+
Mage::getModel('core/config')->saveConfig('brainsins/FIRST_TRANSACTION', '0');
|
154 |
+
}
|
155 |
+
|
156 |
+
|
157 |
+
if (count($parentIdArray) == 0 && $visibility > 1 && $product->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_ENABLED) {
|
158 |
+
|
159 |
+
$bsProduct = Mage::getModel('recsins/product');
|
160 |
+
|
161 |
+
|
162 |
+
$bsProduct->setIsMultilanguage(true);
|
163 |
+
|
164 |
+
$names = array();
|
165 |
+
$descriptions = array();
|
166 |
+
$urls = array();
|
167 |
+
|
168 |
+
$bsProduct->setProduct_id($product->getId());
|
169 |
+
$bsProduct->setPrice($product->getPrice());
|
170 |
+
|
171 |
+
if ($product->getPrice() == 0.0 && $product->getTypeId() == "bundle") {
|
172 |
+
list($minPrice, $maxPrice) = $product->getPriceModel()->getPrices($product);
|
173 |
+
$bsProduct->setPrice($minPrice);
|
174 |
+
}
|
175 |
+
|
176 |
+
$categoryList = array();
|
177 |
+
$categoryIds = $product->getCategoryIds();
|
178 |
+
|
179 |
+
|
180 |
+
if (isset($categoryIds) && is_array($categoryIds)) {
|
181 |
+
foreach ($categoryIds as $catId) {
|
182 |
+
$category = Mage::getModel('catalog/category')->load($catId);
|
183 |
+
$parents = $category->getParentIds();
|
184 |
+
|
185 |
+
if (!in_array($catId, $categoryList)) {
|
186 |
+
$categoryList[] = $catId;
|
187 |
+
}
|
188 |
+
|
189 |
+
if (isset($parents) && is_array($parents)) {
|
190 |
+
foreach ($parents as $parent) {
|
191 |
+
if (!in_array($parent, $categoryList)) {
|
192 |
+
$categoryList[] = $parent;
|
193 |
+
}
|
194 |
+
}
|
195 |
+
}
|
196 |
+
//$categoryList = array_unique(array_merge($categoryList, $parents));
|
197 |
+
}
|
198 |
+
}
|
199 |
+
$bsProduct->setCategories($categoryList);
|
200 |
+
|
201 |
+
//TODO depends on a parameter!!!
|
202 |
+
$resize = false;
|
203 |
+
$width = 0;
|
204 |
+
$heigth = 0;
|
205 |
+
|
206 |
+
$imageSelectedOption = Mage::getStoreConfig('brainsins/BS_IMAGE_RESIZE');
|
207 |
+
if (isset($imageSelectedOption) && $imageSelectedOption == 'image_resize') {
|
208 |
+
$resize = true;
|
209 |
+
}
|
210 |
+
|
211 |
+
$imageSelectedWidth = Mage::getStoreConfig('brainsins/BS_IMAGE_RESIZE_WIDTH');
|
212 |
+
$imageSelectedHeigth = Mage::getStoreConfig('brainsins/BS_IMAGE_RESIZE_HEIGTH');
|
213 |
+
|
214 |
+
if (isset($imageSelectedWidth) && is_numeric($imageSelectedWidth) && $imageSelectedWidth > 0) {
|
215 |
+
$width = $imageSelectedWidth;
|
216 |
+
}
|
217 |
+
|
218 |
+
if (isset($imageSelectedHeigth) && is_numeric($imageSelectedHeigth) && $imageSelectedHeigth > 0) {
|
219 |
+
$heigth = $imageSelectedHeigth;
|
220 |
+
}
|
221 |
+
|
222 |
+
if ($resize && $width > 0) {
|
223 |
+
$prodImage = $product->getSmallImage();
|
224 |
+
if (isset($prodImage) && $prodImage != null && $prodImage != "no_selection") {
|
225 |
+
if ($heigth > 0) {
|
226 |
+
$bsProduct->setImage_url((string)Mage::helper('catalog/image')->init($product, "image")->resize($width, $heigth));
|
227 |
+
} else {
|
228 |
+
$bsProduct->setImage_url((string)Mage::helper('catalog/image')->init($product, "image")->resize($width));
|
229 |
+
}
|
230 |
+
}
|
231 |
+
} else {
|
232 |
+
$prodImage = $product->getSmallImage();
|
233 |
+
if (isset($prodImage) && $prodImage != null && $prodImage != "no_selection") {
|
234 |
+
$bsProduct->setImage_url((string)Mage::helper('catalog/image')->init($product, "image"));
|
235 |
+
}
|
236 |
+
}
|
237 |
+
|
238 |
+
foreach ($stores as $store) {
|
239 |
+
$storeCode = $store->getCode();
|
240 |
+
$storeId = $store->getId();
|
241 |
+
|
242 |
+
$product->setStoreId($storeId);
|
243 |
+
$product->load($id);
|
244 |
+
|
245 |
+
$names[$storeCode] = utf8_decode($product->getName());
|
246 |
+
$descriptions[$storeCode] = utf8_decode($product->getShortDescription());
|
247 |
+
$urls[$storeCode] = $product->getProductUrl();
|
248 |
+
}
|
249 |
+
|
250 |
+
$bsProduct->setNames($names);
|
251 |
+
$bsProduct->setDescriptions($descriptions);
|
252 |
+
$bsProduct->setUrls($urls);
|
253 |
+
|
254 |
+
$client->addProduct($bsProduct);
|
255 |
+
} else {
|
256 |
+
//this product is a configuration of a more general product(id)
|
257 |
+
// or a non visible product
|
258 |
+
}
|
259 |
+
}
|
260 |
+
Mage::getModel('core/config')->saveConfig('brainsins/LAST_PAGE_SENT', $lastPage + 1);
|
261 |
+
$result = $client->sendProducts($firstTransaction);
|
262 |
+
return $result;
|
263 |
+
}
|
264 |
+
|
265 |
+
private function getNextFakeId($lastFakeId) {
|
266 |
+
if (!isset($lastFakeId) || $lastFakeId == 0) {
|
267 |
+
return 999999999999;
|
268 |
+
} else {
|
269 |
+
return $lastFakeId - 1;
|
270 |
+
}
|
271 |
+
}
|
272 |
+
|
273 |
+
public function uploadCatalogQuotes($pageSize, $lastPage, $lastFakeId = 0, $firstTransaction = false) {
|
274 |
+
|
275 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
276 |
+
$client = Mage::getSingleton("recsins/client", array("server" => $this->server, "storeKey" => $key));
|
277 |
+
|
278 |
+
$quotes = Mage::getModel('sales/quote')->getCollection()->setPageSize($pageSize)->setCurPage($lastPage + 1); //($lastPage + 1, 1);
|
279 |
+
foreach ($quotes as $quote) {
|
280 |
+
|
281 |
+
$quote->load($quote->getId());
|
282 |
+
$items = $quote->getAllItems();
|
283 |
+
$idCustomer = $quote->getCustomerId();
|
284 |
+
|
285 |
+
if (!isset($idCustomer)) {
|
286 |
+
$lastFakeId = $this->getNextFakeId($lastFakeId);
|
287 |
+
$idCustomer = $lastFakeId;
|
288 |
+
}
|
289 |
+
$bsCart = Mage::getModel('recsins/cart');
|
290 |
+
$bsCart->setIdCart($quote->getId());
|
291 |
+
$bsCart->setIdUser($idCustomer);
|
292 |
+
$bsCart->setStartDate($quote->getCreated_at());
|
293 |
+
$bsCart->setFinishDate($quote->getUpdated_at());
|
294 |
+
|
295 |
+
$cartItems = array();
|
296 |
+
foreach ($items as $item) {
|
297 |
+
|
298 |
+
if ($item->getParentItemId()) {
|
299 |
+
continue;
|
300 |
+
}
|
301 |
+
|
302 |
+
//TODO ? $product = $item->getProduct();
|
303 |
+
$qty = $item->getQty();
|
304 |
+
$price = $item->getPrice();
|
305 |
+
$idProduct = $item->getProduct_id();
|
306 |
+
|
307 |
+
if (array_key_exists($idProduct, $cartItems)) {
|
308 |
+
$newQty = $cartItems[$idProduct]['qty'] + $qty;
|
309 |
+
$newPrice = ($cartItems[$idProduct]['price'] * $cartItems[$idProduct]['qty'] + $price * $qty) / $newQty;
|
310 |
+
$cartItems[$idProduct]['qty'] = $newQty;
|
311 |
+
$cartItems[$idProduct]['price'] = $newPrice;
|
312 |
+
} else {
|
313 |
+
$cartItems[$idProduct] = array();
|
314 |
+
$cartItems[$idProduct]['qty'] = $qty;
|
315 |
+
$cartItems[$idProduct]['price'] = $price;
|
316 |
+
}
|
317 |
+
}
|
318 |
+
|
319 |
+
$bsCart->setProducts($cartItems);
|
320 |
+
$client->addCart($bsCart);
|
321 |
+
}
|
322 |
+
|
323 |
+
Mage::getModel('core/config')->saveConfig('brainsins/LAST_PAGE_SENT', $lastPage + 1);
|
324 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_LAST_FAKE_ID', $lastFakeId);
|
325 |
+
return $client->sendCatalogCarts($firstTransaction);
|
326 |
+
}
|
327 |
+
|
328 |
+
public function uploadCatalogOrders($pageSize, $lastPage, $lastFakeId, $firstTransaction = false) {
|
329 |
+
|
330 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
331 |
+
$client = Mage::getSingleton("recsins/client", array("server" => $this->server, "storeKey" => $key));
|
332 |
+
|
333 |
+
$orders = Mage::getModel('sales/order')->getCollection()->setPageSize($pageSize)->setCurPage($lastPage + 1);
|
334 |
+
|
335 |
+
foreach ($orders as $order) {
|
336 |
+
|
337 |
+
$order->load($order->getId());
|
338 |
+
$idCustomer = $order->getCustomer_id();
|
339 |
+
$quoteId = $order->getQuote_id();
|
340 |
+
|
341 |
+
if (!isset($idCustomer)) {
|
342 |
+
$idCustomer = $this->getNextFakeId($lastFakeId);
|
343 |
+
}
|
344 |
+
|
345 |
+
$bsOrder = Mage::getModel('recsins/order');
|
346 |
+
$bsOrder->setIdPurchase($order->getIncrementId());
|
347 |
+
$bsOrder->setIdCart($quoteId);
|
348 |
+
$bsOrder->setIdUser($idCustomer);
|
349 |
+
$bsOrder->setDate($order->getCreated_at());
|
350 |
+
$bsOrder->setAmount($order->getSubtotal());
|
351 |
+
|
352 |
+
$bsCart = Mage::getModel('recsins/cart');
|
353 |
+
$bsCart->setIdCart($quoteId);
|
354 |
+
$bsCart->setIdUser($idCustomer);
|
355 |
+
$bsCart->setStartDate($order->getCreated_at());
|
356 |
+
$bsCart->setFinishDate($order->getCreated_at());
|
357 |
+
|
358 |
+
$orderItems = array();
|
359 |
+
$cartItems = array();
|
360 |
+
|
361 |
+
$items = $order->getAllItems();
|
362 |
+
foreach ($items as $item) {
|
363 |
+
|
364 |
+
if ($item->getParentItemId()) {
|
365 |
+
continue;
|
366 |
+
}
|
367 |
+
|
368 |
+
$idProduct = $item->getProduct_id();
|
369 |
+
$price = $item->getPrice();
|
370 |
+
$qty = (int) $item->getQty_ordered();
|
371 |
+
|
372 |
+
if (array_key_exists($idProduct, $orderItems)) {
|
373 |
+
$newQty = $orderItems[$idProduct]['qty'] + $qty;
|
374 |
+
$newPrice = ($orderItems[$idProduct]['price'] * $orderItems[$idProduct]['qty'] + $price * $qty) / $newQty;
|
375 |
+
$orderItems[$idProduct]['qty'] = $newQty;
|
376 |
+
$orderItems[$idProduct]['price'] = $newPrice;
|
377 |
+
$cartItems[$idProduct]['qty'] = $newQty;
|
378 |
+
$cartItems[$idProduct]['price'] = $newPrice;
|
379 |
+
} else {
|
380 |
+
$orderItems[$idProduct] = array();
|
381 |
+
$cartItems[$idProduct] = array();
|
382 |
+
$orderItems[$idProduct]['qty'] = $qty;
|
383 |
+
$orderItems[$idProduct]['price'] = $price;
|
384 |
+
$cartItems[$idProduct]['qty'] = $qty;
|
385 |
+
$cartItems[$idProduct]['price'] = $price;
|
386 |
+
}
|
387 |
+
}
|
388 |
+
|
389 |
+
$bsCart->setProducts($cartItems);
|
390 |
+
$bsOrder->setProducts($orderItems);
|
391 |
+
|
392 |
+
$client->addCart($bsCart);
|
393 |
+
$client->addOrder($bsOrder);
|
394 |
+
}
|
395 |
+
|
396 |
+
$result = $client->sendCatalogCarts();
|
397 |
+
$result = $result && $client->sendCatalogPurchases($firstTransaction);
|
398 |
+
|
399 |
+
Mage::getModel('core/config')->saveConfig('brainsins/LAST_PAGE_SENT', $lastPage + 1);
|
400 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_LAST_FAKE_ID', $lastFakeId);
|
401 |
+
return $result;
|
402 |
+
}
|
403 |
+
|
404 |
+
public function uploadQuotes($quotes, $userId = null) {
|
405 |
+
|
406 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
407 |
+
$client = Mage::getSingleton("recsins/client", array("server" => $this->server, "storeKey" => $key));
|
408 |
+
|
409 |
+
foreach ($quotes as $quote) {
|
410 |
+
|
411 |
+
$orderId = $quote->getOrig_order_id();
|
412 |
+
if ($orderId == 0) {
|
413 |
+
$orderId = $quote->getReserved_order_id();
|
414 |
+
}
|
415 |
+
|
416 |
+
if ($orderId == 0) {
|
417 |
+
$items = $quote->getAllItems();
|
418 |
+
|
419 |
+
if (count($items) > 0) {
|
420 |
+
$idCustomer = $userId ? $userId : $quote->getCustomer()->getId();
|
421 |
+
if ($idCustomer) {
|
422 |
+
|
423 |
+
$cartCustomerId = $userId ? $userId : $quote->getCustomer()->getId();
|
424 |
+
|
425 |
+
$bsCart = Mage::getModel('recsins/cart');
|
426 |
+
$bsCart->setIdCart($quote->getId());
|
427 |
+
$bsCart->setUserId($cartCustomerId);
|
428 |
+
|
429 |
+
$bsCart->setStart_date($quote->getCreated_at());
|
430 |
+
$bsCart->setFinish_date($quote->getUpdated_at());
|
431 |
+
$cartItems = array();
|
432 |
+
|
433 |
+
|
434 |
+
foreach ($items as $item) {
|
435 |
+
if ($item->getParentItemId()) {
|
436 |
+
continue;
|
437 |
+
}
|
438 |
+
|
439 |
+
$qty = $item->getQty();
|
440 |
+
$price = $item->getPrice();
|
441 |
+
|
442 |
+
|
443 |
+
$product = $item->getProduct();
|
444 |
+
|
445 |
+
$productId = $product->getId();
|
446 |
+
$configurable_product_model = Mage::getModel('catalog/product_type_configurable');
|
447 |
+
$parentIdArray = $configurable_product_model->getParentIdsByChild($productId);
|
448 |
+
|
449 |
+
$found = false;
|
450 |
+
|
451 |
+
foreach ($cartItems as $storedItem) {
|
452 |
+
|
453 |
+
if ($productId == $storedItem->getProduct_id()) {
|
454 |
+
|
455 |
+
$storedQty = $storedItem->getQuantity();
|
456 |
+
$storedPrice = $storedItem->getPrice();
|
457 |
+
|
458 |
+
$newQty = $storedQty + $qty;
|
459 |
+
$newPrice = ($storedPrice * $storedQty + $price * $qty) / $newQty;
|
460 |
+
|
461 |
+
$storedItem->setQuantity($newQty);
|
462 |
+
$storedItem->setPrice($newPrice);
|
463 |
+
|
464 |
+
$found = true;
|
465 |
+
break;
|
466 |
+
}
|
467 |
+
}
|
468 |
+
|
469 |
+
if (!$found) {
|
470 |
+
$cartItem = Mage::getModel('recsins/cartProduct');
|
471 |
+
|
472 |
+
$cartItem->setProduct_id($productId);
|
473 |
+
$cartItem->setQuantity($qty);
|
474 |
+
$cartItem->setPrice($price);
|
475 |
+
|
476 |
+
$cartItems[] = $cartItem;
|
477 |
+
}
|
478 |
+
}
|
479 |
+
|
480 |
+
$bsCart->setProducts($cartItems);
|
481 |
+
$client->addCart($bsCart);
|
482 |
+
}
|
483 |
+
} else {
|
484 |
+
//empty cart -> nothing to upload
|
485 |
+
}
|
486 |
+
}
|
487 |
+
}
|
488 |
+
$result = $client->sendFullCarts();
|
489 |
+
return $result;
|
490 |
+
}
|
491 |
+
|
492 |
+
public function trackCheckoutBegin($userId) {
|
493 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
494 |
+
$client = Mage::getSingleton("recsins/client", array("server" => $this->server, "storeKey" => $key));
|
495 |
+
|
496 |
+
$result = $client->beginCheckout($userId);
|
497 |
+
}
|
498 |
+
|
499 |
+
public function trackCheckoutSuccess($order, $user) {
|
500 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
501 |
+
$client = Mage::getSingleton("recsins/client", array("server" => $this->server, "storeKey" => $key));
|
502 |
+
|
503 |
+
$idOrder;
|
504 |
+
|
505 |
+
$total = 0;
|
506 |
+
|
507 |
+
$idsMultipleArray = Mage::getSingleton('core/session')->getOrderIds(true);
|
508 |
+
$firstElement = true;
|
509 |
+
|
510 |
+
if ($idsMultipleArray && is_array($idsMultipleArray)) {
|
511 |
+
foreach ($idsMultipleArray as $id) {
|
512 |
+
if ($firstElement) {
|
513 |
+
$idOrder = $id;
|
514 |
+
$firstElement = false;
|
515 |
+
}
|
516 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($id);
|
517 |
+
$total += $order->getSubtotal();
|
518 |
+
}
|
519 |
+
} else {
|
520 |
+
$idOrder = $order->getIncrementId();
|
521 |
+
$total = $order->getSubtotal();
|
522 |
+
//$total = $order->getBase_grand_total();
|
523 |
+
}
|
524 |
+
|
525 |
+
$result = $client->endCheckout($idOrder, $user, $total);
|
526 |
+
|
527 |
+
return $result;
|
528 |
+
}
|
529 |
+
|
530 |
+
public function checkNewUser($idUser, $email) {
|
531 |
+
$lastId = Mage::getStoreConfig('brainsins/BS_LAST_CUSTOMER_ID_UPLOADED');
|
532 |
+
|
533 |
+
if (!$lastId || $idUser > $lastId) {
|
534 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_LAST_CUSTOMER_ID_UPLOADED', $idUser);
|
535 |
+
$key = Mage::getStoreConfig('brainsins/BSKEY');
|
536 |
+
$client = Mage::getSingleton("recsins/client", array("server" => $this->server, "storeKey" => $key));
|
537 |
+
$user = Mage::getModel('recsins/user', array('user_id' => $idUser, 'email' => $email));
|
538 |
+
|
539 |
+
$client->addUser($user);
|
540 |
+
$client->sendUsers();
|
541 |
+
$res = $client->sendUserLogin($idUser, $_COOKIE['coId']);
|
542 |
+
|
543 |
+
setcookie("ul", 1);
|
544 |
+
setcookie("uId", $idUser);
|
545 |
+
|
546 |
+
return true;
|
547 |
+
} else {
|
548 |
+
return false;
|
549 |
+
}
|
550 |
+
}
|
551 |
+
|
552 |
+
public function log($message) {
|
553 |
+
$pathToBsLogDir = Mage::getBaseDir('base') . "/errors/bsins";
|
554 |
+
|
555 |
+
if (isset($pathToBsLogDir) && !is_dir($pathToBsLogDir)) {
|
556 |
+
mkdir($pathToBsLogDir);
|
557 |
+
}
|
558 |
+
|
559 |
+
if (isset($pathToBsLogDir) && is_dir($pathToBsLogDir)) {
|
560 |
+
$f = fopen($pathToBsLogDir . "/bslog.txt", "a");
|
561 |
+
if ($f !== false) {
|
562 |
+
fwrite($f, "[" . date('j-m-y H:m:s') . "] -> ");
|
563 |
+
fwrite($f, $message);
|
564 |
+
fwrite($f, PHP_EOL);
|
565 |
+
}
|
566 |
+
}
|
567 |
+
}
|
568 |
+
|
569 |
+
}
|
app/code/community/Brainsins/Recsins/Model/Resource/Eav/Mysql4/Recommender.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Model_Resource_Eav_Mysql4_Recommender extends Mage_Eav_Model_Entity_Abstract {
|
28 |
+
|
29 |
+
public function _construct() {
|
30 |
+
$resource = Mage::getSingleton('core/resource');
|
31 |
+
$this->setType('recsins_recommender');
|
32 |
+
$this->setConnection($resource->getConnection('recsins_read'), $resource->getConnection('recsins_write'));
|
33 |
+
}
|
34 |
+
}
|
app/code/community/Brainsins/Recsins/Model/Resource/Eav/Mysql4/Recommender/Collection.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Model_Resource_Eav_Mysql4_Recommender_Collection extends Mage_Eav_Model_Entity_Collection_Abstract {
|
28 |
+
|
29 |
+
protected function _construct() {
|
30 |
+
$this->_init('recsins/recommender');
|
31 |
+
}
|
32 |
+
}
|
app/code/community/Brainsins/Recsins/Model/Resource/Setup.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup {
|
28 |
+
|
29 |
+
}
|
app/code/community/Brainsins/Recsins/Model/Status.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Model_Status extends Varien_Object
|
28 |
+
{
|
29 |
+
const STATUS_ENABLED = 1;
|
30 |
+
const STATUS_DISABLED = 2;
|
31 |
+
|
32 |
+
static public function getOptionArray()
|
33 |
+
{
|
34 |
+
return array(
|
35 |
+
self::STATUS_ENABLED => Mage::helper('recsins')->__('Enabled'),
|
36 |
+
self::STATUS_DISABLED => Mage::helper('recsins')->__('Disabled')
|
37 |
+
);
|
38 |
+
}
|
39 |
+
}
|
app/code/community/Brainsins/Recsins/Model/User.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_Model_User extends Mage_Core_Model_Abstract {
|
28 |
+
|
29 |
+
private $user_id;
|
30 |
+
|
31 |
+
protected function _construct() {
|
32 |
+
$this->user_id = $this->_data['user_id'];
|
33 |
+
}
|
34 |
+
|
35 |
+
}
|
app/code/community/Brainsins/Recsins/brainsins.js.js
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
var xxx = "xxx";
|
2 |
+
|
app/code/community/Brainsins/Recsins/controllers/.DS_Store
ADDED
Binary file
|
app/code/community/Brainsins/Recsins/controllers/Adminhtml/.DS_Store
ADDED
Binary file
|
app/code/community/Brainsins/Recsins/controllers/Adminhtml/RecsinsController.php
ADDED
@@ -0,0 +1,697 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
function bsErrorHandler($errno, $errstr, $errfile, $errline) {
|
28 |
+
Mage::getModel('recsins/recsins')->log($errno . " | " . $errstr . " | " . $errfile . " at line " . $errline);
|
29 |
+
Mage::getModel('core/config')->saveConfig('brainsins/UPLOADING_STATUS', '0');
|
30 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATUS', '0');
|
31 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_HAS_ERRORS', '1');
|
32 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('recsins')->__('Catalog upload aborted due to unexpected error<br>See [storeUrl]/erros/bsins/bsinslog for details'));
|
33 |
+
Mage::getModel('core/config')->saveConfig('brainsins/LAST_PAGE_SENT', '0');
|
34 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_LAST_PAGE_SENT', '0');
|
35 |
+
return mageCoreErrorHandler($errno, $errstr, $errfile, $errline);
|
36 |
+
}
|
37 |
+
|
38 |
+
class Brainsins_Recsins_Adminhtml_RecsinsController extends Mage_Adminhtml_Controller_Action {
|
39 |
+
|
40 |
+
protected function _initAction() {
|
41 |
+
$this->loadLayout()
|
42 |
+
->_setActiveMenu('recsins/items')
|
43 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
44 |
+
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
|
48 |
+
public function indexAction() {
|
49 |
+
//TODO just for testing
|
50 |
+
$currentVersion = Mage::getStoreConfig('brainsins/BS_VERSION');
|
51 |
+
$lastVersion = Mage::getStoreConfig('brainsins/BS_LAST_AVAILABLE_VERSION');
|
52 |
+
if (isset($lastVersion) && isset($currentVersion)) {
|
53 |
+
if ($lastVersion > $currentVersion) {
|
54 |
+
Mage::getSingleton('adminhtml/session')->addWarning(Mage::helper('recsins')->__('There is a new Version Available: BrainSINS extension for Magento v') . $lastVersion);
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
$this->_initAction()
|
59 |
+
->renderLayout();
|
60 |
+
}
|
61 |
+
|
62 |
+
public function editAction() {
|
63 |
+
$id = $this->getRequest()->getParam('id');
|
64 |
+
$model = Mage::getModel('recsins/recsins')->load($id);
|
65 |
+
|
66 |
+
if ($model->getId() || $id == 0) {
|
67 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
68 |
+
if (!empty($data)) {
|
69 |
+
$model->setData($data);
|
70 |
+
}
|
71 |
+
|
72 |
+
Mage::register('recsins_data', $model);
|
73 |
+
|
74 |
+
$this->loadLayout();
|
75 |
+
$this->_setActiveMenu('recsins/items');
|
76 |
+
|
77 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
78 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
79 |
+
|
80 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
81 |
+
|
82 |
+
$this->_addContent($this->getLayout()->createBlock('recsins/adminhtml_recsins_edit'))
|
83 |
+
->_addLeft($this->getLayout()->createBlock('recsins/adminhtml_recsins_edit_tabs'));
|
84 |
+
|
85 |
+
$this->renderLayout();
|
86 |
+
} else {
|
87 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('recsins')->__('Item does not exist'));
|
88 |
+
$this->_redirect('*/*/');
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
public function newAction() {
|
93 |
+
$this->_forward('edit');
|
94 |
+
}
|
95 |
+
|
96 |
+
private function validateBSKey($key) {
|
97 |
+
$pattern = '/^BS-\d{10}-\d+$/';
|
98 |
+
if (preg_match($pattern, $key)) {
|
99 |
+
return true;
|
100 |
+
} else {
|
101 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('recsins')->__('"' . $key . '" is not a valid BS-KEY. The BS-KEY must be like "BS-0123456789-1"'));
|
102 |
+
return false;
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
public function saveAction() {
|
107 |
+
|
108 |
+
$old_error_handler = set_error_handler("bsErrorHandler");
|
109 |
+
|
110 |
+
try {
|
111 |
+
|
112 |
+
//throw new Exception("BSException: extrange category");
|
113 |
+
|
114 |
+
$data = $this->getRequest()->getPost();
|
115 |
+
|
116 |
+
if ($data) {
|
117 |
+
|
118 |
+
$key = $data['bskey_text'];
|
119 |
+
|
120 |
+
if (!$this->validateBSKey($key)) {
|
121 |
+
$this->_redirect('*/*/');
|
122 |
+
return;
|
123 |
+
}
|
124 |
+
|
125 |
+
if (isset($key)) {
|
126 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BSKEY', $key);
|
127 |
+
}
|
128 |
+
|
129 |
+
$enabled = $data['bsenableoptions'];
|
130 |
+
|
131 |
+
if ($enabled === '0') {
|
132 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_ENABLED', '0');
|
133 |
+
} else {
|
134 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_ENABLED', '1');
|
135 |
+
}
|
136 |
+
|
137 |
+
|
138 |
+
$homeRecommender;
|
139 |
+
$categoryRecommender;
|
140 |
+
$productRecommender;
|
141 |
+
$cartRecommender;
|
142 |
+
$checkoutRecommender;
|
143 |
+
|
144 |
+
if (array_key_exists('bshome_recommenders', $data)) {
|
145 |
+
$homeRecommender = $data['bshome_recommenders'];
|
146 |
+
} else {
|
147 |
+
$homeRecommender = 0;
|
148 |
+
}
|
149 |
+
|
150 |
+
if (array_key_exists('bscategory_recommenders', $data)) {
|
151 |
+
$categoryRecommender = $data['bscategory_recommenders'];
|
152 |
+
} else {
|
153 |
+
$categoryRecommender = 0;
|
154 |
+
}
|
155 |
+
|
156 |
+
if (array_key_exists('bsproduct_recommenders', $data)) {
|
157 |
+
$productRecommender = $data['bsproduct_recommenders'];
|
158 |
+
} else {
|
159 |
+
$productRecommender = 0;
|
160 |
+
}
|
161 |
+
|
162 |
+
if (array_key_exists('bscart_recommenders', $data)) {
|
163 |
+
$cartRecommender = $data['bscart_recommenders'];
|
164 |
+
} else {
|
165 |
+
$cartRecommender = 0;
|
166 |
+
}
|
167 |
+
|
168 |
+
if (array_key_exists('bscheckout_recommenders', $data)) {
|
169 |
+
$checkoutRecommender = $data['bscheckout_recommenders'];
|
170 |
+
} else {
|
171 |
+
$checkoutRecommender = 0;
|
172 |
+
}
|
173 |
+
|
174 |
+
if (isset($homeRecommender) && $homeRecommender !== null) {
|
175 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_HOME_RECOMMENDER', $homeRecommender);
|
176 |
+
}
|
177 |
+
|
178 |
+
if (isset($categoryRecommender) && $categoryRecommender !== null) {
|
179 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_CATEGORY_RECOMMENDER', $categoryRecommender);
|
180 |
+
}
|
181 |
+
|
182 |
+
if (isset($productRecommender) && $productRecommender !== null) {
|
183 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_PRODUCT_RECOMMENDER', $productRecommender);
|
184 |
+
}
|
185 |
+
|
186 |
+
if (isset($checkoutRecommender) && $checkoutRecommender !== null) {
|
187 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_CHECKOUT_RECOMMENDER', $checkoutRecommender);
|
188 |
+
}
|
189 |
+
|
190 |
+
if (isset($cartRecommender) && $cartRecommender !== null) {
|
191 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_CART_RECOMMENDER', $cartRecommender);
|
192 |
+
}
|
193 |
+
|
194 |
+
$pageSizeText = $data['bsadvanced'];
|
195 |
+
$pageSize = 50;
|
196 |
+
|
197 |
+
if (isset($pageSizeText) && $pageSizeText !== null) {
|
198 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_PAGE_SIZE', $pageSizeText);
|
199 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_BS_PAGE_SIZE', $pageSizeText);
|
200 |
+
if ($pageSizeText == 'page1') {
|
201 |
+
$pageSize = 1;
|
202 |
+
}
|
203 |
+
if ($pageSizeText == 'page10') {
|
204 |
+
$pageSize = 10;
|
205 |
+
}
|
206 |
+
if ($pageSizeText == 'page20') {
|
207 |
+
$pageSize = 20;
|
208 |
+
}
|
209 |
+
if ($pageSizeText == 'page50') {
|
210 |
+
$pageSize = 50;
|
211 |
+
}
|
212 |
+
if ($pageSizeText == 'page100') {
|
213 |
+
$pageSize = 100;
|
214 |
+
}
|
215 |
+
if ($pageSizeText == 'page200') {
|
216 |
+
$pageSize = 200;
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
$uploadOutOfStockProducts = false;
|
221 |
+
|
222 |
+
if (array_key_exists("out_of_stock_checkbox", $data)) {
|
223 |
+
$uploadOutOfStockValue = $data['out_of_stock_checkbox'];
|
224 |
+
if (isset($uploadOutOfStockValue) && $uploadOutOfStockValue == "checked") {
|
225 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_SEND_OUT_OF_STOCK_PRODUCTS', "1");
|
226 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_BS_SEND_OUT_OF_STOCK_PRODUCTS', "1");
|
227 |
+
} else {
|
228 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_SEND_OUT_OF_STOCK_PRODUCTS', "0");
|
229 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_BS_SEND_OUT_OF_STOCK_PRODUCTS', "0");
|
230 |
+
}
|
231 |
+
} else {
|
232 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_SEND_OUT_OF_STOCK_PRODUCTS', "0");
|
233 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_BS_SEND_OUT_OF_STOCK_PRODUCTS', "0");
|
234 |
+
}
|
235 |
+
|
236 |
+
if (array_key_exists("bsimageoptions", $data)) {
|
237 |
+
$resizeImages = $data['bsimageoptions'];
|
238 |
+
if (isset($resizeImages)) {
|
239 |
+
if ($resizeImages == 'image_no_resize') {
|
240 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_IMAGE_RESIZE', "image_no_resize");
|
241 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_BS_IMAGE_RESIZE', "image_no_resize");
|
242 |
+
} else if ($resizeImages == 'image_resize') {
|
243 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_IMAGE_RESIZE', "image_resize");
|
244 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_BS_IMAGE_RESIZE', "image_resize");
|
245 |
+
if (array_key_exists('image_width_text', $data) && isset($data['image_width_text'])) {
|
246 |
+
$width = $data['image_width_text'];
|
247 |
+
if (is_numeric($width) && $width > 0) {
|
248 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_IMAGE_RESIZE_WIDTH', $width);
|
249 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_BS_IMAGE_RESIZE_WIDTH', $width);
|
250 |
+
}
|
251 |
+
}
|
252 |
+
|
253 |
+
if (array_key_exists('image_heigth_text', $data) && isset($data['image_heigth_text'])) {
|
254 |
+
$heigth = $data['image_heigth_text'];
|
255 |
+
if (is_numeric($heigth) && $heigth > 0) {
|
256 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_IMAGE_RESIZE_HEIGTH', $heigth);
|
257 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_BS_IMAGE_RESIZE_HEIGTH', $heigth);
|
258 |
+
}
|
259 |
+
}
|
260 |
+
} else {
|
261 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_IMAGE_RESIZE', "image_no_resize");
|
262 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_BS_IMAGE_RESIZE', "image_no_resize");
|
263 |
+
}
|
264 |
+
}
|
265 |
+
}
|
266 |
+
|
267 |
+
if (array_key_exists("bsspecialpriceoptions", $data)) {
|
268 |
+
$specialPrice = $data['bsspecialpriceoptions'];
|
269 |
+
if (isset($specialPrice)) {
|
270 |
+
if ($specialPrice == 'special_price_yes') {
|
271 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_USE_SPECIAL_PRICE', "1");
|
272 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins/BS_USE_SPECIAL_PRICE', "1");
|
273 |
+
} else {
|
274 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_USE_SPECIAL_PRICE', "0");
|
275 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins/BS_USE_SPECIAL_PRICE', "0");
|
276 |
+
}
|
277 |
+
}
|
278 |
+
}
|
279 |
+
|
280 |
+
if (array_key_exists("bstaxpriceoptions", $data)) {
|
281 |
+
$taxPrice = $data['bstaxpriceoptions'];
|
282 |
+
if (isset($taxPrice)) {
|
283 |
+
if ($taxPrice == 'tax_price_equal') {
|
284 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_TAX_PRICE', "tax_price_equal");
|
285 |
+
} else if ($taxPrice == 'tax_price_plus') {
|
286 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_TAX_PRICE', "tax_price_plus");
|
287 |
+
} else if ($taxPrice == 'tax_price_minus') {
|
288 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_TAX_PRICE', "tax_price_minus");
|
289 |
+
} else {
|
290 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_TAX_PRICE', "tax_price_equal");
|
291 |
+
}
|
292 |
+
}
|
293 |
+
}
|
294 |
+
|
295 |
+
$importConfig = $data['import_config'];
|
296 |
+
if (isset($importConfig) && $importConfig == '1') {
|
297 |
+
|
298 |
+
$recsins = Mage::getSingleton('recsins/recsins');
|
299 |
+
$result = $recsins->importRecommenders();
|
300 |
+
if ($result === true) {
|
301 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('recsins')->__('Recommenders imported sucssessfully'));
|
302 |
+
} else {
|
303 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('recsins')->__('Error while importing recommenders'));
|
304 |
+
}
|
305 |
+
$this->_redirect('*/*/');
|
306 |
+
}
|
307 |
+
|
308 |
+
/*$uploadCatalog = $data['upload_catalog'];
|
309 |
+
|
310 |
+
if (isset($uploadCatalog) && $uploadCatalog == 'upload') {
|
311 |
+
Mage::getModel('core/config')->saveConfig('brainsins/LAST_PAGE_SENT', '0');
|
312 |
+
$this->uploadCatalog($pageSize);
|
313 |
+
$this->_redirect('* / * / ');
|
314 |
+
return;
|
315 |
+
} else if (isset($uploadCatalog) && $uploadCatalog == 'uploading') {
|
316 |
+
$this->uploadingCatalog($pageSize);
|
317 |
+
$this->_redirect('* / * / ');
|
318 |
+
return;
|
319 |
+
} else if (isset($uploadCatalog) && $uploadCatalog == 'abort') {
|
320 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_LAST_PAGE_SENT', '0');
|
321 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATUS', '0');
|
322 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('recsins')->__('Catalog upload aborted'));
|
323 |
+
$this->_redirect('* / * / ');
|
324 |
+
return;
|
325 |
+
} else {
|
326 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_LAST_PAGE_SENT', '0');
|
327 |
+
}*/
|
328 |
+
}
|
329 |
+
} catch (Exception $e) {
|
330 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATUS', '0');
|
331 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_HAS_ERRORS', '1');
|
332 |
+
Mage::getModel('recsins/recsins')->log($e);
|
333 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('recsins')->__('Catalog upload aborted due to unexpected exception<br>See [storeUrl]/erros/bsins/bsinslog for details'));
|
334 |
+
}
|
335 |
+
|
336 |
+
$this->_redirect('*/*/');
|
337 |
+
|
338 |
+
|
339 |
+
return;
|
340 |
+
}
|
341 |
+
|
342 |
+
public function deleteAction() {
|
343 |
+
$this->_redirect('*/*/');
|
344 |
+
}
|
345 |
+
|
346 |
+
public function massDeleteAction() {
|
347 |
+
$this->_redirect('*/*/index');
|
348 |
+
}
|
349 |
+
|
350 |
+
public function massStatusAction() {
|
351 |
+
$this->_redirect('*/*/index');
|
352 |
+
}
|
353 |
+
|
354 |
+
public function exportCsvAction() {
|
355 |
+
|
356 |
+
}
|
357 |
+
|
358 |
+
public function exportXmlAction() {
|
359 |
+
|
360 |
+
}
|
361 |
+
|
362 |
+
private function uploadCatalog($pageSize) {
|
363 |
+
|
364 |
+
$this->_redirect('*/*/');
|
365 |
+
return;
|
366 |
+
|
367 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATUS', '1');
|
368 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_LAST_PAGE_SENT', '0');
|
369 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATE', 'CLIENTS');
|
370 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_FIRST_TRANSACTION', '1');
|
371 |
+
|
372 |
+
$lastPageSent = Mage::getStoreConfig('brainsins/LAST_PAGE_SENT');
|
373 |
+
$this->uploadingCatalog($pageSize, 'CLIENTS');
|
374 |
+
|
375 |
+
return;
|
376 |
+
}
|
377 |
+
|
378 |
+
private function uploadingCatalog($pageSize, $state = null) {
|
379 |
+
|
380 |
+
$this->_redirect('*/*/');
|
381 |
+
return;
|
382 |
+
|
383 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATUS', '0');
|
384 |
+
$recsins = Mage::getSingleton('recsins/recsins');
|
385 |
+
$lastPageSent = Mage::getSingleton("core/session", array("name" => "adminhtml"))->getData('brainsins_LAST_PAGE_SENT');
|
386 |
+
|
387 |
+
if (!isset($state) || $state == null) {
|
388 |
+
$state = Mage::getSingleton("core/session", array("name" => "adminhtml"))->getData('brainsins_UPLOADING_STATE');
|
389 |
+
}
|
390 |
+
|
391 |
+
$firstTransaction = Mage::getSingleton("core/session", array("name" => "adminhtml"))->getData('brainsins_FIRST_TRANSACTION');
|
392 |
+
if (isset($firstTransaction)) {
|
393 |
+
$firstTransaction = isset($firstTransaction) && $firstTransaction == '1';
|
394 |
+
} else {
|
395 |
+
$firstTransaction = false;
|
396 |
+
}
|
397 |
+
|
398 |
+
/*$isFirstUpload = Mage::getStoreConfig('brainsins/BS_FIRST_CATALOG_UPLOAD');
|
399 |
+
if (isset($isFirstUpload)) {
|
400 |
+
$isFirstUpload = $isFirstUpload == '1';
|
401 |
+
} else {
|
402 |
+
$isFirstUpload = true;
|
403 |
+
}
|
404 |
+
|
405 |
+
$lastFakeId = 0;
|
406 |
+
|
407 |
+
$isFirstUpload = true;
|
408 |
+
|
409 |
+
if ($isFirstUpload === true) {
|
410 |
+
$lastFakeId = Mage::getStoreConfig('brainsins/BS_LAST_FAKE_ID');
|
411 |
+
if (!isset($lastFakeId)) {
|
412 |
+
$lastFakeId = 0;
|
413 |
+
} else {
|
414 |
+
|
415 |
+
}
|
416 |
+
}*/
|
417 |
+
|
418 |
+
|
419 |
+
if ($state === 'CLIENTS') {
|
420 |
+
|
421 |
+
$numItems = Mage::getModel('customer/customer')->getCollection()->count();
|
422 |
+
$res = $recsins->uploadCatalogUsers($pageSize, $lastPageSent, $firstTransaction);
|
423 |
+
//$lastPageSent = Mage::getSingleton("core/session", array("name" => "adminhtml"))->getData('brainsins_LAST_PAGE_SENT');
|
424 |
+
|
425 |
+
|
426 |
+
$hasErrors = Mage::getSingleton("core/session", array("name" => "adminhtml"))->getData('brainsins_UPLOADING_HAS_ERRORS');
|
427 |
+
if (isset($hasErrors) && $hasErrors == "1") {
|
428 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_HAS_ERRORS', '0');
|
429 |
+
return;
|
430 |
+
}
|
431 |
+
|
432 |
+
|
433 |
+
$continue = isset($res) && $res === true && $lastPageSent * $pageSize < $numItems;
|
434 |
+
|
435 |
+
if (!isset($res) || $res === false) {
|
436 |
+
$message = $this->getDisplayMessage('CLIENTS', 'ERROR');
|
437 |
+
Mage::getSingleton('adminhtml/session')->addError($message);
|
438 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATUS', '0');
|
439 |
+
} else if ($continue === true) {
|
440 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATUS', '1');
|
441 |
+
$percentage = number_format(($lastPageSent * $pageSize * 100) / $numItems, 1);
|
442 |
+
$message = $this->getDisplayMessage('CLIENTS', 'UPLOADING', $percentage);
|
443 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($message);
|
444 |
+
/*if ($isFirstUpload) {
|
445 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_FIRST_TRANSACTION', '0');
|
446 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_BS_LAST_FAKE_ID', '0');
|
447 |
+
}*/
|
448 |
+
} else {
|
449 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATUS', '1');
|
450 |
+
$message = $this->getDisplayMessage('CLIENTS', 'FINISHED');
|
451 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($message);
|
452 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATE', 'PRODUCTS');
|
453 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_LAST_PAGE_SENT', '0');
|
454 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_FIRST_TRANSACTION', '1');
|
455 |
+
}
|
456 |
+
|
457 |
+
return;
|
458 |
+
} else if ($state === 'PRODUCTS') {
|
459 |
+
|
460 |
+
$uploadOutOfStockValue = Mage::getStoreConfig('brainsins/BS_SEND_OUT_OF_STOCK_PRODUCTS');
|
461 |
+
$uploadOutOfStock = false;
|
462 |
+
if (isset($uploadOutOfStockValue) && $uploadOutOfStockValue == '1') {
|
463 |
+
$uploadOutOfStock = true;
|
464 |
+
}
|
465 |
+
|
466 |
+
$numItems = Mage::getModel('catalog/product')->getCollection()->count();
|
467 |
+
$res = $recsins->uploadCatalogProducts($pageSize, $lastPageSent, $firstTransaction, $uploadOutOfStock);
|
468 |
+
//$lastPageSent = Mage::getStoreConfig('brainsins/LAST_PAGE_SENT');
|
469 |
+
|
470 |
+
$hasErrors = Mage::getSingleton("core/session", array("name" => "adminhtml"))->getData('brainsins_UPLOADING_HAS_ERRORS');
|
471 |
+
if (isset($hasErrors) && $hasErrors == "1") {
|
472 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_HAS_ERRORS', '0');
|
473 |
+
return;
|
474 |
+
}
|
475 |
+
|
476 |
+
|
477 |
+
$continue = isset($res) && $res === true && $lastPageSent * $pageSize < $numItems;
|
478 |
+
|
479 |
+
if (!isset($res) || $res === false) {
|
480 |
+
$message = $this->getDisplayMessage('PRODUCTS', 'ERROR');
|
481 |
+
Mage::getSingleton('adminhtml/session')->addError($message);
|
482 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATUS', '0');
|
483 |
+
} else if ($continue === true) {
|
484 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATUS', '1');
|
485 |
+
$percentage = number_format(($lastPageSent * $pageSize * 100) / $numItems, 1);
|
486 |
+
$message = $this->getDisplayMessage('PRODUCTS', 'UPLOADING', $percentage);
|
487 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($message);
|
488 |
+
//first transacion is changed inside the recsins model only if at least a product is processed
|
489 |
+
} else {
|
490 |
+
$message = $this->getDisplayMessage('PRODUCTS', 'FINISHED');
|
491 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($message);
|
492 |
+
|
493 |
+
// upload products is always the last step
|
494 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATUS', '0');
|
495 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_LAST_PAGE_SENT', '0');
|
496 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_FIRST_TRANSACTION', '1');
|
497 |
+
//previous code considereing carts upload in first upload
|
498 |
+
/*if ($isFirstUpload === true) {
|
499 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATUS', '1');
|
500 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_LAST_PAGE_SENT', '0');
|
501 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATE', 'QUOTES');
|
502 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_FIRST_TRANSACTION', '1');
|
503 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_BS_LAST_FAKE_ID', '0');
|
504 |
+
} else {
|
505 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATUS', '0');
|
506 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_LAST_PAGE_SENT', '0');
|
507 |
+
}*/
|
508 |
+
}
|
509 |
+
return;
|
510 |
+
} else {
|
511 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATUS', '0');
|
512 |
+
}
|
513 |
+
|
514 |
+
|
515 |
+
/*else if ($state === 'QUOTES' && $isFirstUpload === true) {
|
516 |
+
$numItems = Mage::getModel('sales/quote')->getCollection()->count();
|
517 |
+
$res = $recsins->uploadCatalogQuotes($pageSize, $lastPageSent, $lastFakeId, $firstTransaction);
|
518 |
+
//$lastPageSent = Mage::getStoreConfig('brainsins/LAST_PAGE_SENT');
|
519 |
+
$continue = isset($res) && $res === true && $lastPageSent * $pageSize < $numItems;
|
520 |
+
|
521 |
+
if (!isset($res) || $res === false) {
|
522 |
+
$message = $this->getDisplayMessage('QUOTES', 'ERROR');
|
523 |
+
Mage::getSingleton('adminhtml/session')->addError($message);
|
524 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATUS', '0');
|
525 |
+
} else if ($continue === true) {
|
526 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATUS', '1');
|
527 |
+
$percentage = number_format(($lastPageSent * $pageSize * 100) / $numItems, 1);
|
528 |
+
$message = $this->getDisplayMessage('QUOTES', 'UPLOADING', $percentage);
|
529 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($message);
|
530 |
+
if ($isFirstUpload) {
|
531 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_FIRST_TRANSACTION', '0');
|
532 |
+
}
|
533 |
+
} else {
|
534 |
+
$message = $this->getDisplayMessage('QUOTES', 'FINISHED');
|
535 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($message);
|
536 |
+
|
537 |
+
// quotes is now the last step
|
538 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATE', 'QUOTES');
|
539 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_LAST_PAGE_SENT', '0');
|
540 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_FIRST_TRANSACTION', '1');
|
541 |
+
//Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_BS_FIRST_CATALOG_UPLOAD', "0");
|
542 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_FIRST_CATALOG_UPLOAD', "0");
|
543 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATUS', '0');
|
544 |
+
// ---
|
545 |
+
//Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins/UPLOADING_STATE', 'ORDERS');
|
546 |
+
//Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins/LAST_PAGE_SENT', '0');
|
547 |
+
//Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins/FIRST_TRANSACTION', '1');
|
548 |
+
}
|
549 |
+
return;
|
550 |
+
} else if ($state === 'ORDERS' && $isFirstUpload === true) {
|
551 |
+
|
552 |
+
// orders are not been uploaded for the moment
|
553 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATE', 'QUOTES');
|
554 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_LAST_PAGE_SENT', '0');
|
555 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_FIRST_TRANSACTION', '1');
|
556 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATUS', '0');
|
557 |
+
return;
|
558 |
+
// ---
|
559 |
+
|
560 |
+
$numItems = Mage::getModel('sales/order')->getCollection()->count();
|
561 |
+
$res = $recsins->uploadCatalogOrders($pageSize, $lastPageSent, $lastFakeId, $firstTransaction);
|
562 |
+
$lastPageSent = Mage::getStoreConfig('brainsins/LAST_PAGE_SENT');
|
563 |
+
$continue = isset($res) && $res === true && $lastPageSent * $pageSize < $numItems;
|
564 |
+
|
565 |
+
if (!isset($res) || $res === false) {
|
566 |
+
$message = $this->getDisplayMessage('ORDERS', 'ERROR');
|
567 |
+
Mage::getSingleton('adminhtml/session')->addError($message);
|
568 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATUS', '0');
|
569 |
+
} else if ($continue === true) {
|
570 |
+
$percentage = number_format(($lastPageSent * $pageSize * 100) / $numItems, 1);
|
571 |
+
$message = $this->getDisplayMessage('ORDERS', 'UPLOADING', $percentage);
|
572 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($message);
|
573 |
+
if ($isFirstUpload) {
|
574 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_FIRST_TRANSACTION', '0');
|
575 |
+
}
|
576 |
+
} else {
|
577 |
+
$message = $this->getDisplayMessage('ORDERS', 'FINISHED');
|
578 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($message);
|
579 |
+
|
580 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATE', 'ORDERS');
|
581 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_LAST_PAGE_SENT', '0');
|
582 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_FIRST_TRANSACTION', '1');
|
583 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_BS_FIRST_CATALOG_UPLOAD', "0");
|
584 |
+
Mage::getSingleton("core/session", array("name" => "adminhtml"))->setData('brainsins_UPLOADING_STATUS', '0');
|
585 |
+
}
|
586 |
+
return;
|
587 |
+
}*/
|
588 |
+
|
589 |
+
|
590 |
+
|
591 |
+
return;
|
592 |
+
}
|
593 |
+
|
594 |
+
private function getDisplayMessage($state, $status, $progress = null) {
|
595 |
+
|
596 |
+
$message = "";
|
597 |
+
|
598 |
+
//$isFirstUpload = Mage::getStoreConfig('brainsins/BS_FIRST_CATALOG_UPLOAD');
|
599 |
+
$numStages = 2;
|
600 |
+
|
601 |
+
/*if (isset($isFirstUpload)) {
|
602 |
+
$isFirstUpload = $isFirstUpload == '1';
|
603 |
+
} else {
|
604 |
+
$isFirstUpload = true;
|
605 |
+
}*/
|
606 |
+
|
607 |
+
/*if ($isFirstUpload) {
|
608 |
+
|
609 |
+
//orders are not been uploaded
|
610 |
+
$numStages = 3;
|
611 |
+
//$numStages = 4;
|
612 |
+
}*/
|
613 |
+
|
614 |
+
if ($state == 'CLIENTS') {
|
615 |
+
if ($status == 'UPLOADING') {
|
616 |
+
$message .= "(1/$numStages) " . Mage::helper('recsins')->__("Uploading Clients") . " : $progress %<br>";
|
617 |
+
} else if ($status == 'FINISHED') {
|
618 |
+
$message .= "(1/$numStages) " . Mage::helper('recsins')->__("Clients uploaded OK") . "<br>";
|
619 |
+
$message .= "(2/$numStages) " . Mage::helper('recsins')->__("Uploading Products") . " : 0.0 %<br>";
|
620 |
+
} else if ($status == 'ERROR') {
|
621 |
+
$message .= Mage::helper('recsins')->__("Error occurred while uploading Clients") . "<br>";
|
622 |
+
$message .= Mage::helper('recsins')->__("Catalog upload aborted") . "<br>";
|
623 |
+
}
|
624 |
+
return $message;
|
625 |
+
} else {
|
626 |
+
$message .= "(1/$numStages) " . Mage::helper('recsins')->__("Clients uploaded OK") . "<br>";
|
627 |
+
}
|
628 |
+
|
629 |
+
if ($state == 'PRODUCTS') {
|
630 |
+
if ($status == 'UPLOADING') {
|
631 |
+
$message .= "(2/$numStages) " . Mage::helper('recsins')->__("Uploading Products") . " : $progress %<br>";
|
632 |
+
} else if ($status == 'FINISHED') {
|
633 |
+
$message .= "(2/$numStages) " . Mage::helper('recsins')->__("Products uploaded OK") . "<br>";
|
634 |
+
/*if ($isFirstUpload === true) {
|
635 |
+
$message .= "(3/$numStages) " . Mage::helper('recsins')->__("Uploading Carts") . " : 0.0 %<br>";
|
636 |
+
}*/
|
637 |
+
} else if ($status == 'ERROR') {
|
638 |
+
$message .= Mage::helper('recsins')->__("Error occurred while uploading Products") . "<br>";
|
639 |
+
$message .= Mage::helper('recsins')->__("Catalog upload aborted") . "<br>";
|
640 |
+
}
|
641 |
+
return $message;
|
642 |
+
} else {
|
643 |
+
$message .= "(2/$numStages) " . Mage::helper('recsins')->__("Products uploaded OK") . "<br>";
|
644 |
+
}
|
645 |
+
|
646 |
+
/* if ($isFirstUpload === true) {
|
647 |
+
|
648 |
+
if ($state == 'QUOTES') {
|
649 |
+
if ($status == 'UPLOADING') {
|
650 |
+
$message .= "(3/$numStages) " . Mage::helper('recsins')->__("Uploading Carts") . " : $progress %<br>";
|
651 |
+
} else if ($status == 'FINISHED') {
|
652 |
+
$message .= "(3/$numStages) " . Mage::helper('recsins')->__("Carts uploaded OK") . "<br>";
|
653 |
+
//orders are not been uploaded
|
654 |
+
//$message .= "(4/$numStages) " . Mage::helper('recsins')->__("Uploading Purchases") . " : 0.0 %<br>";
|
655 |
+
} else if ($status == 'ERROR') {
|
656 |
+
$message .= Mage::helper('recsins')->__("Error occurred while uploading Carts") . "<br>";
|
657 |
+
$message .= Mage::helper('recsins')->__("Catalog upload aborted") . "<br>";
|
658 |
+
}
|
659 |
+
return $message;
|
660 |
+
} else {
|
661 |
+
$message .= "(3/$numStages) " . Mage::helper('recsins')->__("Carts uploaded OK") . "<br>";
|
662 |
+
}
|
663 |
+
|
664 |
+
if ($state == 'ORDERS') {
|
665 |
+
if ($status == 'UPLOADING') {
|
666 |
+
$message .= "(4/$numStages) " . Mage::helper('recsins')->__("Uploading Purchases") . " : $progress %<br>";
|
667 |
+
} else if ($status == 'FINISHED') {
|
668 |
+
$message .= "(4/$numStages) " . Mage::helper('recsins')->__("Purchases uploaded OK") . "<br>";
|
669 |
+
} else if ($status == 'ERROR') {
|
670 |
+
$message .= Mage::helper('recsins')->__("Error occurred while uploading Purchases") . "<br>";
|
671 |
+
$message .= Mage::helper('recsins')->__("Catalog upload aborted") . "<br>";
|
672 |
+
}
|
673 |
+
return $message;
|
674 |
+
} else {
|
675 |
+
$message .= "(4/$numStages) " . Mage::helper('recsins')->__("Purchases uploaded OK") . "<br>";
|
676 |
+
}
|
677 |
+
}*/
|
678 |
+
|
679 |
+
return $message;
|
680 |
+
}
|
681 |
+
|
682 |
+
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream') {
|
683 |
+
$response = $this->getResponse();
|
684 |
+
$response->setHeader('HTTP/1.1 200 OK', '');
|
685 |
+
$response->setHeader('Pragma', 'public', true);
|
686 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
687 |
+
$response->setHeader('Content-Disposition', 'attachment; filename=' . $fileName);
|
688 |
+
$response->setHeader('Last-Modified', date('r'));
|
689 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
690 |
+
$response->setHeader('Content-Length', strlen($content));
|
691 |
+
$response->setHeader('Content-type', $contentType);
|
692 |
+
$response->setBody($content);
|
693 |
+
$response->sendResponse();
|
694 |
+
die;
|
695 |
+
}
|
696 |
+
|
697 |
+
}
|
app/code/community/Brainsins/Recsins/controllers/IndexController.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Brainsins_Recsins_IndexController extends Mage_Core_Controller_Front_Action {
|
28 |
+
|
29 |
+
public function indexAction() {
|
30 |
+
|
31 |
+
$model = Mage::getModel('recsins/recommender');
|
32 |
+
$this->loadLayout();
|
33 |
+
$this->renderLayout();
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getRecProdImgAction() {
|
37 |
+
|
38 |
+
$id = $this->getRequest()->getParam("id");
|
39 |
+
$helper = Mage::helper("recsins/recsins");
|
40 |
+
$url = $helper->getImageUrl($id);
|
41 |
+
if (isset($url) && $url) {
|
42 |
+
$this->_redirectUrl($url);
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
app/code/community/Brainsins/Recsins/etc/.DS_Store
ADDED
Binary file
|
app/code/community/Brainsins/Recsins/etc/api.xml
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api>
|
4 |
+
<resources>
|
5 |
+
<bsApi translate="title" module="brainsins_recsins">
|
6 |
+
<title>BrainSINS API Extension</title>
|
7 |
+
<model>Brainsins_Recsins_Model_Api_Api</model>
|
8 |
+
<methods>
|
9 |
+
<test translate="title" module="brainsins_recsins">
|
10 |
+
<title>Just a test call</title>
|
11 |
+
<method>test</method>
|
12 |
+
<acl>catalog/product</acl>
|
13 |
+
</test>
|
14 |
+
<storeList translate="title" module="brainsins_recsins">
|
15 |
+
<title>get all the stores</title>
|
16 |
+
<method>storeList</method>
|
17 |
+
<acl>catalog/product</acl>
|
18 |
+
</storeList>
|
19 |
+
<productInfo translate="title" module="brainsins_recsins">
|
20 |
+
<title>get product info</title>
|
21 |
+
<method>productInfo</method>
|
22 |
+
<acl>catalog/product</acl>
|
23 |
+
</productInfo>
|
24 |
+
<productList translate="title" module="brainsins_recsins">
|
25 |
+
<title>get product list with basic info</title>
|
26 |
+
<method>productList</method>
|
27 |
+
<acl>catalog/product</acl>
|
28 |
+
</productList>
|
29 |
+
<productCount translate="title" module="brainsins_recsins">
|
30 |
+
<title>get number of products</title>
|
31 |
+
<method>productCount</method>
|
32 |
+
<acl>catalog/product</acl>
|
33 |
+
</productCount>
|
34 |
+
<productPage translate="title" module="brainsins_recsins">
|
35 |
+
<title>get a page of products</title>
|
36 |
+
<method>productPage</method>
|
37 |
+
<acl>catalog/product</acl>
|
38 |
+
</productPage>
|
39 |
+
<extensionOptions translate="title" module="brainsins_recsins">
|
40 |
+
<title>get brainsins selected options</title>
|
41 |
+
<method>getExtensionOptions</method>
|
42 |
+
<acl>catalog/product</acl>
|
43 |
+
</extensionOptions>
|
44 |
+
<userCount translate="title" module="brainsins_recsins">
|
45 |
+
<title>get number of users</title>
|
46 |
+
<method>userCount</method>
|
47 |
+
<acl>catalog/product</acl>
|
48 |
+
</userCount>
|
49 |
+
<userPage translate="title" module="brainsins_recsins">
|
50 |
+
<title>get a page of users</title>
|
51 |
+
<method>userPage</method>
|
52 |
+
<acl>catalog/product</acl>
|
53 |
+
</userPage>
|
54 |
+
<notifyVersion translate="title" module="brainsins_recsins">
|
55 |
+
<title>notify last version</title>
|
56 |
+
<method>notifyVersion</method>
|
57 |
+
<acl>catalog/product</acl>
|
58 |
+
</notifyVersion>
|
59 |
+
</methods>
|
60 |
+
</bsApi>
|
61 |
+
</resources>
|
62 |
+
<acl>
|
63 |
+
<resources>
|
64 |
+
<all>
|
65 |
+
</all>
|
66 |
+
</resources>
|
67 |
+
</acl>
|
68 |
+
</api>
|
69 |
+
</config>
|
app/code/community/Brainsins/Recsins/etc/config.xml
ADDED
@@ -0,0 +1,254 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<!--
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
-->
|
25 |
+
|
26 |
+
<config>
|
27 |
+
<modules>
|
28 |
+
<Brainsins_Recsins>
|
29 |
+
<version>1.4.7</version>
|
30 |
+
</Brainsins_Recsins>
|
31 |
+
</modules>
|
32 |
+
<frontend>
|
33 |
+
<routers>
|
34 |
+
<recsins>
|
35 |
+
<use>standard</use>
|
36 |
+
<args>
|
37 |
+
<module>Brainsins_Recsins</module>
|
38 |
+
<frontName>recsins</frontName>
|
39 |
+
</args>
|
40 |
+
</recsins>
|
41 |
+
</routers>
|
42 |
+
<layout>
|
43 |
+
<updates>
|
44 |
+
<recsins>
|
45 |
+
<file>recsins.xml</file>
|
46 |
+
</recsins>
|
47 |
+
</updates>
|
48 |
+
</layout>
|
49 |
+
</frontend>
|
50 |
+
<admin>
|
51 |
+
<menu>
|
52 |
+
<recsins module="recsins">
|
53 |
+
<title>BrainSINS</title>
|
54 |
+
<sort_order>73</sort_order>
|
55 |
+
<children>
|
56 |
+
<items module="recsins">
|
57 |
+
<title>Configure</title>
|
58 |
+
<sort_order>0</sort_order>
|
59 |
+
<action>admin/recsins</action>
|
60 |
+
</items>
|
61 |
+
</children>
|
62 |
+
</recsins>
|
63 |
+
</menu>
|
64 |
+
<routers>
|
65 |
+
<recsins>
|
66 |
+
<use>admin</use>
|
67 |
+
<args>
|
68 |
+
<module>Brainsins_Recsins</module>
|
69 |
+
<frontName>recsins</frontName>
|
70 |
+
</args>
|
71 |
+
</recsins>
|
72 |
+
</routers>
|
73 |
+
<layout>
|
74 |
+
<updates>
|
75 |
+
<recsins>
|
76 |
+
<file>recsins.xml</file>
|
77 |
+
</recsins>
|
78 |
+
</updates>
|
79 |
+
</layout>
|
80 |
+
</admin>
|
81 |
+
<adminhtml>
|
82 |
+
<menu>
|
83 |
+
<recsins module="recsins">
|
84 |
+
<title>BrainSINS</title>
|
85 |
+
<sort_order>71</sort_order>
|
86 |
+
<children>
|
87 |
+
<items module="recsins">
|
88 |
+
<title>Configure</title>
|
89 |
+
<sort_order>0</sort_order>
|
90 |
+
<action>recsins/adminhtml_recsins</action>
|
91 |
+
</items>
|
92 |
+
</children>
|
93 |
+
</recsins>
|
94 |
+
</menu>
|
95 |
+
<translate>
|
96 |
+
<modules>
|
97 |
+
<recsins_recommender>
|
98 |
+
<files>
|
99 |
+
<default>Brainsins_Recsins.csv</default>
|
100 |
+
</files>
|
101 |
+
</recsins_recommender>
|
102 |
+
</modules>
|
103 |
+
</translate>
|
104 |
+
<acl>
|
105 |
+
<resources>
|
106 |
+
<all>
|
107 |
+
<title>Allow Everything</title>
|
108 |
+
</all>
|
109 |
+
<admin>
|
110 |
+
<children>
|
111 |
+
<Brainsins_Recsins>
|
112 |
+
<title>Recsins Module</title>
|
113 |
+
<sort_order>10</sort_order>
|
114 |
+
</Brainsins_Recsins>
|
115 |
+
</children>
|
116 |
+
</admin>
|
117 |
+
</resources>
|
118 |
+
</acl>
|
119 |
+
<layout>
|
120 |
+
<updates>
|
121 |
+
<recsins>
|
122 |
+
<file>recsins.xml</file>
|
123 |
+
</recsins>
|
124 |
+
</updates>
|
125 |
+
</layout>
|
126 |
+
</adminhtml>
|
127 |
+
<global>
|
128 |
+
<models>
|
129 |
+
<recsins>
|
130 |
+
<class>Brainsins_Recsins_Model</class>
|
131 |
+
</recsins>
|
132 |
+
<recommender>
|
133 |
+
<class>Brainsins_Recsins_Model</class>
|
134 |
+
</recommender>
|
135 |
+
<client>
|
136 |
+
<class>Brainsins_Recsins_Model</class>
|
137 |
+
</client>
|
138 |
+
<product>
|
139 |
+
<class>Brainsins_Recsins_Model</class>
|
140 |
+
</product>
|
141 |
+
<orderProduct>
|
142 |
+
<class>Brainsins_Recsins_Model</class>
|
143 |
+
</orderProduct>
|
144 |
+
<cartProduct>
|
145 |
+
<class>Brainsins_Recsins_Model</class>
|
146 |
+
</cartProduct>
|
147 |
+
<user>
|
148 |
+
<class>Brainsins_Recsins_Model</class>
|
149 |
+
</user>
|
150 |
+
<order>
|
151 |
+
<class>Brainsins_Recsins_Model</class>
|
152 |
+
</order>
|
153 |
+
<cart>
|
154 |
+
<class>Brainsins_Recsins_Model</class>
|
155 |
+
</cart>
|
156 |
+
</models>
|
157 |
+
<resources>
|
158 |
+
<recsins_write>
|
159 |
+
<connection>
|
160 |
+
<use>core_write</use>
|
161 |
+
</connection>
|
162 |
+
</recsins_write>
|
163 |
+
<recsins_read>
|
164 |
+
<connection>
|
165 |
+
<use>core_read</use>
|
166 |
+
</connection>
|
167 |
+
</recsins_read>
|
168 |
+
<recsins_setup>
|
169 |
+
<setup>
|
170 |
+
<module>Brainsins_Recsins</module>
|
171 |
+
<class>Brainsins_Recsins_Model_Resource_Setup</class>
|
172 |
+
</setup>
|
173 |
+
<connection>
|
174 |
+
<use>core_setup</use>
|
175 |
+
</connection>
|
176 |
+
</recsins_setup>
|
177 |
+
</resources>
|
178 |
+
<blocks>
|
179 |
+
<recsins>
|
180 |
+
<class>Brainsins_Recsins_Block</class>
|
181 |
+
</recsins>
|
182 |
+
</blocks>
|
183 |
+
<helpers>
|
184 |
+
<recsins>
|
185 |
+
<class>Brainsins_Recsins_Helper</class>
|
186 |
+
</recsins>
|
187 |
+
</helpers>
|
188 |
+
<events>
|
189 |
+
<customer_login>
|
190 |
+
<observers>
|
191 |
+
<Brainsins_Recsins>
|
192 |
+
<type>singleton</type>
|
193 |
+
<class>recsins/observer</class>
|
194 |
+
<method>onLogin</method>
|
195 |
+
</Brainsins_Recsins>
|
196 |
+
</observers>
|
197 |
+
</customer_login>
|
198 |
+
<checkout_cart_save_after>
|
199 |
+
<observers>
|
200 |
+
<Brainsins_Recsins>
|
201 |
+
<type>singleton</type>
|
202 |
+
<class>recsins/observer</class>
|
203 |
+
<method>onCart</method>
|
204 |
+
</Brainsins_Recsins>
|
205 |
+
</observers>
|
206 |
+
</checkout_cart_save_after>
|
207 |
+
<sales_order_payment_place_end>
|
208 |
+
<observers>
|
209 |
+
<Brainsins_Recsins>
|
210 |
+
<type>singleton</type>
|
211 |
+
<class>recsins/observer</class>
|
212 |
+
<method>onCheckoutSuccess</method>
|
213 |
+
</Brainsins_Recsins>
|
214 |
+
</observers>
|
215 |
+
</sales_order_payment_place_end>
|
216 |
+
<controller_action_postdispatch_checkout_multishipping_addresses>
|
217 |
+
<observers>
|
218 |
+
<Brainsins_Recsins>
|
219 |
+
<type>singleton</type>
|
220 |
+
<class>recsins/observer</class>
|
221 |
+
<method>onCheckoutStart</method>
|
222 |
+
</Brainsins_Recsins>
|
223 |
+
</observers>
|
224 |
+
</controller_action_postdispatch_checkout_multishipping_addresses>
|
225 |
+
<controller_action_postdispatch_checkout_onepage_index>
|
226 |
+
<observers>
|
227 |
+
<Brainsins_Recsins>
|
228 |
+
<type>singleton</type>
|
229 |
+
<class>recsins/observer</class>
|
230 |
+
<method>onCheckoutStart</method>
|
231 |
+
</Brainsins_Recsins>
|
232 |
+
</observers>
|
233 |
+
</controller_action_postdispatch_checkout_onepage_index>
|
234 |
+
<controller_action_postdispatch_customer_account_createpost>
|
235 |
+
<observers>
|
236 |
+
<Brainsins_Recsins>
|
237 |
+
<type>singleton</type>
|
238 |
+
<class>recsins/observer</class>
|
239 |
+
<method>onCreateAccount</method>
|
240 |
+
</Brainsins_Recsins>
|
241 |
+
</observers>
|
242 |
+
</controller_action_postdispatch_customer_account_createpost>
|
243 |
+
<newsletter_subscriber_save_after>
|
244 |
+
<observers>
|
245 |
+
<Brainsins_Recsins>
|
246 |
+
<type>singleton</type>
|
247 |
+
<class>recsins/observer</class>
|
248 |
+
<method>onCustomerSave</method>
|
249 |
+
</Brainsins_Recsins>
|
250 |
+
</observers>
|
251 |
+
</newsletter_subscriber_save_after>
|
252 |
+
</events>
|
253 |
+
</global>
|
254 |
+
</config>
|
app/code/community/Brainsins/Recsins/etc/widget.xml
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<!--
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
-->
|
25 |
+
|
26 |
+
<widgets>
|
27 |
+
<recsins_home type="recsins/home">
|
28 |
+
<name>BRAINSINS: Home</name>
|
29 |
+
<description type="desc">Recomendador de home</description>
|
30 |
+
</recsins_home>
|
31 |
+
</widgets>
|
app/code/community/Brainsins/Recsins/sql/.DS_Store
ADDED
Binary file
|
app/code/community/Brainsins/Recsins/sql/recsins_setup/.DS_Store
ADDED
Binary file
|
app/code/community/Brainsins/Recsins/sql/recsins_setup/mysql4-install-1.4.0.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
$installer = $this;
|
28 |
+
|
29 |
+
$table = $installer->getTable('recsins_recommender');
|
30 |
+
|
31 |
+
$installer->startSetup();
|
32 |
+
|
33 |
+
if (!$installer->tableExists($table)) {
|
34 |
+
$installer->run("
|
35 |
+
CREATE TABLE IF NOT EXISTS {$table} (
|
36 |
+
`id` int(10) unsigned NOT NULL,
|
37 |
+
`name` varchar(255),
|
38 |
+
`page` smallint(8),
|
39 |
+
PRIMARY KEY (`id`)
|
40 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Brainsins loaded Recommenders';
|
41 |
+
");
|
42 |
+
}
|
43 |
+
|
44 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_VERSION', '1.4.0');
|
45 |
+
$installer->endSetup();
|
46 |
+
|
47 |
+
Mage::getConfig()->cleanCache();
|
app/code/community/Brainsins/Recsins/sql/recsins_setup/mysql4-upgrade-1.4.0-1.4.1.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
$installer = $this;
|
27 |
+
|
28 |
+
$table = $installer->getTable('recsins_recommender');
|
29 |
+
|
30 |
+
$installer->startSetup();
|
31 |
+
|
32 |
+
if (!$installer->tableExists($table)) {
|
33 |
+
$installer->run("
|
34 |
+
CREATE TABLE IF NOT EXISTS {$table} (
|
35 |
+
`id` int(10) unsigned NOT NULL,
|
36 |
+
`name` varchar(255),
|
37 |
+
`page` smallint(8),
|
38 |
+
PRIMARY KEY (`id`)
|
39 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Brainsins loaded Recommenders';
|
40 |
+
");
|
41 |
+
}
|
42 |
+
|
43 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_VERSION', '1.4.1');
|
44 |
+
|
45 |
+
$installer->endSetup();
|
46 |
+
|
47 |
+
Mage::getConfig()->cleanCache();
|
app/code/community/Brainsins/Recsins/sql/recsins_setup/mysql4-upgrade-1.4.1-1.4.2.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
$installer = $this;
|
27 |
+
|
28 |
+
$table = $installer->getTable('recsins_recommender');
|
29 |
+
|
30 |
+
$installer->startSetup();
|
31 |
+
|
32 |
+
if (!$installer->tableExists($table)) {
|
33 |
+
$installer->run("
|
34 |
+
CREATE TABLE IF NOT EXISTS {$table} (
|
35 |
+
`id` int(10) unsigned NOT NULL,
|
36 |
+
`name` varchar(255),
|
37 |
+
`page` smallint(8),
|
38 |
+
PRIMARY KEY (`id`)
|
39 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Brainsins loaded Recommenders';
|
40 |
+
");
|
41 |
+
}
|
42 |
+
|
43 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_VERSION', '1.4.2');
|
44 |
+
|
45 |
+
$installer->endSetup();
|
46 |
+
|
47 |
+
Mage::getConfig()->cleanCache();
|
app/code/community/Brainsins/Recsins/sql/recsins_setup/mysql4-upgrade-1.4.2-1.4.3.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
$installer = $this;
|
27 |
+
|
28 |
+
$table = $installer->getTable('recsins_recommender');
|
29 |
+
|
30 |
+
$installer->startSetup();
|
31 |
+
|
32 |
+
if (!$installer->tableExists($table)) {
|
33 |
+
$installer->run("
|
34 |
+
CREATE TABLE IF NOT EXISTS {$table} (
|
35 |
+
`id` int(10) unsigned NOT NULL,
|
36 |
+
`name` varchar(255),
|
37 |
+
`page` smallint(8),
|
38 |
+
PRIMARY KEY (`id`)
|
39 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Brainsins loaded Recommenders';
|
40 |
+
");
|
41 |
+
}
|
42 |
+
|
43 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_VERSION', '1.4.3');
|
44 |
+
|
45 |
+
$installer->endSetup();
|
46 |
+
|
47 |
+
Mage::getConfig()->cleanCache();
|
app/code/community/Brainsins/Recsins/sql/recsins_setup/mysql4-upgrade-1.4.3-1.4.4.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
$installer = $this;
|
27 |
+
|
28 |
+
$table = $installer->getTable('recsins_recommender');
|
29 |
+
|
30 |
+
$installer->startSetup();
|
31 |
+
|
32 |
+
if (!$installer->tableExists($table)) {
|
33 |
+
$installer->run("
|
34 |
+
CREATE TABLE IF NOT EXISTS {$table} (
|
35 |
+
`id` int(10) unsigned NOT NULL,
|
36 |
+
`name` varchar(255),
|
37 |
+
`page` smallint(8),
|
38 |
+
PRIMARY KEY (`id`)
|
39 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Brainsins loaded Recommenders';
|
40 |
+
");
|
41 |
+
}
|
42 |
+
|
43 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_VERSION', '1.4.4');
|
44 |
+
|
45 |
+
$installer->endSetup();
|
46 |
+
|
47 |
+
Mage::getConfig()->cleanCache();
|
app/code/community/Brainsins/Recsins/sql/recsins_setup/mysql4-upgrade-1.4.4-1.4.5.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
$installer = $this;
|
27 |
+
|
28 |
+
$table = $installer->getTable('recsins_recommender');
|
29 |
+
|
30 |
+
$installer->startSetup();
|
31 |
+
|
32 |
+
if (!$installer->tableExists($table)) {
|
33 |
+
$installer->run("
|
34 |
+
CREATE TABLE IF NOT EXISTS {$table} (
|
35 |
+
`id` int(10) unsigned NOT NULL,
|
36 |
+
`name` varchar(255),
|
37 |
+
`page` smallint(8),
|
38 |
+
PRIMARY KEY (`id`)
|
39 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Brainsins loaded Recommenders';
|
40 |
+
");
|
41 |
+
}
|
42 |
+
|
43 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_VERSION', '1.4.5');
|
44 |
+
|
45 |
+
$installer->endSetup();
|
46 |
+
|
47 |
+
Mage::getConfig()->cleanCache();
|
app/code/community/Brainsins/Recsins/sql/recsins_setup/mysql4-upgrade-1.4.5-1.4.6.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
$installer = $this;
|
27 |
+
|
28 |
+
$table = $installer->getTable('recsins_recommender');
|
29 |
+
|
30 |
+
$installer->startSetup();
|
31 |
+
|
32 |
+
if (!$installer->tableExists($table)) {
|
33 |
+
$installer->run("
|
34 |
+
CREATE TABLE IF NOT EXISTS {$table} (
|
35 |
+
`id` int(10) unsigned NOT NULL,
|
36 |
+
`name` varchar(255),
|
37 |
+
`page` smallint(8),
|
38 |
+
PRIMARY KEY (`id`)
|
39 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Brainsins loaded Recommenders';
|
40 |
+
");
|
41 |
+
}
|
42 |
+
|
43 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_VERSION', '1.4.6');
|
44 |
+
|
45 |
+
$installer->endSetup();
|
46 |
+
|
47 |
+
Mage::getConfig()->cleanCache();
|
app/code/community/Brainsins/Recsins/sql/recsins_setup/mysql4-upgrade-1.4.6-1.4.7.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
$installer = $this;
|
27 |
+
|
28 |
+
$table = $installer->getTable('recsins_recommender');
|
29 |
+
|
30 |
+
$installer->startSetup();
|
31 |
+
|
32 |
+
if (!$installer->tableExists($table)) {
|
33 |
+
$installer->run("
|
34 |
+
CREATE TABLE IF NOT EXISTS {$table} (
|
35 |
+
`id` int(10) unsigned NOT NULL,
|
36 |
+
`name` varchar(255),
|
37 |
+
`page` smallint(8),
|
38 |
+
PRIMARY KEY (`id`)
|
39 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Brainsins loaded Recommenders';
|
40 |
+
");
|
41 |
+
}
|
42 |
+
|
43 |
+
Mage::getModel('core/config')->saveConfig('brainsins/BS_VERSION', '1.4.6');
|
44 |
+
|
45 |
+
$installer->endSetup();
|
46 |
+
|
47 |
+
Mage::getConfig()->cleanCache();
|
app/design/adminhtml/default/default/layout/recsins.xml
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<!--
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
-->
|
25 |
+
|
26 |
+
<layout version="0.1.0">
|
27 |
+
<recsins_adminhtml_recsins_index>
|
28 |
+
<reference name="content">
|
29 |
+
<block type="recsins/adminhtml_recsins" name="recsins" />
|
30 |
+
</reference>
|
31 |
+
</recsins_adminhtml_recsins_index>
|
32 |
+
</layout>
|
app/design/frontend/base/default/layout/recsins.xml
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<!--
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
-->
|
25 |
+
|
26 |
+
<layout version="0.1.0">
|
27 |
+
<default>
|
28 |
+
<reference name="before_body_end">
|
29 |
+
<block type="recsins/recsins" name="recsins">
|
30 |
+
</block>
|
31 |
+
</reference>
|
32 |
+
</default>
|
33 |
+
<catalog_product_view>
|
34 |
+
<reference name="product.info.upsell">
|
35 |
+
<action method="setTemplate">
|
36 |
+
<template>recsins/product.phtml</template>
|
37 |
+
</action>
|
38 |
+
</reference>
|
39 |
+
</catalog_product_view>
|
40 |
+
<checkout_cart_index>
|
41 |
+
<reference name="checkout.cart.crosssell">
|
42 |
+
<action method="setTemplate">
|
43 |
+
<template>recsins/cart.phtml</template>
|
44 |
+
</action>
|
45 |
+
</reference>
|
46 |
+
</checkout_cart_index>
|
47 |
+
<checkout_onepage_success>
|
48 |
+
<reference name="content">
|
49 |
+
<block type="recsins/checkout" name="recsins.checkout"></block>
|
50 |
+
</reference>
|
51 |
+
</checkout_onepage_success>
|
52 |
+
<checkout_multishipping_success>
|
53 |
+
<reference name="content">
|
54 |
+
<block type="recsins/checkout" name="recsins.checkout"></block>
|
55 |
+
</reference>
|
56 |
+
</checkout_multishipping_success>
|
57 |
+
</layout>
|
app/design/frontend/base/default/template/recsins/.DS_Store
ADDED
Binary file
|
app/design/frontend/base/default/template/recsins/cart.phtml
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<div id="cart_recommendations"></div>
|
app/design/frontend/base/default/template/recsins/category.phtml
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<div id="category_recommendations"></div><br>
|
app/design/frontend/base/default/template/recsins/product.phtml
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<div id="product_recommendations"></div><br>
|
app/design/frontend/base/default/template/recsins/recsins.phtml
ADDED
File without changes
|
app/etc/modules/Brainsins_Recsins.xml
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<!--
|
4 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
5 |
+
* personalized product recommendations into a Magento Store.
|
6 |
+
* Copyright (c) 2011 Social Gaming Platform S.R.L.
|
7 |
+
*
|
8 |
+
* This file is part of BrainSINS' Magento Extension.
|
9 |
+
*
|
10 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
11 |
+
* and/or modify it under the terms of the GNU General Public License
|
12 |
+
* as published by the Free Software Foundation, either version 3 of the
|
13 |
+
* License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* Foobar is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
* GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*
|
23 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
24 |
+
-->
|
25 |
+
|
26 |
+
<config>
|
27 |
+
<modules>
|
28 |
+
<Brainsins_Recsins>
|
29 |
+
<active>true</active>
|
30 |
+
<codePool>community</codePool>
|
31 |
+
</Brainsins_Recsins>
|
32 |
+
</modules>
|
33 |
+
</config>
|
app/locale/en_US/Brainsins_Recsins.csv
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"Configuration", "Configuration"
|
2 |
+
"BrainSINS KEY", "BrainSINS KEY"
|
3 |
+
"Home Page Recommender", "Home Page Recommender"
|
4 |
+
"Category Page Recommender", "Category Page Recommender"
|
5 |
+
"Product Page Recommender", "Product Page Recommender"
|
6 |
+
"Cart Page Recommender", "Cart Page Recommender"
|
7 |
+
"Checkout Page Recommender", "Checkout Page Recommender"
|
8 |
+
"Import Recommenders", "Import Recommenders"
|
9 |
+
"Send Catalog", "Send Catalog"
|
10 |
+
"Do not show", "Do not show"
|
11 |
+
"Edit Style", "Edit Style"
|
12 |
+
"Enabled", "Enabled"
|
13 |
+
"Disabled", "Disabled"
|
14 |
+
"Enable / Disable Extension", "Enable / Disable Extension"
|
15 |
+
"Catalog uploaded successfully", "Catalog uploaded successfully"
|
16 |
+
"Error while uploading the catalog", "Error while uploading the catalog"
|
17 |
+
"Recommenders imported sucssessfully", "Recommenders imported sucssessfully"
|
18 |
+
"Error while importing recommenders", "Error while importing recommenders"
|
19 |
+
"Abort Catalog Upload", "Abort Catalog Upload"
|
20 |
+
"Catalog upload aborted", "Catalog upload aborted"
|
21 |
+
"Uploading Clients", "Uploading Clients"
|
22 |
+
"Clients uploaded OK", "Clients uploaded OK"
|
23 |
+
"Uploading Products", "Uploading Products"
|
24 |
+
"Products uploaded OK", "Products uploaded OK"
|
25 |
+
"Uploading Carts", "Uploading Carts"
|
26 |
+
"Carts uploaded OK", "Carts uploaded OK"
|
27 |
+
"Uploading Purchases", "Uploading Purchases"
|
28 |
+
"Purchases uploaded OK", "Purchases uploaded OK"
|
29 |
+
"Error occurred while uploading Clients", "Error occurred while uploading Clients"
|
30 |
+
"Error occurred while uploading Products", "Error occurred while uploading Products"
|
31 |
+
"Error occurred while uploading Carts", "Error occurred while uploading Carts"
|
32 |
+
"Error occurred while uploading Purchases", "Error occurred while uploading Purchases"
|
33 |
+
"Catalog upload aborted", "Catalog upload aborted"
|
34 |
+
"Do not have a BrainSINS KEY?", "Do not have a BrainSINS KEY?"
|
35 |
+
"I am a BrainSINS client", "I am a BrainSINS client"
|
36 |
+
"I am not a BrainSINS client yet", "I am not a BrainSINS client yet"
|
37 |
+
"Advanced Options", "Advanced Options"
|
38 |
+
"please do not modify these values unless you are told so by BrainSINS' support team", "please do not modify these values unless you are told so by BrainSINS' support team"
|
39 |
+
"Catalog upload page size", "Catalog upload page size"
|
40 |
+
"Include out of stock products in catalog upload (out of stock products will be recommended)", "Include out of stock products in catalog upload (out of stock products will be recommended)"
|
41 |
+
"Select Image url type", "Select Image url type"
|
42 |
+
"Default value for product ''small'' image", "Default value for product ''small'' image"
|
43 |
+
"Resize product ''small'' image", "Resize product ''small'' image"
|
44 |
+
"Width", "Width"
|
45 |
+
"Heigth", "Heigth"
|
46 |
+
"Upload special price", "Upload special price"
|
47 |
+
"Yes", "Yes"
|
48 |
+
"No", "No"
|
49 |
+
"Tax Prices", "Tax Prices"
|
50 |
+
"Display Prices are equal to Catalog Prices", "Display Prices are equal to Catalog Prices"
|
51 |
+
"Display Prices include taxes and Catalog Prices do not include taxes", "Display Prices include taxes and Catalog Prices do not include taxes"
|
52 |
+
"Display Prices do not include taxes and Catalog Prices include taxes", "Display Prices do not include taxes and Catalog Prices include taxes"
|
app/locale/es_ES/Brainsins_Recsins.csv
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"Configuration", "Configuración"
|
2 |
+
"BrainSINS KEY", "BrainSINS KEY"
|
3 |
+
"Home Page Recommender", "Recomendador en la página Home"
|
4 |
+
"Category Page Recommender", "Recomendador en página de categoría"
|
5 |
+
"Product Page Recommender", "Recomendador en la página de Producto"
|
6 |
+
"Cart Page Recommender", "Recomendador en la página de Carrito"
|
7 |
+
"Checkout Page Recommender", "Recomendador en la página de Checkout"
|
8 |
+
"Import Recommenders", "Importar Recomendadores"
|
9 |
+
"Send Catalog", "Enviar Catálogo"
|
10 |
+
"Do not show", "No mostrar"
|
11 |
+
"Edit Style", "Editar Estilo"
|
12 |
+
"Enabled", "Habilitada"
|
13 |
+
"Disabled", "Deshabilitada"
|
14 |
+
"Enable / Disable Extension", "Habilitar / Deshabilitar Extensión"
|
15 |
+
"Catalog uploaded successfully", "Catálogo enviado correctamente"
|
16 |
+
"Error while uploading the catalog", "Error al enviar el catálogo"
|
17 |
+
"Recommenders imported sucssessfully", "Recomendadores importados correctamente"
|
18 |
+
"Error while importing recommenders", "Error al importar los recomendadores"
|
19 |
+
"Abort Catalog Upload", "Abortar Subida de Catálogo"
|
20 |
+
"Catalog upload aborted", "Subida de catálogo abortada"
|
21 |
+
"Uploading Clients", "Enviando Usuarios"
|
22 |
+
"Clients uploaded OK", "Usuarios enviados OK"
|
23 |
+
"Uploading Products", "Enviando Productos"
|
24 |
+
"Products uploaded OK", "Productos enviados OK"
|
25 |
+
"Uploading Carts", "Enviando Carritos"
|
26 |
+
"Carts uploaded OK", "Carritos enviados OK"
|
27 |
+
"Uploading Purchases", "Enviando Compras"
|
28 |
+
"Purchases uploaded OK", "Compras enviadas OK"
|
29 |
+
"Error occurred while uploading Clients", "Error en el envío de Usuarios"
|
30 |
+
"Error occurred while uploading Products", "Error en el envío de Productos"
|
31 |
+
"Error occurred while uploading Carts", "Error en el envío de Carritos"
|
32 |
+
"Error occurred while uploading Purchases", "Error en el envío de Compras"
|
33 |
+
"Catalog upload aborted", "Envío de catálogo abortado"
|
34 |
+
"Do not have a BrainSINS KEY?", "¿No dispone de una clave ''BrainSINS KEY''?"
|
35 |
+
"I am a BrainSINS client", "Ya soy cliente de BrainSINS"
|
36 |
+
"I am not a BrainSINS client yet", "Todavía no soy cliente de BrainSINS"
|
37 |
+
"Advanced Options", "Opciones Avanzadas"
|
38 |
+
"please do not modify these values unless you are told so by BrainSINS' support team", "por favor no modifique estos valores si no es por indicación del equipo de soporte de BrainSINS"
|
39 |
+
"Catalog upload page size", "Tamaño de página para el envío de catálogo"
|
40 |
+
"Include out of stock products in catalog upload (out of stock products will be recommended)", "Incluir productos fuera de stock en la subida de catálogo (estos productos podrán ser recomendados)"
|
41 |
+
"Select Image url type", "Selección del tipo de imágenes(url)"
|
42 |
+
"Default value for product ''small'' image", "Valor por defecto de la imagen ''small''"
|
43 |
+
"Resize product ''small'' image", "Valor redimensionado de la imagen ''small''"
|
44 |
+
"Width", "Ancho"
|
45 |
+
"Heigth", "Alto"
|
46 |
+
"Upload special price", "Enviar precio ''special''"
|
47 |
+
"Yes", "Sí"
|
48 |
+
"No", "No"
|
49 |
+
"Tax Prices", "Impuestos en Precios"
|
50 |
+
"Display Prices are equal to Catalog Prices", "Los precios se muestran igual que en el catálogo"
|
51 |
+
"Display Prices include taxes and Catalog Prices do not include taxes", "Los precios se muestran con impuestos y en el catálogo no incluyen inpuestos"
|
52 |
+
"Display Prices do not include taxes and Catalog Prices include taxes", "Los precios se muestran sin impuestos y en el catálogo sí incluyen impuestos"
|
package.xml
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Brainsins_Recommender</name>
|
4 |
+
<version>1.4.7</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.brainsins.es/contrato-de-prestacion-de-servicios-brainsin-para-plugins/">GPL 3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Brainsins Recommender for Magento</summary>
|
10 |
+
<description>BrainSINS Recommender plugin for Magento is a product that you can easily install in your online store to increase your e-commerce profits. It will replace and improve standard Magento cross-selling and up-selling, and will offer more than 100 personalized recommenders.
|
11 |
+

|
12 |
+
This service will let your online shop:
|
13 |
+
* increase sales up to 30%.
|
14 |
+
* increase conversions up to 30%.
|
15 |
+
* up to 70% of your customers will make more purchases.
|
16 |
+

|
17 |
+
BrainSINS Recommender is offered as a software as a service. It processes the users activity (visited pages, ratings, comments, previous purchases, etc.) and creates a profile for each visitor, offering a personalized experience for each one, allowing your e-commerce offering a unique shop depending on the client’s interest, just like Amazon does. See how we do it here: http://vimeo.com/20025520
|
18 |
+

|
19 |
+
Increase your cross-sell, up-sell and Average Order Value (AOV) rates. Send personalized emails to your clients to increase the return to your store, and measure and control the effect of all the recommendations in your online store.
|
20 |
+

|
21 |
+
Install the plugin in a few minutes and offer more than 100 personalized recommenders in any web page of your online store in less than 24 hours. Choose the plan that better fits to your store at http://www.brainsins.es/tarifas/ and try it for Free 1 month, experimenting the benefits in your own online store without compromise.</description>
|
22 |
+
<notes>Solved a problem with catalog retrieval in Magento version 1.4.x</notes>
|
23 |
+
<authors><author><name>BrainSINS</name><user>auto-converted</user><email>alejandro.cuevas@brainsins.com</email></author></authors>
|
24 |
+
<date>2012-03-23</date>
|
25 |
+
<time>16:15:11</time>
|
26 |
+
<contents><target name="magecommunity"><dir name="Brainsins"><dir name="Recsins"><dir name="Block"><dir name="Adminhtml"><dir name="Recsins"><dir name="Edit"><dir name="Tab"><file name="Form.php" hash="f50e327073f6db6f0b7aaf2e6018834b"/><file name=".DS_Store" hash="47ab7c6331c785f3abe32e1d49659743"/></dir><file name="Form.php" hash="d37edb47bdc512eec8d26eb412ed0e24"/><file name="Tabs.php" hash="da7477ceefd6cc473fb2fb2a307f0282"/><file name=".DS_Store" hash="dbfd4b859fae44d226584cc0de499414"/></dir><file name="Edit.php" hash="942d16b49fca2566799c7c393ffdd4d2"/><file name="Grid.php" hash="bf34a0c320aeebfe1cc645dc4120b4aa"/><file name=".DS_Store" hash="550ce861437446e70bb1b83296032d36"/></dir><file name="Recsins.php" hash="f0bb580c8238818273726847917789f8"/><file name=".DS_Store" hash="1b0ef8c354534e8683bfa107de6b5724"/></dir><file name="Category.php" hash="fa64d544ad0020dfa651b6c27f95d734"/><file name="Checkout.php" hash="e6e523a465b52ff1d93dea497c15db5e"/><file name="Home.php" hash="26eb9d8e4f796bb0a2ba8ea90691c943"/><file name="Product.php" hash="648d439dc8729a8205449c6887175371"/><file name="Recsins.php" hash="a198880d38201579b47bc4a3ca135a7d"/><file name=".DS_Store" hash="685d9658140adde8787312ba21575a63"/><file name=".LCKRecsins.php~" hash="ed46e9b84acaa2b3b33539877109417b"/></dir><dir name="Entity"><file name="Setup.php" hash="02af74b02e083c4552762ecc9987a1a7"/><file name=".DS_Store" hash="904a17b2e133ff00bc1c75992115b463"/></dir><dir name="Helper"><file name="Data.php" hash="c117b4e42fef671651a78c8f4e01d0e5"/><file name="Recsins.php" hash="435d1402b9b860d906db3a3beb3c93de"/><file name=".DS_Store" hash="c9075ec8f3a93c790032a41253f0410d"/></dir><dir name="Model"><dir name="Api"><file name="Api.php" hash="bb8abde6f8b0878a217ec25c1f08fd1f"/><file name="ProductsApi.php" hash="5f79f4a92a08aae848f845c559e624a4"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Mysql4"><dir name="Recsins"><file name="Collection.php" hash="8c69337dee2f64516174e59805c6ec83"/></dir><file name="Recsins.php" hash="57256b85a9e1279e0875ea50cf8325d4"/></dir><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><dir name="Recommender"><file name="Collection.php" hash="6c36324bb84cba28f6a5bdb7eb0c2bce"/></dir><file name="Recommender.php" hash="f6857e56874c6480447b5c411aa7a066"/></dir></dir><file name="Setup.php" hash="02af74b02e083c4552762ecc9987a1a7"/></dir><file name="Cart.php" hash="d19925676d18f200f25b1c995f035300"/><file name="CartProduct.php" hash="fffddbe0a759335f89bbdbcec7b4d2eb"/><file name="Client.php" hash="077a32c36ef2cecd93ea1aef76c36de5"/><file name="NewFile.xml" hash="93286b7fccf6f6092628ada8b85c0727"/><file name="Observer.php" hash="6c0ff3f353947cda424057117c5ba530"/><file name="Order.php" hash="b8dcb3adfe676725fe4f09acff84cd97"/><file name="OrderProduct.php" hash="1d33e879db0bb8557704ed3b66fb584d"/><file name="Product.php" hash="222db5151109eb9e6741cc1fe0d1ba7f"/><file name="Recommender.php" hash="12532b4efd6fdec560522a2ecf029ed9"/><file name="Recsins.php" hash="4d9b501cd6f3d4d454072f92e295b243"/><file name="Recsins_1.php" hash="310a9b224478749d35c5b59689ce1a07"/><file name="Status.php" hash="e3f1a39141d7a4aaa99252937f60ca8d"/><file name="User.php" hash="3244421d7331e5167e910f6fc3827361"/><file name=".DS_Store" hash="097ab8c792166ff4dbfacd5c4a7399ea"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="RecsinsController.php" hash="1c300e7678664231438a647ec30551db"/><file name=".DS_Store" hash="eb69d7bfb18ebe8966b63ac54b04d1c0"/></dir><file name="IndexController.php" hash="2c9f228ed4e43c347235ed327365a219"/><file name=".DS_Store" hash="b415ad11c2cfebb78e16adb17ca06bff"/></dir><dir name="etc"><file name="api.xml" hash="0bf818c199b524f347be7d83e5a8d0f5"/><file name="config.xml" hash="35ca238b5a25b9dfbe6d331880ea2ab6"/><file name="widget.xml" hash="c4f1829fa161f1119d817b64878f3b2f"/><file name=".DS_Store" hash="05e296fc2705958a70855fe260ceb9e5"/></dir><dir name="sql"><dir name="recsins_setup"><file name="mysql4-install-1.4.0.php" hash="33ae9091e3066779c13e738beae3650c"/><file name="mysql4-upgrade-1.4.0-1.4.1.php" hash="b636f16be2575bff013c14c012b34625"/><file name="mysql4-upgrade-1.4.1-1.4.2.php" hash="e73c5189c851c1ddb94d8ce8acd6f1a6"/><file name="mysql4-upgrade-1.4.2-1.4.3.php" hash="2297a4e5670b28a24c1fcd3d5d47aca6"/><file name="mysql4-upgrade-1.4.3-1.4.4.php" hash="6c76f6d7ffe9da72ebabd44779d13bde"/><file name="mysql4-upgrade-1.4.4-1.4.5.php" hash="1b932c2afb4543c6e067a7b769d48eb8"/><file name="mysql4-upgrade-1.4.5-1.4.6.php" hash="a851ccc0fa73440b74828c0b2ee993d9"/><file name="mysql4-upgrade-1.4.6-1.4.7.php" hash="a851ccc0fa73440b74828c0b2ee993d9"/><file name=".DS_Store" hash="70fb1641ce88fc5fdb410744cb098089"/></dir><file name=".DS_Store" hash="fd4b270e5bdf8c2dbe56c9a98d4e6548"/></dir><file name="COPYING.txt" hash="4fe869ee987a340198fb0d54c55c47f1"/><file name="brainsins.js.js" hash="0ac34f45d12fd10332c812a8ea0702a5"/><file name=".DS_Store" hash="eeb372ab169162282b12cc8db9fb11b7"/></dir><file name=".DS_Store" hash="040355aa35efed3766f07840465e47f6"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="recsins.xml" hash="c2608f0c7f9f6efcbeb74bd5b1427206"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="recsins"><file name="cart.phtml" hash="04ee1833a0177a83644e4d1f3211c789"/><file name="category.phtml" hash="1979377cb8f06740a6b44a922e46dacd"/><file name="product.phtml" hash="3a623d6b48cceae14912b4daf5113ca2"/><file name="recsins.phtml" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name=".DS_Store" hash="f0948e76df06a209a9b7f51ff398fd60"/></dir></dir><dir name="layout"><file name="recsins.xml" hash="9185dc1897ec93c400edd2cd95b6533d"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Brainsins_Recsins.xml" hash="54e1c94137477548911c4ebce7eb97fe"/></dir></target><target name="magelocale"><dir name="es_ES"><file name="Brainsins_Recsins.csv" hash="7f731ae9e9faa8b003a63722ef3ce18a"/></dir><dir name="en_US"><file name="Brainsins_Recsins.csv" hash="6381582be5edc31cba54a052bb48b86d"/></dir></target></contents>
|
27 |
+
<compatible/>
|
28 |
+
<dependencies/>
|
29 |
+
</package>
|