Version Notes
First stable release.
Allows creation of Facebook stores. Multiple stores can be exported separately.
Product widgets can be created and exported to the Fan Page wall.
Download this release
Release Info
Developer | Magento Core Team |
Extension | Addon_Froomerce |
Version | 0.1.3 |
Comparing to | |
See all releases |
Version 0.1.3
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce.php +34 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Edit.php +23 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Edit/Form.php +61 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Edit/Tab/Facebook.php +28 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Edit/Tab/Form.php +38 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Edit/Tabs.php +29 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Facebook.php +26 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Facebook/Tab/Facebook.php +302 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Facebook/Tabs.php +22 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Grid.php +229 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Groups.php +23 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Groups/Form.php +20 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Groups/Tab/Form.php +174 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Groups/Tabs.php +31 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Region.php +22 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Region/Form.php +20 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Region/Tab/Form.php +212 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Region/Tabs.php +24 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Websites.php +23 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Websites/Form.php +20 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Websites/Tab/Form.php +182 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Websites/Tabs.php +30 -0
- app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/grid_backup/Grid.php +233 -0
- app/code/local/Addon/Froomerce/Block/Froomerce.php +16 -0
- app/code/local/Addon/Froomerce/Helper/Data.php +6 -0
- app/code/local/Addon/Froomerce/Model/Config.php +10 -0
- app/code/local/Addon/Froomerce/Model/Froomerce.php +9 -0
- app/code/local/Addon/Froomerce/Model/Mysql4/Collection.php +32 -0
- app/code/local/Addon/Froomerce/Model/Mysql4/Config.php +10 -0
- app/code/local/Addon/Froomerce/Model/Mysql4/Config/Collection.php +9 -0
- app/code/local/Addon/Froomerce/Model/Mysql4/Froomerce.php +10 -0
- app/code/local/Addon/Froomerce/Model/Mysql4/Froomerce/Collection.php +10 -0
- app/code/local/Addon/Froomerce/Model/Mysql4/Products.php +10 -0
- app/code/local/Addon/Froomerce/Model/Mysql4/Products/Collection.php +9 -0
- app/code/local/Addon/Froomerce/Model/Observer.php +211 -0
- app/code/local/Addon/Froomerce/Model/Products.php +10 -0
- app/code/local/Addon/Froomerce/Model/Resource/Eav/Mysql4/Product/Collection.php +27 -0
- app/code/local/Addon/Froomerce/Model/Status.php +15 -0
- app/code/local/Addon/Froomerce/controllers/Adminhtml/FroomerceController.php +747 -0
- app/code/local/Addon/Froomerce/controllers/IndexController.php +47 -0
- app/code/local/Addon/Froomerce/controllers/RssController.php +1503 -0
- app/code/local/Addon/Froomerce/etc/adminhtml.xml +22 -0
- app/code/local/Addon/Froomerce/etc/config.xml +185 -0
- app/code/local/Addon/Froomerce/sql/Froomerce_setup/mysql4-install-0.1.0.php +50 -0
- app/design/adminhtml/default/default/layout/froomerce.xml +44 -0
- app/design/adminhtml/default/default/template/addon/froomerce/grid.phtml +25 -0
- app/design/adminhtml/default/default/template/addon/froomerce/loading.phtml +45 -0
- app/design/adminhtml/default/default/template/addon/froomerce/product.phtml +22 -0
- app/design/adminhtml/default/default/template/addon/froomerce/switcher.phtml +57 -0
- app/etc/modules/Addon_Froomerce.xml +22 -0
- app/locale/de_De/Addon_Froomerce.csv +53 -0
- app/locale/fr_FR/Addon_Froomerce.csv +53 -0
- package.xml +53 -0
- skin/adminhtml/default/default/css/local.css +22 -0
- skin/adminhtml/default/default/images/joinbottom.gif +0 -0
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce extends Mage_Adminhtml_Block_Widget_Grid_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->_controller = 'adminhtml_froomerce';
|
7 |
+
$this->_blockGroup = 'froomerce';
|
8 |
+
$this->_headerText = Mage::helper('froomerce')->__('Export as widget to Facebook');
|
9 |
+
//$this->_addButtonLabel = Mage::helper('froomerce')->__('Export');
|
10 |
+
|
11 |
+
parent::__construct();
|
12 |
+
$this->setTemplate('addon/froomerce/product.phtml');
|
13 |
+
$this->_removeButton('add');
|
14 |
+
}
|
15 |
+
|
16 |
+
public function isSingleStoreMode()
|
17 |
+
{
|
18 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
19 |
+
return false;
|
20 |
+
}
|
21 |
+
return true;
|
22 |
+
}
|
23 |
+
|
24 |
+
public function getGridHtml()
|
25 |
+
{
|
26 |
+
return $this->getChildHtml('grid');
|
27 |
+
}
|
28 |
+
|
29 |
+
protected function _prepareLayout()
|
30 |
+
{
|
31 |
+
$this->setChild('grid', $this->getLayout()->createBlock('adminhtml/catalog_product_grid', 'product.grid'));
|
32 |
+
return parent::_prepareLayout();
|
33 |
+
}
|
34 |
+
}
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Edit.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->_objectId = 'id';
|
9 |
+
$this->_blockGroup = 'froomerce';
|
10 |
+
$this->_controller = 'adminhtml_froomerce';
|
11 |
+
$this->_updateButton('save', 'label', Mage::helper('froomerce')->__('Authenticate'));
|
12 |
+
$this->_removeButton('back');
|
13 |
+
}
|
14 |
+
|
15 |
+
public function getHeaderText()
|
16 |
+
{
|
17 |
+
if( Mage::registry('froomerce_data') && Mage::registry('froomerce_data')->getId() ) {
|
18 |
+
return Mage::helper('froomerce')->__("Edit Froomerce User", $this->htmlEscape(Mage::registry('froomerce_data')->getTitle()));
|
19 |
+
} else {
|
20 |
+
return Mage::helper('froomerce')->__('Add Froomerce User');
|
21 |
+
}
|
22 |
+
}
|
23 |
+
}
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Edit/Form.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
3 |
+
{
|
4 |
+
protected function _prepareForm()
|
5 |
+
{
|
6 |
+
$tmp = array();
|
7 |
+
$curn_url = $this->helper('core/url')->getCurrentUrl();
|
8 |
+
$tmp = explode('facebook', $curn_url);
|
9 |
+
$tmp2 = explode('website', $curn_url);
|
10 |
+
$tmp3 = explode('group/', $curn_url);
|
11 |
+
$from = $this->getRequest()->getParam('from');
|
12 |
+
if(empty($from))
|
13 |
+
$from = 'regin';
|
14 |
+
|
15 |
+
if(count($tmp) > 1)
|
16 |
+
{
|
17 |
+
$user_data = Mage::getModel('froomerce/froomerce')->getCollection();
|
18 |
+
$id = 0;
|
19 |
+
foreach($user_data as $user)
|
20 |
+
{
|
21 |
+
$useremail = $user->getEmail();
|
22 |
+
}
|
23 |
+
if($useremail == 'dummy.export@servis.pk')
|
24 |
+
$post_url = 'http://www.servis.pk/api/faceshop/index';
|
25 |
+
else
|
26 |
+
$post_url = 'http://www.froomerce.com/api/faceshop/index';
|
27 |
+
|
28 |
+
}
|
29 |
+
elseif(count($tmp2) > 1)
|
30 |
+
{
|
31 |
+
$post_url = $this->getUrl('*/*/group', array('from' => $from));
|
32 |
+
}
|
33 |
+
elseif(count($tmp3) > 1)
|
34 |
+
{
|
35 |
+
if($from == 'regin')
|
36 |
+
$post_url = $this->getUrl('*/*/region', array('id' => $this->getRequest()->getParam('id')));
|
37 |
+
else
|
38 |
+
$post_url = $this->getUrl('*/*/facebook', array('id' => $this->getRequest()->getParam('id')));
|
39 |
+
}
|
40 |
+
else
|
41 |
+
{
|
42 |
+
$tmp1 = explode('region', $curn_url);
|
43 |
+
if(count($tmp1) > 1)
|
44 |
+
$post_url = $this->getUrl('*/*/createshop', array('id' => $this->getRequest()->getParam('id')));
|
45 |
+
else
|
46 |
+
$post_url = $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id')));
|
47 |
+
}
|
48 |
+
|
49 |
+
$form = new Varien_Data_Form(array(
|
50 |
+
'id' => 'edit_form',
|
51 |
+
'action' => $post_url,
|
52 |
+
'method' => 'post',
|
53 |
+
)
|
54 |
+
);
|
55 |
+
|
56 |
+
$form->setUseContainer(true);
|
57 |
+
$this->setForm($form);
|
58 |
+
return parent::_prepareForm();
|
59 |
+
}
|
60 |
+
|
61 |
+
}
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Edit/Tab/Facebook.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Edit_Tab_Facebook extends Mage_Adminhtml_Block_Widget_Form
|
3 |
+
{
|
4 |
+
protected function _prepareForm()
|
5 |
+
{
|
6 |
+
$form = new Varien_Data_Form();
|
7 |
+
$this->setForm($form);
|
8 |
+
|
9 |
+
$this->setUseAjax(true);
|
10 |
+
|
11 |
+
$fieldset = $form->addFieldset('froomerce_form', array('legend'=>Mage::helper('froomerce')->__('Export to Facebook')));
|
12 |
+
|
13 |
+
$fieldset->addField('label', 'label', array(
|
14 |
+
'label' => Mage::helper('froomerce')->__('Please Authenticate First.'),
|
15 |
+
'style' => 'color:#900;',
|
16 |
+
));
|
17 |
+
|
18 |
+
if ( Mage::getSingleton('adminhtml/session')->getfroomerceData() )
|
19 |
+
{
|
20 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getFroomerceData());
|
21 |
+
Mage::getSingleton('adminhtml/session')->setFroomerceData(null);
|
22 |
+
} elseif ( Mage::registry('froomerce_data') ) {
|
23 |
+
$form->setValues(Mage::registry('froomerce_data')->getData());
|
24 |
+
}
|
25 |
+
return parent::_prepareForm();
|
26 |
+
}
|
27 |
+
}
|
28 |
+
?>
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
3 |
+
{
|
4 |
+
protected function _prepareForm()
|
5 |
+
{
|
6 |
+
$form = new Varien_Data_Form();
|
7 |
+
$this->setForm($form);
|
8 |
+
|
9 |
+
$this->setUseAjax(true);
|
10 |
+
|
11 |
+
$fieldset = $form->addFieldset('froomerce_form', array('legend'=>Mage::helper('froomerce')->__('User information<span class="contactus">Having Problems? Contact us <a href="mailto:support@froomerce.com?subject=">here</a></span>')));
|
12 |
+
|
13 |
+
$fieldset->addField('email', 'text', array(
|
14 |
+
'label' => Mage::helper('froomerce')->__('Froomerce username'),
|
15 |
+
'class' => 'required-entry',
|
16 |
+
'required' => true,
|
17 |
+
'name' => 'email',
|
18 |
+
));
|
19 |
+
|
20 |
+
$fieldset->addField('password', 'password', array(
|
21 |
+
'label' => Mage::helper('froomerce')->__('Froomerce password'),
|
22 |
+
'class' => 'required-entry',
|
23 |
+
'required' => true,
|
24 |
+
'name' => 'password',
|
25 |
+
));
|
26 |
+
|
27 |
+
if ( Mage::getSingleton('adminhtml/session')->getfroomerceData() )
|
28 |
+
{
|
29 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getFroomerceData());
|
30 |
+
Mage::getSingleton('adminhtml/session')->setFroomerceData(null);
|
31 |
+
} elseif ( Mage::registry('froomerce_data') ) {
|
32 |
+
$form->setValues(Mage::registry('froomerce_data')->getData());
|
33 |
+
}
|
34 |
+
return parent::_prepareForm();
|
35 |
+
}
|
36 |
+
|
37 |
+
}
|
38 |
+
?>
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Edit/Tabs.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('froomerce_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle(Mage::helper('froomerce')->__('Froomerce User'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$this->addTab('form_section', array(
|
17 |
+
'label' => Mage::helper('froomerce')->__('Settings'),
|
18 |
+
'title' => Mage::helper('froomerce')->__('Settings'),
|
19 |
+
'content' => $this->getLayout()->createBlock('froomerce/adminhtml_froomerce_edit_tab_form')->toHtml(),
|
20 |
+
));
|
21 |
+
|
22 |
+
$this->addTab('addresses', array(
|
23 |
+
'label' => Mage::helper('froomerce')->__('Facebook'),
|
24 |
+
'content' => $this->getLayout()->createBlock('froomerce/adminhtml_froomerce_edit_tab_facebook')->toHtml(),
|
25 |
+
));
|
26 |
+
|
27 |
+
return parent::_beforeToHtml();
|
28 |
+
}
|
29 |
+
}
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Facebook.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Facebook extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
|
8 |
+
$this->_objectId = 'id';
|
9 |
+
$this->_blockGroup = 'froomerce';
|
10 |
+
$this->_controller = 'adminhtml_froomerce';
|
11 |
+
parent::__construct();
|
12 |
+
//$this->_updateButton('save', 'label', Mage::helper('froomerce')->__('Export to Facebook1'));
|
13 |
+
$this->_removeButton('save');
|
14 |
+
$this->_removeButton('reset');
|
15 |
+
$this->_removeButton('back');
|
16 |
+
}
|
17 |
+
|
18 |
+
public function getHeaderText()
|
19 |
+
{
|
20 |
+
if( Mage::registry('froomerce_data') && Mage::registry('froomerce_data')->getId() ) {
|
21 |
+
return Mage::helper('froomerce')->__("Export to Facebook", $this->htmlEscape(Mage::registry('froomerce_data')->getTitle()));
|
22 |
+
} else {
|
23 |
+
return Mage::helper('froomerce')->__('Export to Facebook');
|
24 |
+
}
|
25 |
+
}
|
26 |
+
}
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Facebook/Tab/Facebook.php
ADDED
@@ -0,0 +1,302 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Facebook_Tab_Facebook extends Mage_Adminhtml_Block_Widget_Form
|
3 |
+
{
|
4 |
+
private $url_dummy = 'http://www.servis.pk/';
|
5 |
+
private $url = 'http://www.froomerce.com/';
|
6 |
+
private $secret_token = '5e5225e8d60e8ec72a7fd96135a0e865';
|
7 |
+
|
8 |
+
protected function _prepareForm()
|
9 |
+
{
|
10 |
+
$form = new Varien_Data_Form();
|
11 |
+
$this->setForm($form);
|
12 |
+
|
13 |
+
$this->setUseAjax(true);
|
14 |
+
|
15 |
+
$userData = $this->getUser();
|
16 |
+
$useremail = $userData['email'];
|
17 |
+
|
18 |
+
$fieldset = $form->addFieldset('froomerce_form', array('legend'=>Mage::helper('froomerce')->__('Export to Facebook<span class="contactus">Having Problems? Contact us <a href="mailto:support@froomerce.com?subject='.$useremail.'">here</a></span>')));
|
19 |
+
|
20 |
+
$user_data = Mage::getModel('froomerce/froomerce')->getCollection();
|
21 |
+
foreach($user_data as $user)
|
22 |
+
{
|
23 |
+
$usr_email = $user['email'];
|
24 |
+
$usr_pass = $user['password'];
|
25 |
+
$froomerce_user_id = $user['froomerce_user_id'];
|
26 |
+
}
|
27 |
+
|
28 |
+
if($grop_data = $this->getRequest()->getPost())
|
29 |
+
$group_id = $grop_data['group_id'];
|
30 |
+
|
31 |
+
if(count($user_data))
|
32 |
+
{
|
33 |
+
$baseURL = Mage::getBaseUrl();
|
34 |
+
|
35 |
+
$secret_token = $this->secret_token;
|
36 |
+
|
37 |
+
$fieldset->addField('email', 'hidden', array(
|
38 |
+
'value' => $usr_email,
|
39 |
+
'name' => 'email',
|
40 |
+
));
|
41 |
+
|
42 |
+
$fieldset->addField('password', 'hidden', array(
|
43 |
+
'value' => $usr_pass,
|
44 |
+
'name' => 'password',
|
45 |
+
));
|
46 |
+
|
47 |
+
$fieldset->addField('secret_token', 'hidden', array(
|
48 |
+
'value' => $secret_token,
|
49 |
+
'name' => 'secret_token',
|
50 |
+
));
|
51 |
+
|
52 |
+
$fieldset->addField('user_id', 'hidden', array(
|
53 |
+
'value' => $froomerce_user_id,
|
54 |
+
'name' => 'user_id',
|
55 |
+
));
|
56 |
+
|
57 |
+
$fieldset->addField('action_type', 'hidden', array(
|
58 |
+
'value' => 'export_shop',
|
59 |
+
'name' => 'action_type',
|
60 |
+
));
|
61 |
+
|
62 |
+
}
|
63 |
+
|
64 |
+
$baseURL = Mage::getBaseUrl();
|
65 |
+
if(Mage::getStoreConfig('web/url/use_store'))
|
66 |
+
$baseURL = Mage::app()->getStore($storecode)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
|
67 |
+
|
68 |
+
$tmp_url = explode('index.php', $baseURL);
|
69 |
+
$img_url = $tmp_url[0].'skin/adminhtml/default/default/images/joinbottom.gif';
|
70 |
+
|
71 |
+
$fieldset->addField('labl', 'label', array(
|
72 |
+
'label' => Mage::helper('froomerce')->__('<div class="alert">Only those stores can be exported to facebook which are already exported to froomerce</div>'),
|
73 |
+
));
|
74 |
+
|
75 |
+
$fieldset->addField('label', 'label', array(
|
76 |
+
'label' => Mage::helper('froomerce')->__('<b>Export Store to Facebook</b>'),
|
77 |
+
));
|
78 |
+
|
79 |
+
$i=1;
|
80 |
+
$website_code = '';
|
81 |
+
$websites = Mage::app()->getWebsites(true);
|
82 |
+
foreach ($websites as $website){
|
83 |
+
if(!$website->getId())
|
84 |
+
continue;
|
85 |
+
|
86 |
+
foreach ($website->getGroups() as $group) {
|
87 |
+
|
88 |
+
if($group->getId() == $group_id)
|
89 |
+
{
|
90 |
+
$website_code = $website->getCode();
|
91 |
+
$fieldset->addField('label'.$i++, 'label', array(
|
92 |
+
'label' => Mage::helper('froomerce')->__('<b>'.$website->getName().' </b>'),
|
93 |
+
));
|
94 |
+
|
95 |
+
$fieldset->addField('label'.$i++, 'label', array(
|
96 |
+
'label' => Mage::helper('froomerce')->__('<b> <img src="'.$img_url.'" /> '.$group->getName().' </b>'),
|
97 |
+
));
|
98 |
+
break;
|
99 |
+
}
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
|
104 |
+
$configs = Mage::getModel('froomerce/config')->getCollection();
|
105 |
+
$configs->addFieldToFilter('group_id',$group_id);
|
106 |
+
$ex_store_ids = array();
|
107 |
+
$shop_ids = array();
|
108 |
+
$shop_ids_tmp = array();
|
109 |
+
foreach($configs as $config)
|
110 |
+
{
|
111 |
+
if($config->getRegionId())
|
112 |
+
{
|
113 |
+
$storeIds = $config->getStoreId();
|
114 |
+
$ex_store_ids[] = $storeIds;
|
115 |
+
$shop_ids[$storeIds] = $config->getFroomerceShopId();
|
116 |
+
$shop_ids_tmp[] = $config->getFroomerceShopId();
|
117 |
+
}
|
118 |
+
}
|
119 |
+
if($usr_email == 'dummy.export@servis.pk')
|
120 |
+
$api_url = $this->url_dummy.'api/faceshop/index';
|
121 |
+
else
|
122 |
+
$api_url = $this->url.'api/faceshop/index';
|
123 |
+
|
124 |
+
$fb_exp_shops = $this->getExpotedShops($api_url,$shop_ids_tmp);
|
125 |
+
$stores = Mage::app()->getWebsite($website_code)->getStores();
|
126 |
+
|
127 |
+
$disable = true;
|
128 |
+
$checked= 1;
|
129 |
+
$disabl_wigt = true;
|
130 |
+
foreach($stores as $lang)
|
131 |
+
{
|
132 |
+
$store_code = $lang->getCode();
|
133 |
+
$store_code_id = $lang->getId();
|
134 |
+
$store_name = $lang->getName();
|
135 |
+
|
136 |
+
$grp_id = Mage::app()->getStore($store_code_id)->getGroup()->getGroupId();
|
137 |
+
$grp_nm = Mage::app()->getStore($store_code_id)->getGroup()->getName();
|
138 |
+
|
139 |
+
if($group_id != $grp_id)
|
140 |
+
continue;
|
141 |
+
|
142 |
+
if(!in_array($store_code_id, $ex_store_ids))
|
143 |
+
{
|
144 |
+
$fieldset->addField('label'.$i++, 'label', array(
|
145 |
+
'label' => Mage::helper('froomerce')->__(' <img src="'.$img_url.'" /> '.$store_name),
|
146 |
+
'name' => 'not_exp',
|
147 |
+
'after_element_html' => '<small>Not exported on froomerce yet</small>',
|
148 |
+
));
|
149 |
+
}
|
150 |
+
else
|
151 |
+
{
|
152 |
+
$disabl_wigt = false;
|
153 |
+
$shopid = $shop_ids[$store_code_id];
|
154 |
+
if(in_array($shopid, $fb_exp_shops))
|
155 |
+
{
|
156 |
+
$fieldset->addField('label'.$i++, 'label', array(
|
157 |
+
'label' => Mage::helper('froomerce')->__(' <img src="'.$img_url.'" /> '.$store_name),
|
158 |
+
'name' => 'not_exp',
|
159 |
+
'after_element_html' => '<small>Already exported on facebook</small>',
|
160 |
+
));
|
161 |
+
|
162 |
+
}
|
163 |
+
else
|
164 |
+
{
|
165 |
+
$disable = false;
|
166 |
+
$fieldset->addField('radio'.$i++, 'radios', array(
|
167 |
+
'label' => Mage::helper('froomerce')->__(' <img src="'.$img_url.'" /> '.$store_name),
|
168 |
+
'name' => 'shop_id',
|
169 |
+
'onclick' => "",
|
170 |
+
'onchange' => "",
|
171 |
+
'value' => '1',
|
172 |
+
'values' => array(
|
173 |
+
array('value'=>$shopid, 'label' => ''),
|
174 |
+
),
|
175 |
+
'checked' => $checked,
|
176 |
+
'tabindex' => 1,
|
177 |
+
));
|
178 |
+
|
179 |
+
$checked= 0;
|
180 |
+
}
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
if(!$disable)
|
185 |
+
{
|
186 |
+
$fieldset->addField('submit', 'submit', array(
|
187 |
+
'label' => Mage::helper('froomerce')->__(''),
|
188 |
+
'value' => Mage::helper('froomerce')->__("Export"),
|
189 |
+
'name' => 'export_shop',
|
190 |
+
'class' => 'form-button',
|
191 |
+
'disabled' => $disable,
|
192 |
+
'onclick' => "this.form.target='_blank';return true;",
|
193 |
+
'tabindex' => 1,
|
194 |
+
));
|
195 |
+
}
|
196 |
+
$fieldset->addField('labels', 'label', array(
|
197 |
+
'label' => Mage::helper('froomerce')->__('<b>Export Widgets to Facebook</b>'),
|
198 |
+
));
|
199 |
+
|
200 |
+
foreach ($websites as $website){
|
201 |
+
if(!$website->getId())
|
202 |
+
continue;
|
203 |
+
|
204 |
+
foreach ($website->getGroups() as $group) {
|
205 |
+
|
206 |
+
if($group->getId() == $group_id)
|
207 |
+
{
|
208 |
+
$fieldset->addField('label'.$i++, 'label', array(
|
209 |
+
'label' => Mage::helper('froomerce')->__('<b>'.$website->getName().' </b>'),
|
210 |
+
));
|
211 |
+
|
212 |
+
$fieldset->addField('label'.$i++, 'label', array(
|
213 |
+
'label' => Mage::helper('froomerce')->__('<b> <img src="'.$img_url.'" /> '.$group->getName().' </b>'),
|
214 |
+
));
|
215 |
+
break;
|
216 |
+
}
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
$checked = 1;
|
221 |
+
if($disabl_wigt)
|
222 |
+
{
|
223 |
+
$fieldset->addField('label_ex'.$i++, 'label', array(
|
224 |
+
'value' => '',
|
225 |
+
'after_element_html' => '<small>No store exported on froomerce yet</small>',
|
226 |
+
));
|
227 |
+
}
|
228 |
+
else
|
229 |
+
{
|
230 |
+
foreach($stores as $lang)
|
231 |
+
{
|
232 |
+
$store_code = $lang->getCode();
|
233 |
+
$store_code_id = $lang->getId();
|
234 |
+
$store_name = $lang->getName();
|
235 |
+
|
236 |
+
if(in_array($store_code_id, $ex_store_ids))
|
237 |
+
{
|
238 |
+
$fieldset->addField('labelexp'.$i++, 'label', array(
|
239 |
+
'label' => Mage::helper('froomerce')->__(' <img src="'.$img_url.'" /> '.$store_name),
|
240 |
+
'tabindex' => 1,
|
241 |
+
'after_element_html' => "<input type='button' class='form-button' value='".Mage::helper('froomerce')->__("Export")."' onclick='window.location = \" ".$this->getUrl('*/*/check', array('store' => $store_code_id))."\"' >",
|
242 |
+
));
|
243 |
+
$checked= 0;
|
244 |
+
}
|
245 |
+
}
|
246 |
+
}
|
247 |
+
|
248 |
+
if ( Mage::getSingleton('adminhtml/session')->getfroomerceData() )
|
249 |
+
{
|
250 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getFroomerceData());
|
251 |
+
Mage::getSingleton('adminhtml/session')->setFroomerceData(null);
|
252 |
+
} elseif ( Mage::registry('froomerce_data') ) {
|
253 |
+
$form->setValues(Mage::registry('froomerce_data')->getData());
|
254 |
+
}
|
255 |
+
return parent::_prepareForm();
|
256 |
+
}
|
257 |
+
|
258 |
+
protected function getUser() {
|
259 |
+
|
260 |
+
$user_data = Mage::getModel('froomerce/froomerce')->getCollection();
|
261 |
+
$userinfo = array();
|
262 |
+
foreach($user_data as $user)
|
263 |
+
{
|
264 |
+
$userinfo['id'] = $user->getId();
|
265 |
+
$userinfo['email'] = $user->getEmail();
|
266 |
+
$userinfo['froomerce_user_id'] = $user->getFroomerceUserId();
|
267 |
+
}
|
268 |
+
return $userinfo;
|
269 |
+
}
|
270 |
+
protected function getExpotedShops($api_url, $shop_ids_tmp= array()) {
|
271 |
+
|
272 |
+
if(!count($shop_ids_tmp))
|
273 |
+
return;
|
274 |
+
|
275 |
+
$_shop_ids = implode(',', $shop_ids_tmp);
|
276 |
+
$fields = array(
|
277 |
+
'shop_ids'=>$_shop_ids,
|
278 |
+
'secret_token' => $this->secret_token,
|
279 |
+
'action_type' => 'verify_shop_export'
|
280 |
+
);
|
281 |
+
//url-ify the data for the POST
|
282 |
+
$fields_string = '';
|
283 |
+
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
|
284 |
+
$fields_string = rtrim($fields_string,'&');
|
285 |
+
|
286 |
+
$ch = curl_init();
|
287 |
+
curl_setopt($ch,CURLOPT_URL,$api_url);
|
288 |
+
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
|
289 |
+
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
|
290 |
+
$result = curl_exec($ch);
|
291 |
+
curl_close($ch);
|
292 |
+
$result = (array) json_decode($result);
|
293 |
+
$res = (array) $result['data'];
|
294 |
+
$exported = array();
|
295 |
+
foreach($res as $key=>$value)
|
296 |
+
{
|
297 |
+
if($value != 'not_exported')
|
298 |
+
$exported[] = $key;
|
299 |
+
}
|
300 |
+
return $exported;
|
301 |
+
}
|
302 |
+
}
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Facebook/Tabs.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Facebook_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
3 |
+
{
|
4 |
+
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('froomerce_tabs');
|
9 |
+
$this->setDestElementId('edit_form');
|
10 |
+
$this->setTitle(Mage::helper('froomerce')->__('Export to Facebook'));
|
11 |
+
}
|
12 |
+
|
13 |
+
protected function _beforeToHtml()
|
14 |
+
{
|
15 |
+
$this->addTab('facebook', array(
|
16 |
+
'label' => Mage::helper('froomerce')->__('Facebook'),
|
17 |
+
'content' => $this->getLayout()->createBlock('froomerce/adminhtml_froomerce_facebook_tab_facebook')->toHtml(),
|
18 |
+
));
|
19 |
+
|
20 |
+
return parent::_beforeToHtml();
|
21 |
+
}
|
22 |
+
}
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Grid.php
ADDED
@@ -0,0 +1,229 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
parent::__construct();
|
7 |
+
$this->setId('froomerceGrid');
|
8 |
+
$this->setDefaultSort('entity_id');
|
9 |
+
$this->setDefaultDir('desc');
|
10 |
+
$this->setSaveParametersInSession(true);
|
11 |
+
// $this->setUseAjax(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _getStore()
|
15 |
+
{
|
16 |
+
$storeId = (int) $this->getRequest()->getParam('store', 0);
|
17 |
+
return Mage::app()->getStore($storeId);
|
18 |
+
}
|
19 |
+
|
20 |
+
protected function _prepareCollection()
|
21 |
+
{
|
22 |
+
$store = $this->_getStore();
|
23 |
+
$stor_id = $store->getId();
|
24 |
+
$root_id = Mage::app()->getStore($stor_id)->getRootCategoryId();
|
25 |
+
|
26 |
+
$resource = Mage::getSingleton( 'core/resource' );
|
27 |
+
$customtable = $resource->getTableName('froomerce_products');
|
28 |
+
|
29 |
+
$collection = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($store->getCode())
|
30 |
+
->addAttributeToSelect('sku')
|
31 |
+
->addAttributeToSelect('name')
|
32 |
+
->addAttributeToSelect('attribute_set_id')
|
33 |
+
->addAttributeToSelect('type_id')
|
34 |
+
->joinField('qty',
|
35 |
+
'cataloginventory/stock_item',
|
36 |
+
'qty',
|
37 |
+
'product_id=entity_id',
|
38 |
+
'{{table}}.stock_id=1',
|
39 |
+
'left')
|
40 |
+
->joinField('is_in_stock',
|
41 |
+
'cataloginventory/stock_item',
|
42 |
+
'is_in_stock',
|
43 |
+
'product_id=entity_id',
|
44 |
+
'{{table}}.stock_id=1',
|
45 |
+
'left')
|
46 |
+
->joinField('store_id',
|
47 |
+
$customtable,
|
48 |
+
'store_id',
|
49 |
+
'product_id=entity_id',
|
50 |
+
null,
|
51 |
+
'right');
|
52 |
+
|
53 |
+
|
54 |
+
if ($store->getId()) {
|
55 |
+
//$collection->setStoreId($store->getId());
|
56 |
+
$adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
|
57 |
+
$collection->addStoreFilter($store);
|
58 |
+
$collection->joinAttribute('name', 'catalog_product/name', 'entity_id', null, 'inner', $adminStore);
|
59 |
+
$collection->joinAttribute('custom_name', 'catalog_product/name', 'entity_id', null, 'inner', $store->getId());
|
60 |
+
$collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner', $store->getId());
|
61 |
+
$collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner', $store->getId());
|
62 |
+
$collection->joinAttribute('price', 'catalog_product/price', 'entity_id', null, 'left', $store->getId());
|
63 |
+
}
|
64 |
+
else {
|
65 |
+
$collection->addAttributeToSelect('price');
|
66 |
+
$collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner');
|
67 |
+
$collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');
|
68 |
+
}
|
69 |
+
|
70 |
+
// Filter only enable and visible products
|
71 |
+
$collection->addAttributeToFilter('status', '1')
|
72 |
+
->addAttributeToFilter('visibility', array('neq' => 1));
|
73 |
+
|
74 |
+
$collection->addAttributeToFilter('is_in_stock', 1);
|
75 |
+
$collection->addFieldToFilter('store_id', $stor_id);
|
76 |
+
|
77 |
+
$this->setCollection($collection);
|
78 |
+
parent::_prepareCollection();
|
79 |
+
$this->getCollection()->addWebsiteNamesToResult();
|
80 |
+
|
81 |
+
return $this;
|
82 |
+
}
|
83 |
+
|
84 |
+
protected function _addColumnFilterToCollection($column)
|
85 |
+
{
|
86 |
+
if ($this->getCollection()) {
|
87 |
+
if ($column->getId() == 'websites') {
|
88 |
+
$this->getCollection()->joinField('websites',
|
89 |
+
'catalog/product_website',
|
90 |
+
'website_id',
|
91 |
+
'product_id=entity_id',
|
92 |
+
null,
|
93 |
+
'left');
|
94 |
+
}
|
95 |
+
}
|
96 |
+
return parent::_addColumnFilterToCollection($column);
|
97 |
+
}
|
98 |
+
|
99 |
+
protected function _prepareColumns()
|
100 |
+
{
|
101 |
+
$this->addColumn('entity_id',
|
102 |
+
array(
|
103 |
+
'header'=> Mage::helper('froomerce')->__('ID'),
|
104 |
+
'width' => '50px',
|
105 |
+
'type' => 'number',
|
106 |
+
'index' => 'entity_id',
|
107 |
+
));
|
108 |
+
$this->addColumn('name',
|
109 |
+
array(
|
110 |
+
'header'=> Mage::helper('froomerce')->__('Name'),
|
111 |
+
'index' => 'name',
|
112 |
+
));
|
113 |
+
|
114 |
+
$store = $this->_getStore();
|
115 |
+
if ($store->getId()) {
|
116 |
+
$this->addColumn('custom_name',
|
117 |
+
array(
|
118 |
+
'header'=> Mage::helper('froomerce')->__('Name in %s', $store->getName()),
|
119 |
+
'index' => 'custom_name',
|
120 |
+
));
|
121 |
+
}
|
122 |
+
|
123 |
+
$this->addColumn('type',
|
124 |
+
array(
|
125 |
+
'header'=> Mage::helper('froomerce')->__('Type'),
|
126 |
+
'width' => '60px',
|
127 |
+
'index' => 'type_id',
|
128 |
+
'type' => 'options',
|
129 |
+
'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
|
130 |
+
));
|
131 |
+
|
132 |
+
$sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
|
133 |
+
->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
|
134 |
+
->load()
|
135 |
+
->toOptionHash();
|
136 |
+
|
137 |
+
$this->addColumn('set_name',
|
138 |
+
array(
|
139 |
+
'header'=> Mage::helper('froomerce')->__('Attrib. Set Name'),
|
140 |
+
'width' => '100px',
|
141 |
+
'index' => 'attribute_set_id',
|
142 |
+
'type' => 'options',
|
143 |
+
'options' => $sets,
|
144 |
+
));
|
145 |
+
|
146 |
+
$this->addColumn('sku',
|
147 |
+
array(
|
148 |
+
'header'=> Mage::helper('froomerce')->__('SKU'),
|
149 |
+
'width' => '80px',
|
150 |
+
'index' => 'sku',
|
151 |
+
));
|
152 |
+
|
153 |
+
$store = $this->_getStore();
|
154 |
+
$this->addColumn('price',
|
155 |
+
array(
|
156 |
+
'header'=> Mage::helper('froomerce')->__('Price'),
|
157 |
+
'type' => 'price',
|
158 |
+
'currency_code' => $store->getBaseCurrency()->getCode(),
|
159 |
+
'index' => 'price',
|
160 |
+
));
|
161 |
+
|
162 |
+
$this->addColumn('qty',
|
163 |
+
array(
|
164 |
+
'header'=> Mage::helper('froomerce')->__('Qty'),
|
165 |
+
'width' => '100px',
|
166 |
+
'type' => 'number',
|
167 |
+
'index' => 'qty',
|
168 |
+
));
|
169 |
+
|
170 |
+
$this->addColumn('visibility',
|
171 |
+
array(
|
172 |
+
'header'=> Mage::helper('froomerce')->__('Visibility'),
|
173 |
+
'width' => '70px',
|
174 |
+
'index' => 'visibility',
|
175 |
+
'type' => 'options',
|
176 |
+
'options' => Mage::getModel('catalog/product_visibility')->getOptionArray(),
|
177 |
+
));
|
178 |
+
|
179 |
+
$this->addColumn('status',
|
180 |
+
array(
|
181 |
+
'header'=> Mage::helper('froomerce')->__('Status'),
|
182 |
+
'width' => '70px',
|
183 |
+
'index' => 'status',
|
184 |
+
'type' => 'options',
|
185 |
+
'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
|
186 |
+
));
|
187 |
+
|
188 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
189 |
+
$this->addColumn('websites',
|
190 |
+
array(
|
191 |
+
'header'=> Mage::helper('catalog')->__('Websites'),
|
192 |
+
'width' => '100px',
|
193 |
+
'sortable' => false,
|
194 |
+
'index' => 'websites',
|
195 |
+
'type' => 'options',
|
196 |
+
'options' => Mage::getModel('core/website')->getCollection()->toOptionHash(),
|
197 |
+
));
|
198 |
+
}
|
199 |
+
|
200 |
+
return parent::_prepareColumns();
|
201 |
+
}
|
202 |
+
|
203 |
+
protected function _prepareMassaction()
|
204 |
+
{
|
205 |
+
$storeUrl = '';
|
206 |
+
if($store = $this->getRequest()->getParam('store'))
|
207 |
+
$storeUrl .= '/store/'.$store.'/';
|
208 |
+
|
209 |
+
$this->setMassactionIdField('entity_id');
|
210 |
+
$this->getMassactionBlock()->setFormFieldName('product');
|
211 |
+
|
212 |
+
$this->getMassactionBlock()->addItem('export', array(
|
213 |
+
'label'=> Mage::helper('froomerce')->__('Export as Widget'),
|
214 |
+
'url' => $this->getUrl('*/adminhtml_froomerce/postwidget'.$storeUrl),
|
215 |
+
));
|
216 |
+
|
217 |
+
return $this;
|
218 |
+
}
|
219 |
+
|
220 |
+
public function getGridUrl()
|
221 |
+
{
|
222 |
+
return $this->getUrl('*/adminhtml_froomerce/check', array('_current'=>true));
|
223 |
+
}
|
224 |
+
|
225 |
+
public function getRowUrl($row)
|
226 |
+
{
|
227 |
+
return;
|
228 |
+
}
|
229 |
+
}
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Groups.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Groups extends Mage_Adminhtml_Block_Widget_Form_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
parent::__construct();
|
7 |
+
$this->_objectId = 'id';
|
8 |
+
$this->_blockGroup = 'froomerce';
|
9 |
+
$this->_controller = 'adminhtml_froomerce';
|
10 |
+
|
11 |
+
$this->_updateButton('save', 'label', Mage::helper('froomerce')->__('Next'));
|
12 |
+
$this->_removeButton('back');
|
13 |
+
}
|
14 |
+
|
15 |
+
public function getHeaderText()
|
16 |
+
{
|
17 |
+
if( Mage::registry('froomerce_data') && Mage::registry('froomerce_data')->getId() ) {
|
18 |
+
return Mage::helper('froomerce')->__("Select Store", $this->htmlEscape(Mage::registry('froomerce_data')->getTitle()));
|
19 |
+
} else {
|
20 |
+
return Mage::helper('froomerce')->__('Select Store');
|
21 |
+
}
|
22 |
+
}
|
23 |
+
}
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Groups/Form.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Groups_Form extends Mage_Adminhtml_Block_Widget_Form
|
3 |
+
{
|
4 |
+
protected function _prepareForm()
|
5 |
+
{
|
6 |
+
$post_url = $this->getUrl('*/*/stores', array('id' => $this->getRequest()->getParam('id')));
|
7 |
+
|
8 |
+
$form = new Varien_Data_Form(array(
|
9 |
+
'id' => 'edit_form',
|
10 |
+
'action' => $post_url,
|
11 |
+
'method' => 'post',
|
12 |
+
)
|
13 |
+
);
|
14 |
+
|
15 |
+
$form->setUseContainer(true);
|
16 |
+
$this->setForm($form);
|
17 |
+
return parent::_prepareForm();
|
18 |
+
}
|
19 |
+
|
20 |
+
}
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Groups/Tab/Form.php
ADDED
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Groups_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
3 |
+
{
|
4 |
+
protected function _prepareForm()
|
5 |
+
{
|
6 |
+
$form = new Varien_Data_Form();
|
7 |
+
$this->setForm($form);
|
8 |
+
|
9 |
+
$this->setUseAjax(true);
|
10 |
+
|
11 |
+
$from = 'froomerce';
|
12 |
+
if($from_nav = $this->getRequest()->getParam('from'))
|
13 |
+
{
|
14 |
+
if($from_nav == 'facebok')
|
15 |
+
$from = 'facebook';
|
16 |
+
}
|
17 |
+
$userData = $this->getUser();
|
18 |
+
$useremail = $userData['email'];
|
19 |
+
|
20 |
+
$fieldset = $form->addFieldset('froomerce_region', array('legend'=>Mage::helper('froomerce')->__('Select one of your magento store to export to '.$from.'<span class="contactus">Having Problems? Contact us
|
21 |
+
<a href="mailto:support@froomerce.com?subject='.$useremail.'">here</a></span>')));
|
22 |
+
|
23 |
+
$i = 0;
|
24 |
+
$configs = Mage::getModel('froomerce/config')->getCollection();
|
25 |
+
|
26 |
+
$ex_store_ids = array();
|
27 |
+
$statuses = array();
|
28 |
+
foreach($configs as $config)
|
29 |
+
{
|
30 |
+
if($config->getRegionId())
|
31 |
+
{
|
32 |
+
$ex_store_ids[] = $config->getStoreId();
|
33 |
+
$statuses[$config->getStoreId()] = $config->getStatus();
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
if($from == 'facebook')
|
38 |
+
{
|
39 |
+
$fieldset->addField('labl', 'label', array(
|
40 |
+
'label' => Mage::helper('froomerce')->__('<div class="alert">Only those stores can be exported to facebook which are already exported to froomerce</div>'),
|
41 |
+
));
|
42 |
+
}
|
43 |
+
|
44 |
+
$fieldset->addField('txt', 'label', array(
|
45 |
+
'label' => Mage::helper('froomerce')->__('<b>Select your magento store : </b>'),
|
46 |
+
'name' => 'txt',
|
47 |
+
));
|
48 |
+
|
49 |
+
$web_data = $this->getRequest()->getPost();
|
50 |
+
$web_id = $web_data['website_id'];
|
51 |
+
|
52 |
+
$checkd = true;
|
53 |
+
$baseURL = Mage::getBaseUrl();
|
54 |
+
if(Mage::getStoreConfig('web/url/use_store'))
|
55 |
+
$baseURL = Mage::app()->getStore($storecode)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
|
56 |
+
|
57 |
+
$tmp_url = explode('index.php', $baseURL);
|
58 |
+
$img_url = $tmp_url[0].'skin/adminhtml/default/default/images/joinbottom.gif';
|
59 |
+
|
60 |
+
$websites = Mage::app()->getWebsites($web_id);
|
61 |
+
foreach ($websites as $website){
|
62 |
+
if(!$website->getId() or $website->getId() != $web_id)
|
63 |
+
continue;
|
64 |
+
|
65 |
+
$fieldset->addField('label'.$i++, 'label', array(
|
66 |
+
'label' => Mage::helper('froomerce')->__('<b>'.$website->getName().' </b>'),
|
67 |
+
));
|
68 |
+
|
69 |
+
foreach ($website->getGroups() as $group) {
|
70 |
+
$mesg = 'Exported!';
|
71 |
+
foreach ($group->getStores() as $store) {
|
72 |
+
$found = false;
|
73 |
+
if($from == 'facebook')
|
74 |
+
{
|
75 |
+
if(in_array($store->getId(), $ex_store_ids))
|
76 |
+
{
|
77 |
+
if($statuses[$store->getId()] == 'Inprogress')
|
78 |
+
$mesg = 'Exporting products';
|
79 |
+
else
|
80 |
+
$mesg = 'Exported!';
|
81 |
+
$found = true;
|
82 |
+
}
|
83 |
+
else
|
84 |
+
{
|
85 |
+
$mesg = '';
|
86 |
+
}
|
87 |
+
}
|
88 |
+
else
|
89 |
+
{
|
90 |
+
if(!in_array($store->getId(), $ex_store_ids))
|
91 |
+
{
|
92 |
+
$found = true;
|
93 |
+
$mesg = '';
|
94 |
+
break;
|
95 |
+
}
|
96 |
+
else
|
97 |
+
{
|
98 |
+
if($statuses[$store->getId()] == 'Inprogress')
|
99 |
+
$mesg = 'Exporting products';
|
100 |
+
}
|
101 |
+
}
|
102 |
+
if($found)
|
103 |
+
break;
|
104 |
+
}
|
105 |
+
if($from == 'froomerce')
|
106 |
+
{
|
107 |
+
if( $mesg != '' )
|
108 |
+
{
|
109 |
+
$fieldset->addField('label'.$i++, 'label', array(
|
110 |
+
'label' => Mage::helper('froomerce')->__('<b> <img src="'.$img_url.'" /> '.$group->getName()),
|
111 |
+
'name' => 'exported',
|
112 |
+
'after_element_html' => '<small>'.$mesg.'</small>',
|
113 |
+
));
|
114 |
+
}
|
115 |
+
else
|
116 |
+
{
|
117 |
+
$fieldset->addField('radio'.$i++, 'radios', array(
|
118 |
+
'label' => Mage::helper('froomerce')->__('<b> <img src="'.$img_url.'" /> '.$group->getName().' </b>'),
|
119 |
+
'name' => 'group_id',
|
120 |
+
'onclick' => "",
|
121 |
+
'onchange' => "",
|
122 |
+
'value' => '1',
|
123 |
+
'values' => array(
|
124 |
+
array('value'=>$group->getId(), 'label' => ''),
|
125 |
+
),
|
126 |
+
'tabindex' => 1,
|
127 |
+
));
|
128 |
+
}
|
129 |
+
}
|
130 |
+
else
|
131 |
+
{
|
132 |
+
if( $mesg != '' )
|
133 |
+
{
|
134 |
+
$fieldset->addField('radio'.$i++, 'radios', array(
|
135 |
+
'label' => Mage::helper('froomerce')->__('<b> <img src="'.$img_url.'" /> '.$group->getName().' </b>'),
|
136 |
+
'name' => 'group_id',
|
137 |
+
'onclick' => "",
|
138 |
+
'onchange' => "",
|
139 |
+
'value' => '1',
|
140 |
+
'values' => array(
|
141 |
+
array('value'=>$group->getId(), 'label' => ''),
|
142 |
+
),
|
143 |
+
'tabindex' => 1,
|
144 |
+
));
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
|
152 |
+
if ( Mage::getSingleton('adminhtml/session')->getfroomerceData() )
|
153 |
+
{
|
154 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getFroomerceData());
|
155 |
+
Mage::getSingleton('adminhtml/session')->setFroomerceData(null);
|
156 |
+
} elseif ( Mage::registry('froomerce_data') ) {
|
157 |
+
$form->setValues(Mage::registry('froomerce_data')->getData());
|
158 |
+
}
|
159 |
+
return parent::_prepareForm();
|
160 |
+
}
|
161 |
+
protected function getUser() {
|
162 |
+
|
163 |
+
$user_data = Mage::getModel('froomerce/froomerce')->getCollection();
|
164 |
+
$userinfo = array();
|
165 |
+
foreach($user_data as $user)
|
166 |
+
{
|
167 |
+
$userinfo['id'] = $user->getId();
|
168 |
+
$userinfo['email'] = $user->getEmail();
|
169 |
+
$userinfo['froomerce_user_id'] = $user->getFroomerceUserId();
|
170 |
+
}
|
171 |
+
return $userinfo;
|
172 |
+
}
|
173 |
+
}
|
174 |
+
?>
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Groups/Tabs.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Groups_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('froomerce_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle(Mage::helper('froomerce')->__('Select Store'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$capt = 'Settings';
|
17 |
+
if($from_nav = $this->getRequest()->getParam('from'))
|
18 |
+
{
|
19 |
+
if($from_nav == 'facebok')
|
20 |
+
$capt = 'Facebook';
|
21 |
+
}
|
22 |
+
|
23 |
+
$this->addTab('export_store', array(
|
24 |
+
'label' => Mage::helper('froomerce')->__($capt),
|
25 |
+
'title' => Mage::helper('froomerce')->__($capt),
|
26 |
+
'content' => $this->getLayout()->createBlock('froomerce/adminhtml_froomerce_groups_tab_form')->toHtml(),
|
27 |
+
));
|
28 |
+
|
29 |
+
return parent::_beforeToHtml();
|
30 |
+
}
|
31 |
+
}
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Region.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Region extends Mage_Adminhtml_Block_Widget_Form_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->_objectId = 'id';
|
7 |
+
$this->_blockGroup = 'froomerce';
|
8 |
+
$this->_controller = 'adminhtml_froomerce';
|
9 |
+
parent::__construct();
|
10 |
+
$this->_updateButton('save', 'label', Mage::helper('froomerce')->__('Export to Froomerce'));
|
11 |
+
$this->_removeButton('back');
|
12 |
+
}
|
13 |
+
|
14 |
+
public function getHeaderText()
|
15 |
+
{
|
16 |
+
if( Mage::registry('froomerce_data') && Mage::registry('froomerce_data')->getId() ) {
|
17 |
+
return Mage::helper('froomerce')->__("Export to Froomerce", $this->htmlEscape(Mage::registry('froomerce_data')->getTitle()));
|
18 |
+
} else {
|
19 |
+
return Mage::helper('froomerce')->__('Export to Froomerce');
|
20 |
+
}
|
21 |
+
}
|
22 |
+
}
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Region/Form.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Region_Form extends Mage_Adminhtml_Block_Widget_Form
|
3 |
+
{
|
4 |
+
protected function _prepareForm()
|
5 |
+
{
|
6 |
+
$post_url = $this->getUrl('*/*/createshop', array('id' => $this->getRequest()->getParam('id')));
|
7 |
+
|
8 |
+
$form = new Varien_Data_Form(array(
|
9 |
+
'id' => 'edit_form',
|
10 |
+
'action' => $post_url,
|
11 |
+
'method' => 'post',
|
12 |
+
)
|
13 |
+
);
|
14 |
+
|
15 |
+
$form->setUseContainer(true);
|
16 |
+
$this->setForm($form);
|
17 |
+
return parent::_prepareForm();
|
18 |
+
}
|
19 |
+
|
20 |
+
}
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Region/Tab/Form.php
ADDED
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Region_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
3 |
+
{
|
4 |
+
private $url_dummy = 'http://www.servis.pk/';
|
5 |
+
private $url = 'http://www.froomerce.com/';
|
6 |
+
private $secret_token = '5e5225e8d60e8ec72a7fd96135a0e865';
|
7 |
+
|
8 |
+
protected function _prepareForm()
|
9 |
+
{
|
10 |
+
$form = new Varien_Data_Form();
|
11 |
+
$this->setForm($form);
|
12 |
+
|
13 |
+
$this->setUseAjax(true);
|
14 |
+
$i=0;
|
15 |
+
|
16 |
+
$userData = $this->getUser();
|
17 |
+
$useremail = $userData['email'];
|
18 |
+
|
19 |
+
$fieldset = $form->addFieldset('froomerce_region', array('legend'=>Mage::helper('froomerce')->__('Select one of your magento store
|
20 |
+
views to export to froomerce<span class="contactus">Having Problems? Contact us
|
21 |
+
<a href="mailto:support@froomerce.com?subject='.$useremail.'">here</a></span>')));
|
22 |
+
if($grop_data = $this->getRequest()->getPost())
|
23 |
+
$group_id = $grop_data['group_id'];
|
24 |
+
else
|
25 |
+
$group_id = $this->getRequest()->getParam('group_id');
|
26 |
+
|
27 |
+
$fieldset->addField('txt', 'label', array(
|
28 |
+
'label' => Mage::helper('froomerce')->__('<b>Select your magento store view to export : </b>'),
|
29 |
+
'name' => 'txt',
|
30 |
+
));
|
31 |
+
|
32 |
+
|
33 |
+
$baseURL = Mage::getBaseUrl();
|
34 |
+
if(Mage::getStoreConfig('web/url/use_store'))
|
35 |
+
$baseURL = Mage::app()->getStore($storecode)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
|
36 |
+
|
37 |
+
$tmp_url = explode('index.php', $baseURL);
|
38 |
+
$rot_url = rtrim(Mage::getRoot(), 'app');
|
39 |
+
$img_url = $tmp_url[0].'skin/adminhtml/default/default/images/joinbottom.gif';
|
40 |
+
$website_code='';
|
41 |
+
$websites = Mage::app()->getWebsites(true);
|
42 |
+
foreach ($websites as $website){
|
43 |
+
if(!$website->getId())
|
44 |
+
continue;
|
45 |
+
|
46 |
+
foreach ($website->getGroups() as $group) {
|
47 |
+
//<img src="'.$baseURL.'/skin/adminhtml/default/default/images/joinbottom.gif" />
|
48 |
+
if($group->getId() == $group_id)
|
49 |
+
{
|
50 |
+
$website_code = $website->getCode();
|
51 |
+
$fieldset->addField('label'.$i++, 'label', array(
|
52 |
+
'label' => Mage::helper('froomerce')->__('<b>'.$website->getName().' </b>'),
|
53 |
+
));
|
54 |
+
|
55 |
+
$fieldset->addField('label'.$i++, 'label', array(
|
56 |
+
'label' => Mage::helper('froomerce')->__('<b> <img src="'.$img_url.'" /> '.$group->getName().' </b>'),
|
57 |
+
));
|
58 |
+
break;
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
$configs = Mage::getModel('froomerce/config')->getCollection();
|
64 |
+
$configs->addFieldToFilter('group_id',$group_id);
|
65 |
+
|
66 |
+
$region_names = array();
|
67 |
+
$exp_region_ids = array();
|
68 |
+
$ex_store_ids = array();
|
69 |
+
$statuses = array();
|
70 |
+
foreach($configs as $config)
|
71 |
+
{
|
72 |
+
if($config->getRegionId())
|
73 |
+
{
|
74 |
+
$exp_region_ids[] = $config->getRegionId();
|
75 |
+
$ex_store_ids[] = $config->getStoreId();
|
76 |
+
$statuses[$config->getStoreId()] = $config->getStatus();
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
$stores = Mage::app()->getWebsite($website_code)->getStores();
|
81 |
+
|
82 |
+
$disable = false;
|
83 |
+
$show_name = true;
|
84 |
+
foreach($stores as $lang)
|
85 |
+
{
|
86 |
+
$store_code = $lang->getCode();
|
87 |
+
$store_name = $lang->getName();
|
88 |
+
$store_code_id = $lang->getId();
|
89 |
+
|
90 |
+
$grp_id = Mage::app()->getStore($store_code_id)->getGroup()->getGroupId();
|
91 |
+
|
92 |
+
if($group_id != $grp_id)
|
93 |
+
continue;
|
94 |
+
|
95 |
+
$grp_name = Mage::app()->getStore($store_code_id)->getGroup()->getName();
|
96 |
+
if($show_name)
|
97 |
+
{
|
98 |
+
$show_name=false;
|
99 |
+
$fieldset->addField('group_name', 'hidden', array(
|
100 |
+
'value' => $grp_name,
|
101 |
+
'name' => 'group_name',
|
102 |
+
));
|
103 |
+
$fieldset->addField('group_id', 'hidden', array(
|
104 |
+
'value' => $group_id,
|
105 |
+
'name' => 'group_id',
|
106 |
+
));
|
107 |
+
}
|
108 |
+
|
109 |
+
//echo '<br>'.Mage::app()->getStore($store_code_id)->getGroup()->getName();
|
110 |
+
|
111 |
+
if(in_array($store_code_id, $ex_store_ids))
|
112 |
+
{
|
113 |
+
$disable = true;
|
114 |
+
if($statuses[$store_code_id] == 'Inprogress')
|
115 |
+
$sts = 'Exporting products';
|
116 |
+
else
|
117 |
+
$sts = 'Exported';
|
118 |
+
|
119 |
+
|
120 |
+
$fieldset->addField('label'.$i++, 'label', array(
|
121 |
+
'label' => Mage::helper('froomerce')->__(' <img src="'.$img_url.'" /> '.$store_name),
|
122 |
+
'after_element_html' => '<small>'.$sts.'</small>',
|
123 |
+
));
|
124 |
+
}
|
125 |
+
else
|
126 |
+
{
|
127 |
+
$fieldset->addField('radio'.$i++, 'radios', array(
|
128 |
+
'label' => Mage::helper('froomerce')->__(' <img src="'.$img_url.'" /> '.$store_name),
|
129 |
+
'name' => 'store_code',
|
130 |
+
'value' => '1',
|
131 |
+
'values' => array(
|
132 |
+
array('value'=>$store_code, 'label' => ''),
|
133 |
+
),
|
134 |
+
'tabindex' => 1,
|
135 |
+
));
|
136 |
+
}
|
137 |
+
}
|
138 |
+
|
139 |
+
$fieldset->addField('label', 'label', array(
|
140 |
+
'label' => Mage::helper('froomerce')->__('<b> Choose the region that is related to your store :</b>'),
|
141 |
+
));
|
142 |
+
|
143 |
+
$regions = $this->getRegions();
|
144 |
+
foreach($regions['regions'] as $rgn)
|
145 |
+
{
|
146 |
+
|
147 |
+
if(!in_array($rgn->id, $exp_region_ids))
|
148 |
+
{
|
149 |
+
$fieldset->addField('radio'.$i++, 'radios', array(
|
150 |
+
'label' => Mage::helper('froomerce')->__(' <img src="'.$rgn->region_flag.'"> '.$rgn->region_name),
|
151 |
+
'name' => 'region_id',
|
152 |
+
'onclick' => "",
|
153 |
+
'onchange' => "",
|
154 |
+
'value' => '1',
|
155 |
+
'values' => array(
|
156 |
+
array('value'=>$rgn->id, 'label' => ''),
|
157 |
+
),
|
158 |
+
'tabindex' => 1,
|
159 |
+
));
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
if ( Mage::getSingleton('adminhtml/session')->getfroomerceData() )
|
164 |
+
{
|
165 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getFroomerceData());
|
166 |
+
Mage::getSingleton('adminhtml/session')->setFroomerceData(null);
|
167 |
+
} elseif ( Mage::registry('froomerce_data') ) {
|
168 |
+
$form->setValues(Mage::registry('froomerce_data')->getData());
|
169 |
+
}
|
170 |
+
return parent::_prepareForm();
|
171 |
+
}
|
172 |
+
|
173 |
+
protected function getRegions()
|
174 |
+
{
|
175 |
+
$user_data = Mage::getModel('froomerce/froomerce')->getCollection();
|
176 |
+
$id = 0;
|
177 |
+
foreach($user_data as $user)
|
178 |
+
{
|
179 |
+
$useremail = $user->getEmail();
|
180 |
+
}
|
181 |
+
if($useremail == 'dummy.export@servis.pk')
|
182 |
+
$api_url = $this->url_dummy.'api/user/index';
|
183 |
+
else
|
184 |
+
$api_url = $this->url.'api/user/index';
|
185 |
+
|
186 |
+
$fields = array(
|
187 |
+
'secret_token'=>$this->secret_token,
|
188 |
+
'action_type'=>'get_regions'
|
189 |
+
);
|
190 |
+
|
191 |
+
$fields_string = '';
|
192 |
+
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
|
193 |
+
$fields_string = rtrim($fields_string,'&');
|
194 |
+
|
195 |
+
$result = file_get_contents($api_url.'?'.$fields_string);
|
196 |
+
$result = json_decode($result);
|
197 |
+
return $result = (array) $result;
|
198 |
+
}
|
199 |
+
protected function getUser() {
|
200 |
+
|
201 |
+
$user_data = Mage::getModel('froomerce/froomerce')->getCollection();
|
202 |
+
$userinfo = array();
|
203 |
+
foreach($user_data as $user)
|
204 |
+
{
|
205 |
+
$userinfo['id'] = $user->getId();
|
206 |
+
$userinfo['email'] = $user->getEmail();
|
207 |
+
$userinfo['froomerce_user_id'] = $user->getFroomerceUserId();
|
208 |
+
}
|
209 |
+
return $userinfo;
|
210 |
+
}
|
211 |
+
|
212 |
+
}
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Region/Tabs.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Region_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('froomerce_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle(Mage::helper('froomerce')->__('Export stores to Froomerce'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$this->addTab('export_store', array(
|
17 |
+
'label' => Mage::helper('froomerce')->__('Export Stores'),
|
18 |
+
'title' => Mage::helper('froomerce')->__('Export Stores'),
|
19 |
+
'content' => $this->getLayout()->createBlock('froomerce/adminhtml_froomerce_region_tab_form')->toHtml(),
|
20 |
+
));
|
21 |
+
|
22 |
+
return parent::_beforeToHtml();
|
23 |
+
}
|
24 |
+
}
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Websites.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Websites extends Mage_Adminhtml_Block_Widget_Form_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
parent::__construct();
|
7 |
+
$this->_objectId = 'id';
|
8 |
+
$this->_blockGroup = 'froomerce';
|
9 |
+
$this->_controller = 'adminhtml_froomerce';
|
10 |
+
|
11 |
+
$this->_updateButton('save', 'label', Mage::helper('froomerce')->__('Next'));
|
12 |
+
$this->_removeButton('back');
|
13 |
+
}
|
14 |
+
|
15 |
+
public function getHeaderText()
|
16 |
+
{
|
17 |
+
if( Mage::registry('froomerce_data') && Mage::registry('froomerce_data')->getId() ) {
|
18 |
+
return Mage::helper('froomerce')->__("Select Website", $this->htmlEscape(Mage::registry('froomerce_data')->getTitle()));
|
19 |
+
} else {
|
20 |
+
return Mage::helper('froomerce')->__('Select Website');
|
21 |
+
}
|
22 |
+
}
|
23 |
+
}
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Websites/Form.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Websites_Form extends Mage_Adminhtml_Block_Widget_Form
|
3 |
+
{
|
4 |
+
protected function _prepareForm()
|
5 |
+
{
|
6 |
+
$post_url = $this->getUrl('*/*/stores', array('id' => $this->getRequest()->getParam('id')));
|
7 |
+
|
8 |
+
$form = new Varien_Data_Form(array(
|
9 |
+
'id' => 'edit_form',
|
10 |
+
'action' => $post_url,
|
11 |
+
'method' => 'post',
|
12 |
+
)
|
13 |
+
);
|
14 |
+
|
15 |
+
$form->setUseContainer(true);
|
16 |
+
$this->setForm($form);
|
17 |
+
return parent::_prepareForm();
|
18 |
+
}
|
19 |
+
|
20 |
+
}
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Websites/Tab/Form.php
ADDED
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Websites_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
3 |
+
{
|
4 |
+
protected function _prepareForm()
|
5 |
+
{
|
6 |
+
$form = new Varien_Data_Form();
|
7 |
+
$this->setForm($form);
|
8 |
+
|
9 |
+
$this->setUseAjax(true);
|
10 |
+
|
11 |
+
$from = 'froomerce';
|
12 |
+
if($from_nav = $this->getRequest()->getParam('from'))
|
13 |
+
{
|
14 |
+
if($from_nav == 'facebok')
|
15 |
+
$from = 'facebook';
|
16 |
+
}
|
17 |
+
$userData = $this->getUser();
|
18 |
+
$useremail = $userData['email'];
|
19 |
+
|
20 |
+
$fieldset = $form->addFieldset('froomerce_region', array('legend'=>Mage::helper('froomerce')->__('Select one of your magento website to export to '.$from.'<span class="contactus">Having Problems? Contact us
|
21 |
+
<a href="mailto:support@froomerce.com?subject='.$useremail.'">here</a></span>')));
|
22 |
+
|
23 |
+
// $stores = Mage::app()->getWebsite(true)->getStores(2);
|
24 |
+
|
25 |
+
$configs = Mage::getModel('froomerce/config')->getCollection();
|
26 |
+
|
27 |
+
$ex_store_ids = array();
|
28 |
+
$statuses = array();
|
29 |
+
foreach($configs as $config)
|
30 |
+
{
|
31 |
+
if($config->getRegionId())
|
32 |
+
{
|
33 |
+
$ex_store_ids[] = $config->getStoreId();
|
34 |
+
$statuses[$config->getStoreId()] = $config->getStatus();
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
$i = 0;
|
39 |
+
|
40 |
+
if($from == 'facebook')
|
41 |
+
{
|
42 |
+
$fieldset->addField('labl', 'label', array(
|
43 |
+
'label' => Mage::helper('froomerce')->__('<div class="alert">Only those stores can be exported to facebook which are already exported to froomerce</div>'),
|
44 |
+
));
|
45 |
+
}
|
46 |
+
|
47 |
+
$showed = true;
|
48 |
+
$found = false;
|
49 |
+
$websites = Mage::app()->getWebsites(true);
|
50 |
+
foreach ($websites as $website){
|
51 |
+
if(!$website->getId())
|
52 |
+
continue;
|
53 |
+
|
54 |
+
$mesg = 'Exported!';
|
55 |
+
foreach ($website->getGroups() as $group) {
|
56 |
+
|
57 |
+
foreach ($group->getStores() as $store) {
|
58 |
+
|
59 |
+
if($from == 'facebook')
|
60 |
+
{
|
61 |
+
if(in_array($store->getId(), $ex_store_ids))
|
62 |
+
{
|
63 |
+
$found = true;
|
64 |
+
if($statuses[$store->getId()] == 'Inprogress')
|
65 |
+
$mesg = 'Exporting products';
|
66 |
+
else
|
67 |
+
$mesg = 'Exported!';
|
68 |
+
break;
|
69 |
+
}
|
70 |
+
else
|
71 |
+
{
|
72 |
+
$mesg = '';
|
73 |
+
}
|
74 |
+
}
|
75 |
+
else
|
76 |
+
{
|
77 |
+
if(!in_array($store->getId(), $ex_store_ids))
|
78 |
+
{
|
79 |
+
$found = true;
|
80 |
+
$mesg = '';
|
81 |
+
break;
|
82 |
+
}
|
83 |
+
else
|
84 |
+
{
|
85 |
+
if($statuses[$store->getId()] == 'Inprogress')
|
86 |
+
$mesg = 'Exporting products';
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
}
|
91 |
+
if($found)
|
92 |
+
break;
|
93 |
+
}
|
94 |
+
|
95 |
+
if($from == 'facebook')
|
96 |
+
{
|
97 |
+
if($mesg != '')
|
98 |
+
{
|
99 |
+
if($showed)
|
100 |
+
{
|
101 |
+
$showed = false;
|
102 |
+
$fieldset->addField('txt', 'label', array(
|
103 |
+
'label' => Mage::helper('froomerce')->__('<b>Select your website : </b>'),
|
104 |
+
'name' => 'txt',
|
105 |
+
));
|
106 |
+
}
|
107 |
+
|
108 |
+
$fieldset->addField('radio'.$i++, 'radios', array(
|
109 |
+
'label' => Mage::helper('froomerce')->__('<b> '.$website->getName().' </b>'),
|
110 |
+
'name' => 'website_id',
|
111 |
+
'onclick' => "",
|
112 |
+
'onchange' => "",
|
113 |
+
'value' => '1',
|
114 |
+
'values' => array(
|
115 |
+
array('value'=>$website->getId(), 'label' => ''),
|
116 |
+
),
|
117 |
+
'tabindex' => 1,
|
118 |
+
));
|
119 |
+
}
|
120 |
+
}
|
121 |
+
else
|
122 |
+
{
|
123 |
+
if($showed)
|
124 |
+
{
|
125 |
+
$showed = false;
|
126 |
+
$fieldset->addField('txt', 'label', array(
|
127 |
+
'label' => Mage::helper('froomerce')->__('<b>Select your website : </b>'),
|
128 |
+
'name' => 'txt',
|
129 |
+
));
|
130 |
+
}
|
131 |
+
if($mesg != '')
|
132 |
+
{
|
133 |
+
$fieldset->addField('txt'.$i++, 'label', array(
|
134 |
+
'label' => Mage::helper('froomerce')->__('<b> '.$website->getName().' </b>'),
|
135 |
+
'name' => 'txt',
|
136 |
+
'after_element_html' => Mage::helper('froomerce')->__('<small>'.$mesg.'</small>'),
|
137 |
+
));
|
138 |
+
}
|
139 |
+
else
|
140 |
+
{
|
141 |
+
$fieldset->addField('radio'.$i++, 'radios', array(
|
142 |
+
'label' => Mage::helper('froomerce')->__('<b> '.$website->getName().' </b>'),
|
143 |
+
'name' => 'website_id',
|
144 |
+
'onclick' => "",
|
145 |
+
'onchange' => "",
|
146 |
+
'value' => '1',
|
147 |
+
'values' => array(
|
148 |
+
array('value'=>$website->getId(), 'label' => ''),
|
149 |
+
),
|
150 |
+
'tabindex' => 1,
|
151 |
+
|
152 |
+
));
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
}
|
157 |
+
|
158 |
+
if ( Mage::getSingleton('adminhtml/session')->getfroomerceData() )
|
159 |
+
{
|
160 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getFroomerceData());
|
161 |
+
Mage::getSingleton('adminhtml/session')->setFroomerceData(null);
|
162 |
+
} elseif ( Mage::registry('froomerce_data') ) {
|
163 |
+
$form->setValues(Mage::registry('froomerce_data')->getData());
|
164 |
+
}
|
165 |
+
return parent::_prepareForm();
|
166 |
+
}
|
167 |
+
|
168 |
+
protected function getUser() {
|
169 |
+
|
170 |
+
$user_data = Mage::getModel('froomerce/froomerce')->getCollection();
|
171 |
+
$userinfo = array();
|
172 |
+
foreach($user_data as $user)
|
173 |
+
{
|
174 |
+
$userinfo['id'] = $user->getId();
|
175 |
+
$userinfo['email'] = $user->getEmail();
|
176 |
+
$userinfo['froomerce_user_id'] = $user->getFroomerceUserId();
|
177 |
+
}
|
178 |
+
return $userinfo;
|
179 |
+
}
|
180 |
+
|
181 |
+
}
|
182 |
+
?>
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/Websites/Tabs.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Websites_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('froomerce_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle(Mage::helper('froomerce')->__('Select Website'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$capt = 'Settings';
|
17 |
+
if($from_nav = $this->getRequest()->getParam('from'))
|
18 |
+
{
|
19 |
+
if($from_nav == 'facebok')
|
20 |
+
$capt = 'Facebook';
|
21 |
+
}
|
22 |
+
$this->addTab('export_store', array(
|
23 |
+
'label' => Mage::helper('froomerce')->__($capt),
|
24 |
+
'title' => Mage::helper('froomerce')->__($capt),
|
25 |
+
'content' => $this->getLayout()->createBlock('froomerce/adminhtml_froomerce_websites_tab_form')->toHtml(),
|
26 |
+
));
|
27 |
+
|
28 |
+
return parent::_beforeToHtml();
|
29 |
+
}
|
30 |
+
}
|
app/code/local/Addon/Froomerce/Block/Adminhtml/Froomerce/grid_backup/Grid.php
ADDED
@@ -0,0 +1,233 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Block_Adminhtml_Froomerce_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
parent::__construct();
|
7 |
+
$this->setId('froomerceGrid');
|
8 |
+
$this->setDefaultSort('entity_id');
|
9 |
+
$this->setDefaultDir('desc');
|
10 |
+
$this->setSaveParametersInSession(true);
|
11 |
+
// $this->setUseAjax(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _getStore()
|
15 |
+
{
|
16 |
+
$storeId = (int) $this->getRequest()->getParam('store', 0);
|
17 |
+
return Mage::app()->getStore($storeId);
|
18 |
+
}
|
19 |
+
|
20 |
+
protected function _prepareCollection()
|
21 |
+
{
|
22 |
+
$store = $this->_getStore();
|
23 |
+
$collection = Mage::getModel('catalog/product')->getCollection()
|
24 |
+
->addAttributeToSelect('sku')
|
25 |
+
->addAttributeToSelect('name')
|
26 |
+
->addAttributeToSelect('attribute_set_id')
|
27 |
+
->addAttributeToSelect('type_id')
|
28 |
+
->joinField('qty',
|
29 |
+
'cataloginventory/stock_item',
|
30 |
+
'qty',
|
31 |
+
'product_id=entity_id',
|
32 |
+
'{{table}}.stock_id=1',
|
33 |
+
'left')
|
34 |
+
->joinField('is_in_stock',
|
35 |
+
'cataloginventory/stock_item',
|
36 |
+
'is_in_stock',
|
37 |
+
'product_id=entity_id',
|
38 |
+
'{{table}}.stock_id=1',
|
39 |
+
'left');
|
40 |
+
if ($store->getId()) {
|
41 |
+
//$collection->setStoreId($store->getId());
|
42 |
+
$adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
|
43 |
+
$collection->addStoreFilter($store);
|
44 |
+
$collection->joinAttribute('name', 'catalog_product/name', 'entity_id', null, 'inner', $adminStore);
|
45 |
+
$collection->joinAttribute('custom_name', 'catalog_product/name', 'entity_id', null, 'inner', $store->getId());
|
46 |
+
$collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner', $store->getId());
|
47 |
+
$collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner', $store->getId());
|
48 |
+
$collection->joinAttribute('price', 'catalog_product/price', 'entity_id', null, 'left', $store->getId());
|
49 |
+
}
|
50 |
+
else {
|
51 |
+
$collection->addAttributeToSelect('price');
|
52 |
+
$collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner');
|
53 |
+
$collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');
|
54 |
+
}
|
55 |
+
|
56 |
+
// Filter only enable and visible products
|
57 |
+
$collection->addAttributeToFilter('status', '1')
|
58 |
+
->addAttributeToFilter('visibility', array('in' => array(2,3,4)));
|
59 |
+
$collection->addAttributeToFilter('is_in_stock', 1);
|
60 |
+
|
61 |
+
// Applying filter for products that belongs to atleast one category
|
62 |
+
/*$collection
|
63 |
+
->joinField('category_id',
|
64 |
+
'catalog_category_product',
|
65 |
+
'category_id',
|
66 |
+
'product_id=entity_id',
|
67 |
+
null,
|
68 |
+
'right');
|
69 |
+
|
70 |
+
// Getting root Id
|
71 |
+
$root = Mage::getModel('catalog/category')->load( Mage::app()->getWebsite(true)->getDefaultStore()->getRootCategoryId());
|
72 |
+
$root_id = $root->getId();
|
73 |
+
$child = $root->getAllChildren(true);
|
74 |
+
//echo implode(',', $child);
|
75 |
+
$collection->getSelect()->distinct(true);
|
76 |
+
//$collection->addAttributeToFilter('category_id',array('finset'=>3,4,8,9,10));
|
77 |
+
//$collection->addAttributeToFilter('category_id', array('in' => array(3,4,8,9,10)));
|
78 |
+
//$collection->addAttributeToFilter('category_id', array('in' => $child));
|
79 |
+
*/
|
80 |
+
// End of filter
|
81 |
+
|
82 |
+
$this->setCollection($collection);
|
83 |
+
parent::_prepareCollection();
|
84 |
+
$this->getCollection()->addWebsiteNamesToResult();
|
85 |
+
return $this;
|
86 |
+
}
|
87 |
+
|
88 |
+
protected function _addColumnFilterToCollection($column)
|
89 |
+
{
|
90 |
+
if ($this->getCollection()) {
|
91 |
+
if ($column->getId() == 'websites') {
|
92 |
+
$this->getCollection()->joinField('websites',
|
93 |
+
'catalog/product_website',
|
94 |
+
'website_id',
|
95 |
+
'product_id=entity_id',
|
96 |
+
null,
|
97 |
+
'left');
|
98 |
+
}
|
99 |
+
}
|
100 |
+
return parent::_addColumnFilterToCollection($column);
|
101 |
+
}
|
102 |
+
|
103 |
+
protected function _prepareColumns()
|
104 |
+
{
|
105 |
+
$this->addColumn('entity_id',
|
106 |
+
array(
|
107 |
+
'header'=> Mage::helper('froomerce')->__('ID'),
|
108 |
+
'width' => '50px',
|
109 |
+
'type' => 'number',
|
110 |
+
'index' => 'entity_id',
|
111 |
+
));
|
112 |
+
$this->addColumn('name',
|
113 |
+
array(
|
114 |
+
'header'=> Mage::helper('froomerce')->__('Name'),
|
115 |
+
'index' => 'name',
|
116 |
+
));
|
117 |
+
|
118 |
+
$store = $this->_getStore();
|
119 |
+
if ($store->getId()) {
|
120 |
+
$this->addColumn('custom_name',
|
121 |
+
array(
|
122 |
+
'header'=> Mage::helper('froomerce')->__('Name in %s', $store->getName()),
|
123 |
+
'index' => 'custom_name',
|
124 |
+
));
|
125 |
+
}
|
126 |
+
|
127 |
+
$this->addColumn('type',
|
128 |
+
array(
|
129 |
+
'header'=> Mage::helper('froomerce')->__('Type'),
|
130 |
+
'width' => '60px',
|
131 |
+
'index' => 'type_id',
|
132 |
+
'type' => 'options',
|
133 |
+
'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
|
134 |
+
));
|
135 |
+
|
136 |
+
$sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
|
137 |
+
->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
|
138 |
+
->load()
|
139 |
+
->toOptionHash();
|
140 |
+
|
141 |
+
$this->addColumn('set_name',
|
142 |
+
array(
|
143 |
+
'header'=> Mage::helper('froomerce')->__('Attrib. Set Name'),
|
144 |
+
'width' => '100px',
|
145 |
+
'index' => 'attribute_set_id',
|
146 |
+
'type' => 'options',
|
147 |
+
'options' => $sets,
|
148 |
+
));
|
149 |
+
|
150 |
+
$this->addColumn('sku',
|
151 |
+
array(
|
152 |
+
'header'=> Mage::helper('froomerce')->__('SKU'),
|
153 |
+
'width' => '80px',
|
154 |
+
'index' => 'sku',
|
155 |
+
));
|
156 |
+
|
157 |
+
$store = $this->_getStore();
|
158 |
+
$this->addColumn('price',
|
159 |
+
array(
|
160 |
+
'header'=> Mage::helper('froomerce')->__('Price'),
|
161 |
+
'type' => 'price',
|
162 |
+
'currency_code' => $store->getBaseCurrency()->getCode(),
|
163 |
+
'index' => 'price',
|
164 |
+
));
|
165 |
+
|
166 |
+
$this->addColumn('qty',
|
167 |
+
array(
|
168 |
+
'header'=> Mage::helper('froomerce')->__('Qty'),
|
169 |
+
'width' => '100px',
|
170 |
+
'type' => 'number',
|
171 |
+
'index' => 'qty',
|
172 |
+
));
|
173 |
+
|
174 |
+
$this->addColumn('visibility',
|
175 |
+
array(
|
176 |
+
'header'=> Mage::helper('froomerce')->__('Visibility'),
|
177 |
+
'width' => '70px',
|
178 |
+
'index' => 'visibility',
|
179 |
+
'type' => 'options',
|
180 |
+
'options' => Mage::getModel('catalog/product_visibility')->getOptionArray(),
|
181 |
+
));
|
182 |
+
|
183 |
+
$this->addColumn('status',
|
184 |
+
array(
|
185 |
+
'header'=> Mage::helper('froomerce')->__('Status'),
|
186 |
+
'width' => '70px',
|
187 |
+
'index' => 'status',
|
188 |
+
'type' => 'options',
|
189 |
+
'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
|
190 |
+
));
|
191 |
+
|
192 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
193 |
+
$this->addColumn('websites',
|
194 |
+
array(
|
195 |
+
'header'=> Mage::helper('catalog')->__('Websites'),
|
196 |
+
'width' => '100px',
|
197 |
+
'sortable' => false,
|
198 |
+
'index' => 'websites',
|
199 |
+
'type' => 'options',
|
200 |
+
'options' => Mage::getModel('core/website')->getCollection()->toOptionHash(),
|
201 |
+
));
|
202 |
+
}
|
203 |
+
|
204 |
+
return parent::_prepareColumns();
|
205 |
+
}
|
206 |
+
|
207 |
+
protected function _prepareMassaction()
|
208 |
+
{
|
209 |
+
$storeUrl = '';
|
210 |
+
if($store = $this->getRequest()->getParam('store'))
|
211 |
+
$storeUrl .= '/store/'.$store.'/';
|
212 |
+
|
213 |
+
$this->setMassactionIdField('entity_id');
|
214 |
+
$this->getMassactionBlock()->setFormFieldName('product');
|
215 |
+
|
216 |
+
$this->getMassactionBlock()->addItem('export', array(
|
217 |
+
'label'=> Mage::helper('froomerce')->__('Export as Widget'),
|
218 |
+
'url' => $this->getUrl('*/adminhtml_froomerce/postwidget'.$storeUrl),
|
219 |
+
));
|
220 |
+
|
221 |
+
return $this;
|
222 |
+
}
|
223 |
+
|
224 |
+
public function getGridUrl()
|
225 |
+
{
|
226 |
+
return $this->getUrl('*/adminhtml_froomerce/check', array('_current'=>true));
|
227 |
+
}
|
228 |
+
|
229 |
+
public function getRowUrl($row)
|
230 |
+
{
|
231 |
+
return;
|
232 |
+
}
|
233 |
+
}
|
app/code/local/Addon/Froomerce/Block/Froomerce.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Block_Froomerce extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
public function _prepareLayout()
|
5 |
+
{
|
6 |
+
return parent::_prepareLayout();
|
7 |
+
}
|
8 |
+
|
9 |
+
public function getFroomerce()
|
10 |
+
{
|
11 |
+
if (!$this->hasData('froomerce')) {
|
12 |
+
$this->setData('froomerce', Mage::registry('froomerce'));
|
13 |
+
}
|
14 |
+
return $this->getData('froomerce');
|
15 |
+
}
|
16 |
+
}
|
app/code/local/Addon/Froomerce/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Addon_Froomerce_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/local/Addon/Froomerce/Model/Config.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Addon_Froomerce_Model_Config extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('froomerce/config');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Addon/Froomerce/Model/Froomerce.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Model_Froomerce extends Mage_Core_Model_Abstract
|
3 |
+
{
|
4 |
+
public function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->_init('froomerce/froomerce');
|
8 |
+
}
|
9 |
+
}
|
app/code/local/Addon/Froomerce/Model/Mysql4/Collection.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Model_Mysql4_Collection extends Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Get SQL for get record count
|
6 |
+
*
|
7 |
+
* @return Varien_Db_Select
|
8 |
+
*/
|
9 |
+
public function getSelectCountSql()
|
10 |
+
{
|
11 |
+
$this->_renderFilters();
|
12 |
+
|
13 |
+
die('override');
|
14 |
+
$countSelect = clone $this->getSelect();
|
15 |
+
$countSelect->reset(Zend_Db_Select::ORDER);
|
16 |
+
$countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
|
17 |
+
$countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
|
18 |
+
$countSelect->reset(Zend_Db_Select::COLUMNS);
|
19 |
+
|
20 |
+
//Added this code - START -------------------->
|
21 |
+
if (Mage::getSingleton('adminhtml/url')->getRequest()->getModuleName() == 'froomerce') {
|
22 |
+
$countSelect->reset(Zend_Db_Select::GROUP);
|
23 |
+
}
|
24 |
+
//Added this code - END -----------------------<
|
25 |
+
|
26 |
+
$countSelect->from('', 'COUNT(DISTINCT e.entity_id)');
|
27 |
+
$countSelect->resetJoinLeft();
|
28 |
+
|
29 |
+
return $countSelect;
|
30 |
+
|
31 |
+
}
|
32 |
+
}
|
app/code/local/Addon/Froomerce/Model/Mysql4/Config.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Addon_Froomerce_Model_Mysql4_Config extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the id refers to the key field in your database table.
|
8 |
+
$this->_init('froomerce/froomerce_config', 'id');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Addon/Froomerce/Model/Mysql4/Config/Collection.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Model_Mysql4_Config_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
3 |
+
{
|
4 |
+
public function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->_init('froomerce/config');
|
8 |
+
}
|
9 |
+
}
|
app/code/local/Addon/Froomerce/Model/Mysql4/Froomerce.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Addon_Froomerce_Model_Mysql4_Froomerce extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the user_id refers to the key field in your database table.
|
8 |
+
$this->_init('froomerce/froomerce_users', 'user_id');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Addon/Froomerce/Model/Mysql4/Froomerce/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Addon_Froomerce_Model_Mysql4_Froomerce_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('froomerce/froomerce');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Addon/Froomerce/Model/Mysql4/Products.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Addon_Froomerce_Model_Mysql4_Products extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the id refers to the key field in your database table.
|
8 |
+
$this->_init('froomerce/froomerce_products', 'id');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Addon/Froomerce/Model/Mysql4/Products/Collection.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Model_Mysql4_Products_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
3 |
+
{
|
4 |
+
public function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->_init('froomerce/products');
|
8 |
+
}
|
9 |
+
}
|
app/code/local/Addon/Froomerce/Model/Observer.php
ADDED
@@ -0,0 +1,211 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Model_Observer
|
3 |
+
{
|
4 |
+
private $secret_token = '5e5225e8d60e8ec72a7fd96135a0e865';
|
5 |
+
private $url_dummy = 'http://www.servis.pk/api/productfeed/index';
|
6 |
+
private $url = 'http://www.froomerce.com/api/productfeed/index';
|
7 |
+
|
8 |
+
public function __construct()
|
9 |
+
{
|
10 |
+
}
|
11 |
+
/**
|
12 |
+
* Sends differnt API requests on spacific events
|
13 |
+
* @param Varien_Event_Observer $observer
|
14 |
+
* @return Addon_Froomerce_Model_Observer
|
15 |
+
*/
|
16 |
+
|
17 |
+
public function checkoutAfter($observer)
|
18 |
+
{
|
19 |
+
$store_id = Mage::app()->getStore()->getId();
|
20 |
+
$configs = Mage::getModel('froomerce/config')->getCollection();
|
21 |
+
$configs->addFieldToFilter('store_id',$store_id);
|
22 |
+
$shop_id = 0;
|
23 |
+
foreach($configs as $config)
|
24 |
+
{
|
25 |
+
$shop_id = $config->getFroomerceShopId();
|
26 |
+
}
|
27 |
+
|
28 |
+
$rst = $this->getUser(); // Getting user info
|
29 |
+
|
30 |
+
// Check User if exist
|
31 |
+
if($shop_id)
|
32 |
+
{
|
33 |
+
$froomerce_user_id = $rst['froomerce_user_id'];
|
34 |
+
$useremail = $rst['email'];
|
35 |
+
$froomerce_shop_id = $shop_id;
|
36 |
+
|
37 |
+
$orders = $observer->getEvent()->getOrder();
|
38 |
+
$items = $orders->getAllItems();
|
39 |
+
$product_ids = array();
|
40 |
+
foreach ($items as $item) {
|
41 |
+
$product = $item->getProduct();
|
42 |
+
$product_ids[] = $product->getId();
|
43 |
+
}
|
44 |
+
|
45 |
+
foreach($product_ids as $id)
|
46 |
+
{
|
47 |
+
$collection = Mage::getModel('catalog/product')->getCollection();
|
48 |
+
$collection->addAttributeToFilter('entity_id',$id);
|
49 |
+
$collection->addAttributeToSelect('*');
|
50 |
+
|
51 |
+
$out_of_stock = array();
|
52 |
+
foreach($collection as $prod)
|
53 |
+
{
|
54 |
+
$qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($prod)->getQty();
|
55 |
+
if($qty < 1)
|
56 |
+
$out_of_stock[] = $prod->getId();
|
57 |
+
}
|
58 |
+
}
|
59 |
+
if(count($out_of_stock))
|
60 |
+
{
|
61 |
+
$action_type = 'disable_products';
|
62 |
+
$outofstock = implode(',', $out_of_stock);
|
63 |
+
$fields = array(
|
64 |
+
'secret_token'=>$this->secret_token,
|
65 |
+
'product_ids'=> $outofstock,
|
66 |
+
'shop_id'=>$froomerce_shop_id,
|
67 |
+
'user_id'=> $froomerce_user_id,
|
68 |
+
'action_type' => $action_type
|
69 |
+
);
|
70 |
+
|
71 |
+
// Deleting products from exported products table
|
72 |
+
$resource = Mage::getSingleton( 'core/resource' );
|
73 |
+
$write = $resource->getConnection('core_write');
|
74 |
+
$table = $resource->getTableName('froomerce_products');
|
75 |
+
$write->query("DELETE FROM ".$table ." WHERE product_id IN (".$outofstock.")");
|
76 |
+
//End
|
77 |
+
//url-ify the data for the POST
|
78 |
+
$fields_string = '';
|
79 |
+
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
|
80 |
+
$fields_string = rtrim($fields_string,'&');
|
81 |
+
|
82 |
+
if($useremail == 'dummy.export@servis.pk')
|
83 |
+
$url_post = $this->url_dummy;
|
84 |
+
else
|
85 |
+
$url_post = $this->url;
|
86 |
+
|
87 |
+
// CURL Request section
|
88 |
+
$ch = curl_init();
|
89 |
+
curl_setopt($ch,CURLOPT_URL,$url_post);
|
90 |
+
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
|
91 |
+
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
|
92 |
+
$result = curl_exec($ch);
|
93 |
+
curl_close($ch);
|
94 |
+
}
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
public function sendNewProductRequest($observer)
|
99 |
+
{
|
100 |
+
$collectm =$observer->getProduct();
|
101 |
+
$product_id = $collectm->getId();
|
102 |
+
$shop_ids = array();
|
103 |
+
|
104 |
+
$referer = $_SERVER['HTTP_REFERER'];
|
105 |
+
$res = explode('/edit/', $referer);
|
106 |
+
$check_new = count($res);
|
107 |
+
if($check_new < 2)// that's mean it is not an update product request
|
108 |
+
return;
|
109 |
+
|
110 |
+
if ($store_id = Mage::app()->getFrontController()->getRequest()->getParam('store'))
|
111 |
+
{
|
112 |
+
$configs = Mage::getModel('froomerce/config')->getCollection();
|
113 |
+
$configs->addFieldToFilter('store_id',$store_id);
|
114 |
+
foreach($configs as $config)
|
115 |
+
{
|
116 |
+
$shop_id = $config->getFroomerceShopId();
|
117 |
+
|
118 |
+
if($shop_id)
|
119 |
+
$shop_ids[]= $shop_id;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
else
|
123 |
+
{
|
124 |
+
$configs = Mage::getModel('froomerce/config')->getCollection();
|
125 |
+
foreach($configs as $config)
|
126 |
+
{
|
127 |
+
$shop_id = $config->getFroomerceShopId();
|
128 |
+
|
129 |
+
if($shop_id)
|
130 |
+
$shop_ids[]= $shop_id;
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
$rst = $this->getUser(); // Getting user info
|
135 |
+
|
136 |
+
// Check User if exist
|
137 |
+
if(count($shop_ids))
|
138 |
+
{
|
139 |
+
$froomerce_user_id = $rst['froomerce_user_id'];
|
140 |
+
$useremail = $rst['email'];
|
141 |
+
$qty_obj = Mage::getModel('cataloginventory/stock_item')->loadByProduct($collectm);
|
142 |
+
$qty = $qty_obj->getQty();
|
143 |
+
|
144 |
+
if(empty($collectm['stock_item']->is_in_stock))
|
145 |
+
{
|
146 |
+
$is_in_stock = $qty_obj->is_in_stock;
|
147 |
+
}
|
148 |
+
else
|
149 |
+
{
|
150 |
+
$is_in_stock = $collectm['stock_item']->is_in_stock;
|
151 |
+
}
|
152 |
+
|
153 |
+
if($collectm['type_id'] != 'configurable' and ($qty < 1 or $is_in_stock==0))
|
154 |
+
{
|
155 |
+
$product_id = $collectm->getId();
|
156 |
+
$action_type = 'disable_products';
|
157 |
+
$fields = array(
|
158 |
+
'secret_token'=>$this->secret_token,
|
159 |
+
'product_ids'=> $product_id,
|
160 |
+
'shop_id'=>implode(',', $shop_ids),
|
161 |
+
'user_id'=> $froomerce_user_id,
|
162 |
+
'action_type' => $action_type
|
163 |
+
);
|
164 |
+
|
165 |
+
// Deleting products from exported products table
|
166 |
+
$resource = Mage::getSingleton( 'core/resource' );
|
167 |
+
$write = $resource->getConnection('core_write');
|
168 |
+
$table = $resource->getTableName('froomerce_products');
|
169 |
+
$write->query("DELETE FROM ".$table ." WHERE product_id= ".$product_id);
|
170 |
+
//End
|
171 |
+
|
172 |
+
//url-ify the data for the POST
|
173 |
+
$fields_string = '';
|
174 |
+
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
|
175 |
+
$fields_string = rtrim($fields_string,'&');
|
176 |
+
|
177 |
+
if($useremail == 'dummy.export@servis.pk')
|
178 |
+
$url_post = $this->url_dummy;
|
179 |
+
else
|
180 |
+
$url_post = $this->url;
|
181 |
+
|
182 |
+
// CURL Request section
|
183 |
+
$ch = curl_init();
|
184 |
+
curl_setopt($ch,CURLOPT_URL,$url_post);
|
185 |
+
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
|
186 |
+
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
|
187 |
+
$result = curl_exec($ch);
|
188 |
+
curl_close($ch);
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
}
|
193 |
+
|
194 |
+
|
195 |
+
public function getUser()
|
196 |
+
{
|
197 |
+
$user_data = Mage::getModel('froomerce/froomerce')->getCollection();
|
198 |
+
$user_info = array();
|
199 |
+
foreach($user_data as $user)
|
200 |
+
{
|
201 |
+
$user_info['email'] = $user['email'];
|
202 |
+
$user_info['password'] = $user['password'];
|
203 |
+
$user_info['froomerce_user_id'] = $user['froomerce_user_id'];
|
204 |
+
}
|
205 |
+
if(count($user_info))
|
206 |
+
return $user_info;
|
207 |
+
else
|
208 |
+
return false;
|
209 |
+
}
|
210 |
+
|
211 |
+
}
|
app/code/local/Addon/Froomerce/Model/Products.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Addon_Froomerce_Model_Products extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('froomerce/products');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Addon/Froomerce/Model/Resource/Eav/Mysql4/Product/Collection.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Addon_Froomerce_Model_Resource_Eav_Mysql4_Product_Collection
|
4 |
+
extends Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
|
5 |
+
{
|
6 |
+
|
7 |
+
public function getSelectCountSql()
|
8 |
+
{
|
9 |
+
$this->_renderFilters();
|
10 |
+
|
11 |
+
$countSelect = clone $this->getSelect();
|
12 |
+
$countSelect->reset(Zend_Db_Select::ORDER);
|
13 |
+
$countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
|
14 |
+
$countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
|
15 |
+
$countSelect->reset(Zend_Db_Select::COLUMNS);
|
16 |
+
//Added this code - START -------------------->
|
17 |
+
if (Mage::getSingleton('adminhtml/url')->getRequest()->getModuleName() == 'froomerce') {
|
18 |
+
$countSelect->reset(Zend_Db_Select::GROUP);
|
19 |
+
}
|
20 |
+
//Added this code - END -----------------------<
|
21 |
+
|
22 |
+
$countSelect->columns('COUNT(DISTINCT e.entity_id)');
|
23 |
+
$countSelect->resetJoinLeft();
|
24 |
+
|
25 |
+
return $countSelect;
|
26 |
+
}
|
27 |
+
}
|
app/code/local/Addon/Froomerce/Model/Status.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Addon_Froomerce_Model_Status extends Varien_Object
|
4 |
+
{
|
5 |
+
const STATUS_ENABLED = 1;
|
6 |
+
const STATUS_DISABLED = 2;
|
7 |
+
|
8 |
+
static public function getOptionArray()
|
9 |
+
{
|
10 |
+
return array(
|
11 |
+
self::STATUS_ENABLED => Mage::helper('froomerce')->__('Enabled'),
|
12 |
+
self::STATUS_DISABLED => Mage::helper('froomerce')->__('Disabled')
|
13 |
+
);
|
14 |
+
}
|
15 |
+
}
|
app/code/local/Addon/Froomerce/controllers/Adminhtml/FroomerceController.php
ADDED
@@ -0,0 +1,747 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_Adminhtml_FroomerceController extends Mage_Adminhtml_Controller_action {
|
3 |
+
|
4 |
+
private $secret_token = '5e5225e8d60e8ec72a7fd96135a0e865';
|
5 |
+
private $auth_url_dummy = 'https://www.servis.pk/';
|
6 |
+
private $auth_url = 'https://www.froomerce.com/';
|
7 |
+
private $url_dummy = 'http://www.servis.pk/';
|
8 |
+
private $url = 'http://www.froomerce.com/';
|
9 |
+
|
10 |
+
protected function _initAction() {
|
11 |
+
|
12 |
+
$this->loadLayout()
|
13 |
+
->_setActiveMenu('froomerce/items');
|
14 |
+
return $this;
|
15 |
+
}
|
16 |
+
|
17 |
+
public function indexAction() {
|
18 |
+
$this->checkuser();
|
19 |
+
$this->_forward('edit');
|
20 |
+
}
|
21 |
+
|
22 |
+
// Froomerce authentication form
|
23 |
+
public function editAction() {
|
24 |
+
$this->checkuser();
|
25 |
+
|
26 |
+
$user_data = Mage::getModel('froomerce/froomerce')->getCollection();
|
27 |
+
$id = 0;
|
28 |
+
foreach($user_data as $user)
|
29 |
+
{
|
30 |
+
$id = $user->getId();
|
31 |
+
}
|
32 |
+
|
33 |
+
$model = Mage::getModel('froomerce/froomerce')->load($id);
|
34 |
+
|
35 |
+
if ($model->getId() || $id == 0) {
|
36 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
37 |
+
if (!empty($data)) {
|
38 |
+
$model->setData($data);
|
39 |
+
}
|
40 |
+
|
41 |
+
Mage::register('froomerce_data', $model);
|
42 |
+
|
43 |
+
$this->_initAction();
|
44 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
45 |
+
|
46 |
+
$this->_addContent($this->getLayout()->createBlock('froomerce/adminhtml_froomerce_edit'))
|
47 |
+
->_addLeft($this->getLayout()->createBlock('froomerce/adminhtml_froomerce_edit_tabs'));
|
48 |
+
|
49 |
+
$this->renderLayout();
|
50 |
+
} else {
|
51 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('froomerce')->__('User does not exist'));
|
52 |
+
$this->_redirect('*/*/');
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
// Froomerce authentication form
|
57 |
+
public function regionAction() {
|
58 |
+
|
59 |
+
if ($this->getRequest()->getPost() || $this->getRequest()->getParam('group_id')) {
|
60 |
+
$data1 = $this->getRequest()->getParam('group_id');
|
61 |
+
if(empty($data1))
|
62 |
+
{
|
63 |
+
$data1 = $this->getRequest()->getPost();
|
64 |
+
if(!array_key_exists('group_id', $data1))
|
65 |
+
{
|
66 |
+
$this->_redirect('*/adminhtml_froomerce/website/from/regin');
|
67 |
+
return;
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
72 |
+
|
73 |
+
$this->_initAction();
|
74 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
75 |
+
|
76 |
+
$this->_addContent($this->getLayout()->createBlock('froomerce/adminhtml_froomerce_region'))
|
77 |
+
->_addLeft($this->getLayout()->createBlock('froomerce/adminhtml_froomerce_region_tabs'));
|
78 |
+
|
79 |
+
$this->renderLayout();
|
80 |
+
}
|
81 |
+
else
|
82 |
+
{
|
83 |
+
$this->_redirect('*/adminhtml_froomerce/website/from/regin');
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
public function newAction() {
|
88 |
+
|
89 |
+
$this->checkuser();
|
90 |
+
$this->_redirect('*/adminhtml_froomerce/check/export/1');
|
91 |
+
}
|
92 |
+
|
93 |
+
// Remotely user authentication and saving
|
94 |
+
public function saveAction() {
|
95 |
+
if ($data = $this->getRequest()->getPost()) {
|
96 |
+
$user_email = $data['email'];
|
97 |
+
$user_pass = $data['password'];
|
98 |
+
$secret_token = '5e5225e8d60e8ec72a7fd96135a0e865';
|
99 |
+
|
100 |
+
if($user_email == 'dummy.export@servis.pk')
|
101 |
+
$authUrl = $this->auth_url_dummy;
|
102 |
+
else
|
103 |
+
$authUrl = $this->auth_url;
|
104 |
+
|
105 |
+
$qeury_str = $authUrl."api/user/index?email=".$data['email']."&password=".$data['password']."&secret_token=".$this->secret_token."&action_type=verify_login";
|
106 |
+
|
107 |
+
$response = file_get_contents($qeury_str);
|
108 |
+
|
109 |
+
$decoded_data = json_decode($response);
|
110 |
+
$decoded_data = (array) $decoded_data;
|
111 |
+
|
112 |
+
if($decoded_data['status']== 'success')
|
113 |
+
{
|
114 |
+
$froomerce_user_id = $decoded_data['data']->user_id ;
|
115 |
+
|
116 |
+
$data = array(
|
117 |
+
'email'=>$user_email,
|
118 |
+
'password'=>$user_pass,
|
119 |
+
'froomerce_user_id'=>$froomerce_user_id,
|
120 |
+
);
|
121 |
+
|
122 |
+
$model = Mage::getModel('froomerce/froomerce');
|
123 |
+
$model->setData($data);
|
124 |
+
$model->save();
|
125 |
+
|
126 |
+
$config_model = Mage::getModel('froomerce/config');
|
127 |
+
$websites = Mage::app()->getWebsites(true);
|
128 |
+
foreach ($websites as $website){
|
129 |
+
|
130 |
+
foreach ($website->getGroups() as $group) {
|
131 |
+
|
132 |
+
if($group->getId() == 0)
|
133 |
+
continue;
|
134 |
+
|
135 |
+
foreach($group->getStores() as $store)
|
136 |
+
{
|
137 |
+
$config_data = array(
|
138 |
+
'store_id' => $store->getId(),
|
139 |
+
'group_id'=>$group->getId(),
|
140 |
+
'froomerce_user_id'=>$froomerce_user_id,
|
141 |
+
'status'=>'Inprogress',
|
142 |
+
);
|
143 |
+
$config_model->setData($config_data);
|
144 |
+
$config_model->save();
|
145 |
+
}
|
146 |
+
}
|
147 |
+
}
|
148 |
+
$this->_redirect('*/adminhtml_froomerce/region');
|
149 |
+
return;
|
150 |
+
}
|
151 |
+
else
|
152 |
+
{
|
153 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('froomerce')->__('Unable to save as remote authentication failed'));
|
154 |
+
}
|
155 |
+
}
|
156 |
+
$this->_redirect('*/*/');
|
157 |
+
}
|
158 |
+
|
159 |
+
public function createshopAction() {
|
160 |
+
|
161 |
+
if ($data = $this->getRequest()->getPost()) {
|
162 |
+
$group_name = $data['group_name'];
|
163 |
+
$group_id = $data['group_id'];
|
164 |
+
|
165 |
+
if(array_key_exists('store_code', $data) and array_key_exists('region_id', $data))
|
166 |
+
{
|
167 |
+
$storecode = $data['store_code'];
|
168 |
+
$region_id = $data['region_id'];
|
169 |
+
}
|
170 |
+
else
|
171 |
+
{
|
172 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('froomerce')->__('Please select both ( Store and Region )'));
|
173 |
+
$this->_redirect('*/*/region/group_id/'.$group_id, array('id' => $this->getRequest()->getParam('id')));
|
174 |
+
return;
|
175 |
+
}
|
176 |
+
|
177 |
+
$user_data = Mage::getModel('froomerce/froomerce')->getCollection();
|
178 |
+
foreach($user_data as $user)
|
179 |
+
{
|
180 |
+
$froomerce_user_id = $user->getFroomerceUserId();
|
181 |
+
$tbl_id = $user->getId();
|
182 |
+
|
183 |
+
if($user->getEmail() == 'dummy.export@servis.pk')
|
184 |
+
$url = $this->url_dummy.'api/shop/index';
|
185 |
+
else
|
186 |
+
$url = $this->url.'api/shop/index';
|
187 |
+
|
188 |
+
$fields = array(
|
189 |
+
'secret_token'=>$this->secret_token,
|
190 |
+
'user_id'=>$froomerce_user_id,
|
191 |
+
'region_id'=>$region_id,
|
192 |
+
'shop_name'=>$group_name,
|
193 |
+
'action_type'=>'create_shop'
|
194 |
+
);
|
195 |
+
|
196 |
+
//url-ify the data for the POST
|
197 |
+
$fields_string = '';
|
198 |
+
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
|
199 |
+
$fields_string = rtrim($fields_string,'&');
|
200 |
+
|
201 |
+
// CURL Request section
|
202 |
+
$ch = curl_init();
|
203 |
+
curl_setopt($ch,CURLOPT_URL,$url);
|
204 |
+
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
|
205 |
+
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
|
206 |
+
$result = curl_exec($ch);
|
207 |
+
curl_close($ch);
|
208 |
+
// End
|
209 |
+
$deocded_res = json_decode($result);
|
210 |
+
$deocded_res = (array) $deocded_res;
|
211 |
+
|
212 |
+
if($deocded_res['status']== 'success')
|
213 |
+
{
|
214 |
+
$froomerce_shop_id = $deocded_res['data']->shop_id;
|
215 |
+
|
216 |
+
$froomerce_config = Mage::getModel('froomerce/config')->getCollection();
|
217 |
+
$website_code = $this->getWebsiteCode($group_id);
|
218 |
+
$stores = Mage::app()->getWebsite($website_code)->getStores();
|
219 |
+
foreach($stores as $lang)
|
220 |
+
{
|
221 |
+
if($storecode == $lang->getCode())
|
222 |
+
{
|
223 |
+
$storeid = $lang->getId();
|
224 |
+
break;
|
225 |
+
}
|
226 |
+
}
|
227 |
+
$model = Mage::getModel('froomerce/config');
|
228 |
+
$data1 = array(
|
229 |
+
'store_id'=>$storeid,
|
230 |
+
'region_id' => $region_id,
|
231 |
+
'froomerce_shop_id' => $froomerce_shop_id,
|
232 |
+
'status' => 'Inprogress',
|
233 |
+
);
|
234 |
+
|
235 |
+
foreach($froomerce_config as $cnfg)
|
236 |
+
{
|
237 |
+
if($storeid == $cnfg->getStoreId() and $group_id == $cnfg->getGroupId())
|
238 |
+
{
|
239 |
+
$cnfgId = $cnfg->getId();
|
240 |
+
break;
|
241 |
+
}
|
242 |
+
}
|
243 |
+
$model->setData($data1)
|
244 |
+
->setId($cnfgId);
|
245 |
+
try {
|
246 |
+
$model->save();
|
247 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('froomerce')->__('New shop created successfully'));
|
248 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
249 |
+
|
250 |
+
$this->_redirect('*/adminhtml_froomerce/check/store_code/'.$storecode);
|
251 |
+
return;
|
252 |
+
} catch (Exception $e) {
|
253 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
254 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
255 |
+
$this->_redirect('*/*/region', array('id' => $this->getRequest()->getParam('id')));
|
256 |
+
return;
|
257 |
+
}
|
258 |
+
}
|
259 |
+
else
|
260 |
+
{
|
261 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('froomerce')->__('Unable to Create Shop'));
|
262 |
+
}
|
263 |
+
}
|
264 |
+
}
|
265 |
+
}
|
266 |
+
|
267 |
+
// Products listing
|
268 |
+
public function checkAction() {
|
269 |
+
|
270 |
+
if($this->getRequest()->getParam('store_code') != '')
|
271 |
+
{
|
272 |
+
$froomerce_shop_id = 0;
|
273 |
+
$storecode = $this->getRequest()->getParam('store_code');
|
274 |
+
$storeId = $this->getStoreId($storecode);
|
275 |
+
$storename = $this->getStoreName($storecode);
|
276 |
+
|
277 |
+
$froomerce_config = Mage::getModel('froomerce/config')->getCollection();
|
278 |
+
|
279 |
+
foreach($froomerce_config as $cnfig)
|
280 |
+
{
|
281 |
+
if($storeId == $cnfig['store_id'])
|
282 |
+
{
|
283 |
+
$froomerce_shop_id = $cnfig['froomerce_shop_id'];
|
284 |
+
break;
|
285 |
+
}
|
286 |
+
}
|
287 |
+
|
288 |
+
$user_data = Mage::getModel('froomerce/froomerce')->getCollection();
|
289 |
+
foreach($user_data as $user)
|
290 |
+
{
|
291 |
+
$froomerce_user_id = $user['froomerce_user_id'];
|
292 |
+
$user_email = $user['email'];
|
293 |
+
break;
|
294 |
+
}
|
295 |
+
if($froomerce_shop_id)
|
296 |
+
{
|
297 |
+
$baseURL = Mage::getBaseUrl();
|
298 |
+
if(Mage::getStoreConfig('web/url/use_store'))
|
299 |
+
$baseURL = Mage::app()->getStore($storecode)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
|
300 |
+
|
301 |
+
$fields = array(
|
302 |
+
'secret_token'=>$this->secret_token,
|
303 |
+
'feed_url'=> $baseURL.'froomerce/rss/export/store_code/'.$storecode,
|
304 |
+
'temp_url' => $baseURL.'froomerce/rss/firstexport/store_code/'.$storecode,
|
305 |
+
'request_url'=>$baseURL.'froomerce/rss/callback',
|
306 |
+
'shop_id'=>$froomerce_shop_id,
|
307 |
+
'user_id'=> $froomerce_user_id,
|
308 |
+
'action_type' => 'import_feed'
|
309 |
+
);
|
310 |
+
|
311 |
+
//url-ify the data for the POST
|
312 |
+
$fields_string = '';
|
313 |
+
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
|
314 |
+
$fields_string = rtrim($fields_string,'&');
|
315 |
+
|
316 |
+
// CURL Request section
|
317 |
+
if($user_email == 'dummy.export@servis.pk')
|
318 |
+
$url = $this->url_dummy.'api/productfeed/index';
|
319 |
+
else
|
320 |
+
$url = $this->url.'api/productfeed/index';
|
321 |
+
|
322 |
+
$ch = curl_init();
|
323 |
+
curl_setopt($ch,CURLOPT_URL,$url);
|
324 |
+
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
|
325 |
+
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
|
326 |
+
$result = curl_exec($ch);
|
327 |
+
curl_close($ch);
|
328 |
+
|
329 |
+
$result = (array) json_decode($result);
|
330 |
+
|
331 |
+
$cnfgId = 0;
|
332 |
+
$froomerce_config = Mage::getModel('froomerce/config')->getCollection()
|
333 |
+
->addFieldToFilter('froomerce_shop_id', $froomerce_shop_id);
|
334 |
+
foreach($froomerce_config as $cnfig)
|
335 |
+
{
|
336 |
+
if($froomerce_shop_id == $cnfig['froomerce_shop_id'])
|
337 |
+
{
|
338 |
+
$statussss = $cnfig['status'];
|
339 |
+
$cnfgId = $cnfig['id'];
|
340 |
+
break;
|
341 |
+
}
|
342 |
+
}
|
343 |
+
if($cnfgId)
|
344 |
+
{
|
345 |
+
if(empty($statussss) or $statussss == 'Exported')
|
346 |
+
{
|
347 |
+
if( $result['status'] == 'success' )
|
348 |
+
{
|
349 |
+
$fields = array(
|
350 |
+
'secret_token'=>$this->secret_token,
|
351 |
+
'shop_id'=>$froomerce_shop_id,
|
352 |
+
'user_id'=> $froomerce_user_id,
|
353 |
+
'action_type' => 'update_feed_status'
|
354 |
+
);
|
355 |
+
|
356 |
+
//url-ify the data for the POST
|
357 |
+
$fields_string = '';
|
358 |
+
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
|
359 |
+
$fields_string = rtrim($fields_string,'&');
|
360 |
+
|
361 |
+
$ch = curl_init();
|
362 |
+
curl_setopt($ch,CURLOPT_URL,$url);
|
363 |
+
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
|
364 |
+
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
|
365 |
+
$rests = curl_exec($ch);
|
366 |
+
curl_close($ch);
|
367 |
+
}
|
368 |
+
else
|
369 |
+
{
|
370 |
+
$model = Mage::getModel('froomerce/config');
|
371 |
+
$data1 = array(
|
372 |
+
'region_id' => 0,
|
373 |
+
'froomerce_shop_id' => 0,
|
374 |
+
'status' => 'Inprogress',
|
375 |
+
);
|
376 |
+
|
377 |
+
$model->setData($data1)
|
378 |
+
->setId($cnfgId);
|
379 |
+
try {
|
380 |
+
$model->save();
|
381 |
+
} catch (Exception $e) {
|
382 |
+
}
|
383 |
+
}
|
384 |
+
}
|
385 |
+
}
|
386 |
+
// End of log
|
387 |
+
|
388 |
+
$this->loadLayout();
|
389 |
+
|
390 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('froomerce')->__('New shop created successfully'));
|
391 |
+
if( $result['status'] == 'success' )
|
392 |
+
{
|
393 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('froomerce')->__('Products Exported Successfully from \''.$storename.'\' Store View'));
|
394 |
+
}
|
395 |
+
else
|
396 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('froomerce')->__('Could Not Export Products'));
|
397 |
+
|
398 |
+
$this->_redirect('*/adminhtml_froomerce/region');
|
399 |
+
return;
|
400 |
+
}
|
401 |
+
}
|
402 |
+
else
|
403 |
+
{
|
404 |
+
$froomerce_config = Mage::getModel('froomerce/config')->getCollection();
|
405 |
+
$ready = false;
|
406 |
+
$storeids = array();
|
407 |
+
foreach($froomerce_config as $cnfig)
|
408 |
+
{
|
409 |
+
$froomerce_shop_id = $cnfig['froomerce_shop_id'];
|
410 |
+
$store_id_exp = $cnfig['store_id'];
|
411 |
+
|
412 |
+
if($store_id_exp)
|
413 |
+
$storeids[] = $store_id_exp;
|
414 |
+
|
415 |
+
if($froomerce_shop_id)
|
416 |
+
$ready = true;
|
417 |
+
}
|
418 |
+
|
419 |
+
$this->_initAction()
|
420 |
+
->renderLayout();
|
421 |
+
if(!$ready)
|
422 |
+
{
|
423 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('froomerce')->__('Please Export Store to Froomerce first'));
|
424 |
+
$this->_redirect('*/adminhtml_froomerce/region');
|
425 |
+
}
|
426 |
+
}
|
427 |
+
|
428 |
+
//if (!Mage::app()->isSingleStoreMode())
|
429 |
+
//{
|
430 |
+
if($this->getRequest()->getParam('store') == '' or !$this->getRequest()->getParam('store'))
|
431 |
+
{
|
432 |
+
if(count($storeids))
|
433 |
+
asort($storeids);
|
434 |
+
|
435 |
+
$url = $this->getUrl('*/adminhtml_froomerce/check');
|
436 |
+
$url1 = explode('/froomerce', $url);
|
437 |
+
$this->_redirect($url1[1].'store/'.$storeids[0].'/');
|
438 |
+
}
|
439 |
+
//}
|
440 |
+
}
|
441 |
+
|
442 |
+
public function facebookAction() {
|
443 |
+
|
444 |
+
if ($this->getRequest()->getPost() || $this->getRequest()->getParam('group_id')) {
|
445 |
+
|
446 |
+
$data1 = $this->getRequest()->getParam('group_id');
|
447 |
+
if(empty($data1))
|
448 |
+
{
|
449 |
+
$data1 = $this->getRequest()->getPost();
|
450 |
+
if(!array_key_exists('group_id', $data1))
|
451 |
+
{
|
452 |
+
$this->_redirect('*/adminhtml_froomerce/website/from/facebok');
|
453 |
+
return;
|
454 |
+
}
|
455 |
+
}
|
456 |
+
|
457 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
458 |
+
|
459 |
+
$user_data = Mage::getModel('froomerce/froomerce')->getCollection();
|
460 |
+
|
461 |
+
$this->_initAction();
|
462 |
+
|
463 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
464 |
+
|
465 |
+
$this->_addContent($this->getLayout()->createBlock('froomerce/adminhtml_froomerce_facebook'))
|
466 |
+
->_addLeft($this->getLayout()->createBlock('froomerce/adminhtml_froomerce_facebook_tabs'));
|
467 |
+
|
468 |
+
$this->renderLayout();
|
469 |
+
if(!count($user_data))
|
470 |
+
{
|
471 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('froomerce')->__('Please Authenticate First'));
|
472 |
+
$this->_redirect('*/adminhtml_froomerce/edit');
|
473 |
+
}
|
474 |
+
}
|
475 |
+
else
|
476 |
+
{
|
477 |
+
$this->_redirect('*/adminhtml_froomerce/website/from/facebok');
|
478 |
+
}
|
479 |
+
}
|
480 |
+
|
481 |
+
public function websiteAction() {
|
482 |
+
|
483 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
484 |
+
|
485 |
+
$user_data = Mage::getModel('froomerce/froomerce')->getCollection();
|
486 |
+
if(!count($user_data))
|
487 |
+
{
|
488 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('froomerce')->__('Please Authenticate First'));
|
489 |
+
$this->_redirect('*/adminhtml_froomerce/edit');
|
490 |
+
return;
|
491 |
+
}
|
492 |
+
$this->_initAction();
|
493 |
+
|
494 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
495 |
+
|
496 |
+
$this->_addContent($this->getLayout()->createBlock('froomerce/adminhtml_froomerce_websites'))
|
497 |
+
->_addLeft($this->getLayout()->createBlock('froomerce/adminhtml_froomerce_websites_tabs'));
|
498 |
+
|
499 |
+
$this->renderLayout();
|
500 |
+
}
|
501 |
+
|
502 |
+
public function groupAction() {
|
503 |
+
if ($this->getRequest()->getPost()) {
|
504 |
+
|
505 |
+
$data1 = $this->getRequest()->getPost();
|
506 |
+
if(!array_key_exists('website_id', $data1))
|
507 |
+
{
|
508 |
+
$this->_redirect('*/*/');
|
509 |
+
return;
|
510 |
+
}
|
511 |
+
|
512 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
513 |
+
|
514 |
+
$user_data = Mage::getModel('froomerce/froomerce')->getCollection();
|
515 |
+
|
516 |
+
$this->_initAction();
|
517 |
+
|
518 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
519 |
+
|
520 |
+
$this->_addContent($this->getLayout()->createBlock('froomerce/adminhtml_froomerce_groups'))
|
521 |
+
->_addLeft($this->getLayout()->createBlock('froomerce/adminhtml_froomerce_groups_tabs'));
|
522 |
+
|
523 |
+
$this->renderLayout();
|
524 |
+
if(!count($user_data))
|
525 |
+
{
|
526 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('froomerce')->__('Please Authenticate First'));
|
527 |
+
$this->_redirect('*/adminhtml_froomerce/edit');
|
528 |
+
}
|
529 |
+
}
|
530 |
+
else
|
531 |
+
{
|
532 |
+
$this->_redirect('*/adminhtml_froomerce/website');
|
533 |
+
}
|
534 |
+
}
|
535 |
+
|
536 |
+
// Post widgets to facebook
|
537 |
+
public function postwidgetAction() {
|
538 |
+
|
539 |
+
$store_id = 0;
|
540 |
+
$froomerce_config = Mage::getModel('froomerce/config')->getCollection();
|
541 |
+
$froomerce_shop_id = 0;
|
542 |
+
|
543 |
+
if($store = $this->getRequest()->getParam('store'))
|
544 |
+
{
|
545 |
+
$store_id = $store;
|
546 |
+
|
547 |
+
foreach($froomerce_config as $cnfig)
|
548 |
+
{
|
549 |
+
if($store_id == $cnfig['store_id'])
|
550 |
+
{
|
551 |
+
$froomerce_shop_id = $cnfig['froomerce_shop_id'];
|
552 |
+
break;
|
553 |
+
}
|
554 |
+
}
|
555 |
+
}
|
556 |
+
|
557 |
+
$user_data = Mage::getModel('froomerce/froomerce')->getCollection();
|
558 |
+
$user_info = array();
|
559 |
+
foreach($user_data as $user)
|
560 |
+
{
|
561 |
+
$user_info['email'] = $user['email'];
|
562 |
+
$user_info['password'] = $user['password'];
|
563 |
+
$user_info['shop_id'] = $froomerce_shop_id;
|
564 |
+
$user_info['user_id'] = $user['froomerce_user_id'];
|
565 |
+
$user_info['secret_token'] = $this->secret_token;
|
566 |
+
$user_info['action_type'] = 'export_widget';
|
567 |
+
}
|
568 |
+
//Check if user is authenticated or not
|
569 |
+
if(!isset($user_info['user_id'])) // Means not authenticated then redirect to authentication form
|
570 |
+
{
|
571 |
+
$this->_redirect('*/adminhtml_froomerce/index');
|
572 |
+
return;
|
573 |
+
}
|
574 |
+
|
575 |
+
if($data = $this->getRequest()->getPost())
|
576 |
+
{
|
577 |
+
$admin_url = $this->getUrl('*/*/check', array('store' => $store_id));
|
578 |
+
|
579 |
+
foreach($data['product'] as $id=>$value)
|
580 |
+
$p_ids[] = $value;
|
581 |
+
|
582 |
+
// CURL Request here
|
583 |
+
$credentials = md5($user_info['email'].$user_info['password']);
|
584 |
+
if($user_info['email'] == 'dummy.export@servis.pk')
|
585 |
+
{
|
586 |
+
$url = $this->url_dummy.'api/faceshop/index';
|
587 |
+
$post_w_url = $this->url_dummy.'api/faceshop/export';
|
588 |
+
}
|
589 |
+
else
|
590 |
+
{
|
591 |
+
$url = $this->url.'api/faceshop/index';
|
592 |
+
$post_w_url = $this->url.'api/faceshop/export';
|
593 |
+
}
|
594 |
+
|
595 |
+
|
596 |
+
|
597 |
+
$fields = array(
|
598 |
+
'secret_token'=>$this->secret_token,
|
599 |
+
'email'=>$user_info['email'],
|
600 |
+
'password'=>$user_info['password'],
|
601 |
+
'product_ids'=> implode(',', $p_ids),
|
602 |
+
'shop_id'=>$user_info['shop_id'],
|
603 |
+
'user_id'=> $user_info['user_id'],
|
604 |
+
'action_type' => 'export_widget'
|
605 |
+
);
|
606 |
+
|
607 |
+
//url-ify the data for the POST
|
608 |
+
$fields_string = '';
|
609 |
+
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
|
610 |
+
$fields_string = rtrim($fields_string,'&');
|
611 |
+
|
612 |
+
// CURL Request section
|
613 |
+
$ch = curl_init();
|
614 |
+
curl_setopt($ch,CURLOPT_URL,$url);
|
615 |
+
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
|
616 |
+
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
|
617 |
+
$result = curl_exec($ch);
|
618 |
+
curl_close($ch);
|
619 |
+
|
620 |
+
$decoded_data = json_decode($result);
|
621 |
+
$decoded_data = (array) $decoded_data;
|
622 |
+
if($decoded_data['status'] == 'error')
|
623 |
+
{
|
624 |
+
$message = $decoded_data['error']->message;
|
625 |
+
Mage::getSingleton('adminhtml/session')->addError($message);
|
626 |
+
$this->_redirect('*/adminhtml_froomerce/check/store/'.$store_id);
|
627 |
+
return;
|
628 |
+
} else {
|
629 |
+
|
630 |
+
if($decoded_data['data']->notice == 1)
|
631 |
+
{
|
632 |
+
$message = "The widget has been created \n
|
633 |
+
Although the products which have not beed updated to froomerce were not included";
|
634 |
+
}
|
635 |
+
else
|
636 |
+
$message = "Widget(s) has been created";
|
637 |
+
|
638 |
+
$widget_id = $decoded_data['data']->widget_id;
|
639 |
+
|
640 |
+
}
|
641 |
+
$this->_initAction();
|
642 |
+
$this->getLayout()->getBlock('froomerce_postwidget')->setCredentials($credentials);
|
643 |
+
$this->getLayout()->getBlock('froomerce_postwidget')->setMessage($message);
|
644 |
+
$this->getLayout()->getBlock('froomerce_postwidget')->setWidgetId($widget_id);
|
645 |
+
$this->getLayout()->getBlock('froomerce_postwidget')->setAdminUrl($admin_url);
|
646 |
+
$this->getLayout()->getBlock('froomerce_postwidget')->setSecrettoken($this->secret_token);
|
647 |
+
$this->getLayout()->getBlock('froomerce_postwidget')->setPostUrl($post_w_url);
|
648 |
+
$this->renderLayout();
|
649 |
+
}
|
650 |
+
|
651 |
+
}
|
652 |
+
|
653 |
+
// Check if user authenticated from froomerce or not
|
654 |
+
public function checkuser() {
|
655 |
+
|
656 |
+
$user_data = Mage::getModel('froomerce/froomerce')->getCollection();
|
657 |
+
foreach($user_data as $user)
|
658 |
+
{
|
659 |
+
$id = $user->getId();
|
660 |
+
if(!empty($id))
|
661 |
+
$this->_redirect('*/adminhtml_froomerce/website/from/regin');
|
662 |
+
break;
|
663 |
+
}
|
664 |
+
}
|
665 |
+
public function getUser() {
|
666 |
+
|
667 |
+
$user_data = Mage::getModel('froomerce/froomerce')->getCollection();
|
668 |
+
$userinfo = array();
|
669 |
+
foreach($user_data as $user)
|
670 |
+
{
|
671 |
+
$userinfo['id'] = $user->getId();
|
672 |
+
$userinfo['email'] = $user->getEmail();
|
673 |
+
$userinfo['froomerce_user_id'] = $user->getFroomerceUserId();
|
674 |
+
}
|
675 |
+
return $userinfo;
|
676 |
+
}
|
677 |
+
|
678 |
+
public function getStoreId($storecode = 0) {
|
679 |
+
if($storecode)
|
680 |
+
{
|
681 |
+
$website_name='';
|
682 |
+
$websites = Mage::app()->getWebsites(true);
|
683 |
+
foreach ($websites as $website){
|
684 |
+
if(!$website->getId())
|
685 |
+
continue;
|
686 |
+
|
687 |
+
foreach ($website->getGroups() as $group) {
|
688 |
+
foreach($group->getStores() as $lang)
|
689 |
+
{
|
690 |
+
if($storecode == $lang->getCode())
|
691 |
+
{
|
692 |
+
$storeid = $lang->getId();
|
693 |
+
return $storeid;
|
694 |
+
}
|
695 |
+
}
|
696 |
+
}
|
697 |
+
}
|
698 |
+
return false;
|
699 |
+
}
|
700 |
+
}
|
701 |
+
public function getWebsiteCode($group_id = 0)
|
702 |
+
{
|
703 |
+
if($group_id)
|
704 |
+
{
|
705 |
+
$website_code='';
|
706 |
+
$websites = Mage::app()->getWebsites(true);
|
707 |
+
foreach ($websites as $website){
|
708 |
+
if(!$website->getId())
|
709 |
+
continue;
|
710 |
+
|
711 |
+
foreach ($website->getGroups() as $group) {
|
712 |
+
if($group->getId() == $group_id)
|
713 |
+
{
|
714 |
+
return $website_code = $website->getCode();
|
715 |
+
break;
|
716 |
+
}
|
717 |
+
}
|
718 |
+
}
|
719 |
+
}
|
720 |
+
return 0;
|
721 |
+
}
|
722 |
+
|
723 |
+
public function getStoreName($storecode = 0) {
|
724 |
+
if($storecode)
|
725 |
+
{
|
726 |
+
$website_name='';
|
727 |
+
$websites = Mage::app()->getWebsites(true);
|
728 |
+
foreach ($websites as $website){
|
729 |
+
if(!$website->getId())
|
730 |
+
continue;
|
731 |
+
|
732 |
+
foreach ($website->getGroups() as $group) {
|
733 |
+
foreach($group->getStores() as $lang)
|
734 |
+
{
|
735 |
+
if($storecode == $lang->getCode())
|
736 |
+
{
|
737 |
+
$storename = $lang->getName();
|
738 |
+
return $storename;
|
739 |
+
}
|
740 |
+
}
|
741 |
+
}
|
742 |
+
}
|
743 |
+
return false;
|
744 |
+
}
|
745 |
+
}
|
746 |
+
|
747 |
+
}
|
app/code/local/Addon/Froomerce/controllers/IndexController.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addon_Froomerce_IndexController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
public function indexAction()
|
5 |
+
{
|
6 |
+
/*
|
7 |
+
* Load an object by id
|
8 |
+
* Request looking like:
|
9 |
+
* http://site.com/brands?id=15
|
10 |
+
* or
|
11 |
+
* http://site.com/brands/id/15
|
12 |
+
*/
|
13 |
+
|
14 |
+
$user_id = $this->getRequest()->getParam('id');
|
15 |
+
|
16 |
+
if($user_id != null && $brands_id != '') {
|
17 |
+
$user = Mage::getModel('froomerce/froomerce')->load($user_id)->getData();
|
18 |
+
} else {
|
19 |
+
$user = null;
|
20 |
+
}
|
21 |
+
Mage::register('froomerce', $user);
|
22 |
+
|
23 |
+
/*
|
24 |
+
* If no param we load a the last created item
|
25 |
+
*/
|
26 |
+
/*
|
27 |
+
if($brands == null) {
|
28 |
+
$resource = Mage::getSingleton('core/resource');
|
29 |
+
$read= $resource->getConnection('core_read');
|
30 |
+
$brandsTable = $resource->getTableName('brands');
|
31 |
+
|
32 |
+
$select = $read->select()
|
33 |
+
->from($brandsTable,array('brands_id','title','content','status'))
|
34 |
+
->where('status',1)
|
35 |
+
->order('created_time DESC') ;
|
36 |
+
|
37 |
+
$brands = $read->fetchRow($select);
|
38 |
+
}
|
39 |
+
Mage::register('brands', $brands);
|
40 |
+
*/
|
41 |
+
|
42 |
+
|
43 |
+
$this->loadLayout();
|
44 |
+
$this->getLayout()->getBlock('head')->setTitle($user['title']);
|
45 |
+
$this->renderLayout();
|
46 |
+
}
|
47 |
+
}
|
app/code/local/Addon/Froomerce/controllers/RssController.php
ADDED
@@ -0,0 +1,1503 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*/
|
4 |
+
class Addon_Froomerce_RssController extends Mage_Core_Controller_Front_Action
|
5 |
+
{
|
6 |
+
public function exportAction() {
|
7 |
+
|
8 |
+
set_time_limit(0);
|
9 |
+
header('Content-Type: text/xml');
|
10 |
+
|
11 |
+
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
|
12 |
+
echo '<data>';
|
13 |
+
|
14 |
+
if($data = $this->getRequest()->getPost())
|
15 |
+
{
|
16 |
+
foreach($data['product'] as $id)
|
17 |
+
{
|
18 |
+
print '<products>' . $this->productXml($id) . '</products>';
|
19 |
+
//print '<categories>' . $this->categoriesxml() . '</categories>';
|
20 |
+
}
|
21 |
+
}
|
22 |
+
else
|
23 |
+
{
|
24 |
+
print '<products>' . $this->allProductsXml() . '</products>';
|
25 |
+
|
26 |
+
if($this->getRequest()->getParam('next_page'))
|
27 |
+
{
|
28 |
+
$store_code = $this->getRequest()->getParam('store_code');
|
29 |
+
$total_products_count = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($store_code)
|
30 |
+
->joinField('qty',
|
31 |
+
'cataloginventory/stock_item',
|
32 |
+
'qty',
|
33 |
+
'product_id=entity_id',
|
34 |
+
'{{table}}.stock_id=1',
|
35 |
+
'left')
|
36 |
+
->joinField('is_in_stock',
|
37 |
+
'cataloginventory/stock_item',
|
38 |
+
'is_in_stock',
|
39 |
+
'product_id=entity_id',
|
40 |
+
'{{table}}.stock_id=1',
|
41 |
+
'left')
|
42 |
+
->addAttributeToSelect('*')
|
43 |
+
->addAttributeToFilter('status', '1')
|
44 |
+
->addAttributeToFilter('is_in_stock', '1')
|
45 |
+
->addAttributeToFilter('visibility', array('neq' => 1))->count();
|
46 |
+
|
47 |
+
$pages = ceil($total_products_count/300);
|
48 |
+
echo "<pages>".$pages."</pages>";
|
49 |
+
$page_num_rcv = $this->getRequest()->getParam('next_page');
|
50 |
+
if($page_num_rcv > $pages)
|
51 |
+
return;
|
52 |
+
} else {
|
53 |
+
|
54 |
+
print '<categories>' . $this->categoriesxml() . '</categories>';
|
55 |
+
}
|
56 |
+
|
57 |
+
}
|
58 |
+
echo '</data>';
|
59 |
+
die;
|
60 |
+
}
|
61 |
+
|
62 |
+
public function firstExportAction() {
|
63 |
+
|
64 |
+
set_time_limit(0);
|
65 |
+
header('Content-Type: text/xml');
|
66 |
+
|
67 |
+
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
|
68 |
+
echo '<data>';
|
69 |
+
|
70 |
+
if($data = $this->getRequest()->getPost())
|
71 |
+
{
|
72 |
+
foreach($data['product'] as $id)
|
73 |
+
{
|
74 |
+
print '<products>' . $this->productXml($id) . '</products>';
|
75 |
+
//print '<categories>' . $this->categoriesxml() . '</categories>';
|
76 |
+
}
|
77 |
+
}
|
78 |
+
else
|
79 |
+
{
|
80 |
+
print '<products>' . $this->tmpAllProductsXml() . '</products>';
|
81 |
+
print '<categories>' . $this->categoriesxml() . '</categories>';
|
82 |
+
}
|
83 |
+
echo '</data>';
|
84 |
+
die;
|
85 |
+
}
|
86 |
+
|
87 |
+
public function callbackAction() {
|
88 |
+
|
89 |
+
if($data = $this->getRequest()->getPost())
|
90 |
+
{
|
91 |
+
if($data['action_type'] == 'verify_cart')
|
92 |
+
{
|
93 |
+
$product_ids = explode(',', $data['product_ids']);
|
94 |
+
$quantities = explode(',', $data['quantities']);
|
95 |
+
$associated_ids = explode(',', $data['associated_ids']);
|
96 |
+
$shop_id_rcv = $data['shop_id'];
|
97 |
+
|
98 |
+
$store_id = Mage::app()->getStore()->getId();
|
99 |
+
$froomerce_config = Mage::getModel('froomerce/config')->getCollection();
|
100 |
+
foreach($froomerce_config as $cnfig)
|
101 |
+
{
|
102 |
+
if($shop_id_rcv == $cnfig['froomerce_shop_id'])
|
103 |
+
{
|
104 |
+
$store_id = $cnfig['store_id'];
|
105 |
+
break;
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
$total_products = count($product_ids);
|
110 |
+
|
111 |
+
$errors = array();
|
112 |
+
$return = array();
|
113 |
+
$er_index = 0;
|
114 |
+
for($j=0; $j < $total_products; $j++)
|
115 |
+
{
|
116 |
+
if($associated_ids[$j])
|
117 |
+
$product_tmp = Mage::getModel('catalog/product')->setStoreId($store_id)->load($associated_ids[$j]);
|
118 |
+
else
|
119 |
+
$product_tmp = Mage::getModel('catalog/product')->setStoreId($store_id)->load($product_ids[$j]);
|
120 |
+
|
121 |
+
$stock_obj = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product_tmp);
|
122 |
+
$max_sale_qty = $stock_obj->getMaxSaleQty();
|
123 |
+
$qty = $stock_obj->getQty();
|
124 |
+
if($qty < $quantities[$j] or $max_sale_qty < $quantities[$j])
|
125 |
+
{
|
126 |
+
if($max_sale_qty < $quantities[$j])
|
127 |
+
$available = $max_sale_qty;
|
128 |
+
else
|
129 |
+
$available = $qty;
|
130 |
+
|
131 |
+
$errors[$er_index]['name'] = $product_tmp->getName();
|
132 |
+
$errors[$er_index]['out_of_stock'] = $product_tmp->getId();
|
133 |
+
$errors[$er_index]['available_qty'] = round($available);
|
134 |
+
$er_index++;
|
135 |
+
}
|
136 |
+
}
|
137 |
+
if(count($errors))
|
138 |
+
{
|
139 |
+
$return['status'] = 'error';
|
140 |
+
$return['error'] = $errors;
|
141 |
+
}
|
142 |
+
else
|
143 |
+
{
|
144 |
+
$return['status'] = 'success';
|
145 |
+
}
|
146 |
+
echo json_encode($return);
|
147 |
+
exit;
|
148 |
+
|
149 |
+
}
|
150 |
+
elseif($data['action_type'] == 'get_attributes')
|
151 |
+
{
|
152 |
+
$id = $data['product_id'];
|
153 |
+
$collection = Mage::getModel('catalog/product')->getCollection();
|
154 |
+
$collection->addAttributeToFilter('entity_id',$id);
|
155 |
+
$collection->addAttributeToSelect('*');
|
156 |
+
|
157 |
+
$shop_id_rcv = $data['shop_id'];
|
158 |
+
|
159 |
+
$store_id = Mage::app()->getStore()->getId();
|
160 |
+
$curr_code = Mage::app()->getStore()->getCode();
|
161 |
+
|
162 |
+
$froomerce_config = Mage::getModel('froomerce/config')->getCollection();
|
163 |
+
foreach($froomerce_config as $cnfig)
|
164 |
+
{
|
165 |
+
if($shop_id_rcv == $cnfig['froomerce_shop_id'])
|
166 |
+
{
|
167 |
+
$store_id = $cnfig['store_id'];
|
168 |
+
break;
|
169 |
+
}
|
170 |
+
}
|
171 |
+
$storeCode_recv = $this->getStoreCode($store_id);
|
172 |
+
|
173 |
+
foreach($collection as $product)
|
174 |
+
{
|
175 |
+
if($product['type_id'] == 'configurable')
|
176 |
+
{
|
177 |
+
/**
|
178 |
+
/*$childProducts = Mage::getModel('catalog/product_type_configurable')
|
179 |
+
->getUsedProducts(null,$product);*/
|
180 |
+
$childIds = Mage::getModel('catalog/product_type_configurable')
|
181 |
+
->getChildrenIds($product->getId());
|
182 |
+
$attrs = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
|
183 |
+
|
184 |
+
$bas_curncy_code = Mage::app()->getStore()->getBaseCurrencyCode();
|
185 |
+
$cur_curncy_code = Mage::app()->getStore($storeCode_recv)->getCurrentCurrencyCode();
|
186 |
+
|
187 |
+
|
188 |
+
$allowedCurrencies = Mage::getModel('directory/currency')
|
189 |
+
->getConfigAllowCurrencies();
|
190 |
+
$currencyRates = Mage::getModel('directory/currency')
|
191 |
+
->getCurrencyRates($bas_curncy_code, array_values($allowedCurrencies));
|
192 |
+
|
193 |
+
$collection = Mage::getModel('catalog/product')->getCollection()
|
194 |
+
->joinField('qty',
|
195 |
+
'cataloginventory/stock_item',
|
196 |
+
'qty',
|
197 |
+
'product_id=entity_id',
|
198 |
+
'{{table}}.stock_id=1',
|
199 |
+
'left')
|
200 |
+
->joinField('is_in_stock',
|
201 |
+
'cataloginventory/stock_item',
|
202 |
+
'is_in_stock',
|
203 |
+
'product_id=entity_id',
|
204 |
+
'{{table}}.stock_id=1',
|
205 |
+
'left');
|
206 |
+
$collection->addAttributeToFilter('entity_id', array('in' => $childIds));
|
207 |
+
$collection->addAttributeToSelect('*');
|
208 |
+
$collection->addAttributeToFilter('status', '1');
|
209 |
+
$collection->addAttributeToFilter('is_in_stock', '1')
|
210 |
+
->addAttributeToFilter('qty', array('gt' => '0'));
|
211 |
+
$products_arr = array();
|
212 |
+
$index=0;
|
213 |
+
foreach($collection as $prod) {
|
214 |
+
$store_curncy_add = 0;
|
215 |
+
foreach($attrs as $attr) {
|
216 |
+
|
217 |
+
$options = $attr['values'];
|
218 |
+
$att_tmp = '';
|
219 |
+
$price_additional_fixed = 0;
|
220 |
+
$price_additional_percent = 0;
|
221 |
+
foreach($options as $option) {
|
222 |
+
if($option['value_index'] == $prod[$attr['attribute_code']])
|
223 |
+
{
|
224 |
+
if($option['is_percent'])
|
225 |
+
$price_additional_percent = $option['pricing_value'];
|
226 |
+
else
|
227 |
+
{
|
228 |
+
if(!empty($option['pricing_value']))
|
229 |
+
$price_additional_fixed = $option['pricing_value'];
|
230 |
+
}
|
231 |
+
|
232 |
+
$att_tmp = $option['store_label'];
|
233 |
+
break;
|
234 |
+
}
|
235 |
+
}
|
236 |
+
//$products_arr[$index][$attr['attribute_code']] = $att_tmp;
|
237 |
+
$products_arr[$index][$attr['frontend_label']] = $att_tmp;
|
238 |
+
|
239 |
+
$_finalPriceInclTax = $product->getPrice();
|
240 |
+
$special_price = 0;
|
241 |
+
$special_price = $product->getSpecialPrice();
|
242 |
+
$today = date('Y-m-d');
|
243 |
+
|
244 |
+
if($special_price and strtotime($today.' 00:00:00') < strtotime($product['special_to_date']))
|
245 |
+
$store_curncy = $special_price;
|
246 |
+
else
|
247 |
+
$store_curncy = $_finalPriceInclTax;
|
248 |
+
// convert Currncy
|
249 |
+
if($bas_curncy_code != $cur_curncy_code
|
250 |
+
and array_key_exists($bas_curncy_code, $currencyRates)
|
251 |
+
and array_key_exists($cur_curncy_code, $currencyRates)
|
252 |
+
)
|
253 |
+
{
|
254 |
+
$store_curncy = Mage::helper('directory')
|
255 |
+
->currencyConvert($store_curncy, $bas_curncy_code, $cur_curncy_code);
|
256 |
+
}
|
257 |
+
|
258 |
+
if($price_additional_percent)
|
259 |
+
{
|
260 |
+
$store_curncy_add += $store_curncy*$price_additional_percent/100;
|
261 |
+
}
|
262 |
+
elseif($price_additional_fixed)
|
263 |
+
{
|
264 |
+
$store_curncy_add += $price_additional_fixed;
|
265 |
+
}
|
266 |
+
|
267 |
+
$products_arr[$index]['price'] = $store_curncy;
|
268 |
+
$products_arr[$index]['product_id'] = $prod->getId();
|
269 |
+
}
|
270 |
+
$products_arr[$index]['price'] += $store_curncy_add;
|
271 |
+
$index++;
|
272 |
+
}
|
273 |
+
|
274 |
+
echo json_encode($products_arr);exit;
|
275 |
+
|
276 |
+
}
|
277 |
+
|
278 |
+
}
|
279 |
+
}
|
280 |
+
elseif($data['action_type'] == 'add_to_cart')
|
281 |
+
{
|
282 |
+
// Refresing Shoping Cart
|
283 |
+
//foreach( Mage::getSingleton('checkout/session')->getQuote()->getItemsCollection() as $item ){
|
284 |
+
//$cart->removeItem( $item->getId() )->save();
|
285 |
+
//}
|
286 |
+
$cart = Mage::getSingleton('checkout/cart');
|
287 |
+
Mage::getSingleton('checkout/session')->clear();
|
288 |
+
$cart->truncate();
|
289 |
+
Mage::getSingleton('checkout/cart')->truncate();
|
290 |
+
Mage::getSingleton('checkout/session')->clear();
|
291 |
+
// End of Refreshing Shoping Cart
|
292 |
+
|
293 |
+
$product_ids = explode(',', $data['product_ids']);
|
294 |
+
$quantities = explode(',', $data['quantities']);
|
295 |
+
$associated_ids = explode(',', $data['associated_ids']);
|
296 |
+
$shop_id_rcv = $data['shop_id'];
|
297 |
+
|
298 |
+
$store_id = Mage::app()->getStore()->getId();
|
299 |
+
$curr_code = Mage::app()->getStore()->getCode();
|
300 |
+
|
301 |
+
$froomerce_config = Mage::getModel('froomerce/config')->getCollection();
|
302 |
+
foreach($froomerce_config as $cnfig)
|
303 |
+
{
|
304 |
+
if($shop_id_rcv == $cnfig['froomerce_shop_id'])
|
305 |
+
{
|
306 |
+
$store_id = $cnfig['store_id'];
|
307 |
+
break;
|
308 |
+
}
|
309 |
+
}
|
310 |
+
$storeCode_recv = $this->getStoreCode($store_id);
|
311 |
+
$qry_str = '';
|
312 |
+
if($curr_code != $storeCode_recv)
|
313 |
+
$qry_str = '?___store='.$storeCode_recv.'&___from_store='.$curr_code;
|
314 |
+
|
315 |
+
$total_products = count($product_ids);
|
316 |
+
|
317 |
+
for($i=0; $i < $total_products; $i++)
|
318 |
+
{
|
319 |
+
$product = Mage::getModel('catalog/product')->setStoreId($store_id)->load($product_ids[$i]);
|
320 |
+
|
321 |
+
if($associated_ids[$i])
|
322 |
+
{
|
323 |
+
$attrs = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
|
324 |
+
$associat_product = Mage::getModel('catalog/product')
|
325 |
+
->setStoreId($store_id)->load($associated_ids[$i]);
|
326 |
+
|
327 |
+
$final_options = array();
|
328 |
+
$indx = 0;
|
329 |
+
foreach($attrs as $attr)
|
330 |
+
{
|
331 |
+
$prod_attr = $associat_product[$attr['attribute_code']];
|
332 |
+
|
333 |
+
foreach($attr['values'] as $value)
|
334 |
+
{
|
335 |
+
if($prod_attr == $value['value_index'])
|
336 |
+
{
|
337 |
+
$final_options[$indx][$product_ids[$i]]['attribute_id'] = $attr['attribute_id'];
|
338 |
+
$final_options[$indx][$product_ids[$i]]['attribute_value'] = $value['value_index'];
|
339 |
+
$indx++;
|
340 |
+
}
|
341 |
+
}
|
342 |
+
}
|
343 |
+
|
344 |
+
$keys = '';
|
345 |
+
$vals = '';
|
346 |
+
$opts_arr = array();
|
347 |
+
foreach($final_options as $super_attribute)
|
348 |
+
{
|
349 |
+
$keys .= $super_attribute[$product_ids[$i]]['attribute_id'].',';
|
350 |
+
$vals .= $super_attribute[$product_ids[$i]]['attribute_value'].',';
|
351 |
+
}
|
352 |
+
$keys = rtrim($keys, ',');
|
353 |
+
$vals = rtrim($vals, ',');
|
354 |
+
$opts_arr = array_combine(explode(',', $keys), explode(',', $vals));
|
355 |
+
|
356 |
+
$params = array(
|
357 |
+
'product' => $product_ids[$i],
|
358 |
+
'super_attribute' => $opts_arr,
|
359 |
+
'qty' => $quantities[$i],
|
360 |
+
);
|
361 |
+
}
|
362 |
+
else
|
363 |
+
{
|
364 |
+
$params = array(
|
365 |
+
'product' => $product_ids[$i],
|
366 |
+
'qty' => $quantities[$i]
|
367 |
+
);
|
368 |
+
}
|
369 |
+
// Adding requested items to cart
|
370 |
+
try {
|
371 |
+
$cart->init();
|
372 |
+
$cart->addProduct($product, $params);
|
373 |
+
$cart->save();
|
374 |
+
} catch(Exception $e) {
|
375 |
+
}
|
376 |
+
}
|
377 |
+
$this->_redirect('checkout/cart/'.$qry_str);
|
378 |
+
}
|
379 |
+
|
380 |
+
elseif($data['action_type'] == 'export_flag')
|
381 |
+
{
|
382 |
+
$shop_id_rcv = $data['shop_id'];
|
383 |
+
$resource = Mage::getSingleton( 'core/resource' );
|
384 |
+
try {
|
385 |
+
$write = $resource->getConnection('core_write');
|
386 |
+
$table = $resource->getTableName('froomerce_config');
|
387 |
+
$write->query("UPDATE ".$table ." SET status='Exported' WHERE froomerce_shop_id='$shop_id_rcv' ");
|
388 |
+
} catch (Exception $e) {
|
389 |
+
|
390 |
+
}
|
391 |
+
|
392 |
+
/*
|
393 |
+
$model = Mage::getModel('froomerce/config');
|
394 |
+
|
395 |
+
$froomerce_config = Mage::getModel('froomerce/config')->getCollection();
|
396 |
+
foreach($froomerce_config as $cnfig)
|
397 |
+
{
|
398 |
+
if($shop_id_rcv == $cnfig['froomerce_shop_id'])
|
399 |
+
{
|
400 |
+
$cnfg_id = $cnfig->getId();
|
401 |
+
break;
|
402 |
+
}
|
403 |
+
}
|
404 |
+
|
405 |
+
$export_status = 'Exported';
|
406 |
+
|
407 |
+
$dataa = array(
|
408 |
+
'status'=>$export_status,
|
409 |
+
);
|
410 |
+
$model->setData($dataa)
|
411 |
+
->setId($cnfg_id);
|
412 |
+
try {
|
413 |
+
$model->save();
|
414 |
+
} catch (Exception $e) {
|
415 |
+
|
416 |
+
} */
|
417 |
+
}
|
418 |
+
|
419 |
+
elseif($data['action_type'] == 'exported_products')
|
420 |
+
{
|
421 |
+
$shop_id_rcv = $data['shop_id'];
|
422 |
+
$product_ids_str = $data['product_ids'];
|
423 |
+
$product_ids_arr = explode(',', $product_ids_str);
|
424 |
+
|
425 |
+
try {
|
426 |
+
$store_id = Mage::app()->getStore()->getId();
|
427 |
+
$froomerce_config = Mage::getModel('froomerce/config')->getCollection()
|
428 |
+
->addFieldToFilter('froomerce_shop_id', $shop_id_rcv);
|
429 |
+
|
430 |
+
foreach($froomerce_config as $cnfig)
|
431 |
+
{
|
432 |
+
$store_id = $cnfig['store_id'];
|
433 |
+
}
|
434 |
+
|
435 |
+
$model = Mage::getModel('froomerce/products');
|
436 |
+
$resource = Mage::getSingleton( 'core/resource' );
|
437 |
+
|
438 |
+
$write = $resource->getConnection('core_write');
|
439 |
+
$table = $resource->getTableName('froomerce_products');
|
440 |
+
|
441 |
+
if(isset($data['first']) and $data['first'] == 1)
|
442 |
+
{
|
443 |
+
$write->query("UPDATE ".$table ." SET status='0' WHERE store_id='$store_id' ");
|
444 |
+
}
|
445 |
+
|
446 |
+
if(count($product_ids_arr))
|
447 |
+
{
|
448 |
+
$qrystr1 = ",$store_id,1),(";
|
449 |
+
$qry_str = implode($qrystr1, $product_ids_arr);
|
450 |
+
$qry_str = "(".$qry_str.",$store_id,1)";
|
451 |
+
|
452 |
+
$write->query("insert into ".$table ." (product_id, store_id, status) values ".$qry_str."
|
453 |
+
ON DUPLICATE KEY UPDATE status='1'");
|
454 |
+
|
455 |
+
}
|
456 |
+
|
457 |
+
if(isset($data['last']) and $data['last'] == 1)
|
458 |
+
{
|
459 |
+
$write->query("DELETE FROM ".$table ." WHERE status='0' AND store_id='$store_id' ");
|
460 |
+
}
|
461 |
+
} catch (Exception $e) {
|
462 |
+
$handler = fopen('cronError.txt', 'w');
|
463 |
+
fwrite($handler, print_r($e, true));
|
464 |
+
fclose($handler);
|
465 |
+
}
|
466 |
+
}
|
467 |
+
}
|
468 |
+
else
|
469 |
+
echo 'Invalid Request Type.';
|
470 |
+
}
|
471 |
+
|
472 |
+
public function addtocartAction()
|
473 |
+
{
|
474 |
+
$id = 10;
|
475 |
+
$collection = Mage::getModel('catalog/product')->getCollection();
|
476 |
+
$collection->addAttributeToFilter('entity_id',$id);
|
477 |
+
$collection->addAttributeToSelect('*');
|
478 |
+
|
479 |
+
$shop_id_rcv = 7577;
|
480 |
+
|
481 |
+
$store_id = Mage::app()->getStore()->getId();
|
482 |
+
$curr_code = Mage::app()->getStore()->getCode();
|
483 |
+
|
484 |
+
$froomerce_config = Mage::getModel('froomerce/config')->getCollection();
|
485 |
+
foreach($froomerce_config as $cnfig)
|
486 |
+
{
|
487 |
+
if($shop_id_rcv == $cnfig['froomerce_shop_id'])
|
488 |
+
{
|
489 |
+
$store_id = $cnfig['store_id'];
|
490 |
+
break;
|
491 |
+
}
|
492 |
+
}
|
493 |
+
$storeCode_recv = $this->getStoreCode($store_id);
|
494 |
+
|
495 |
+
foreach($collection as $product)
|
496 |
+
{
|
497 |
+
if($product['type_id'] == 'configurable')
|
498 |
+
{
|
499 |
+
/**
|
500 |
+
/*$childProducts = Mage::getModel('catalog/product_type_configurable')
|
501 |
+
->getUsedProducts(null,$product);*/
|
502 |
+
$childIds = Mage::getModel('catalog/product_type_configurable')
|
503 |
+
->getChildrenIds($product->getId());
|
504 |
+
$attrs = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
|
505 |
+
|
506 |
+
$bas_curncy_code = Mage::app()->getStore()->getBaseCurrencyCode();
|
507 |
+
$cur_curncy_code = Mage::app()->getStore($storeCode_recv)->getCurrentCurrencyCode();
|
508 |
+
|
509 |
+
|
510 |
+
$allowedCurrencies = Mage::getModel('directory/currency')
|
511 |
+
->getConfigAllowCurrencies();
|
512 |
+
$currencyRates = Mage::getModel('directory/currency')
|
513 |
+
->getCurrencyRates($bas_curncy_code, array_values($allowedCurrencies));
|
514 |
+
|
515 |
+
$collection = Mage::getModel('catalog/product')->getCollection()
|
516 |
+
->joinField('qty',
|
517 |
+
'cataloginventory/stock_item',
|
518 |
+
'qty',
|
519 |
+
'product_id=entity_id',
|
520 |
+
'{{table}}.stock_id=1',
|
521 |
+
'left')
|
522 |
+
->joinField('is_in_stock',
|
523 |
+
'cataloginventory/stock_item',
|
524 |
+
'is_in_stock',
|
525 |
+
'product_id=entity_id',
|
526 |
+
'{{table}}.stock_id=1',
|
527 |
+
'left');
|
528 |
+
$collection->addAttributeToFilter('entity_id', array('in' => $childIds));
|
529 |
+
$collection->addAttributeToSelect('*');
|
530 |
+
$collection->addAttributeToFilter('status', '1');
|
531 |
+
$collection->addAttributeToFilter('is_in_stock', '1')
|
532 |
+
->addAttributeToFilter('qty', array('neq' => '0'));
|
533 |
+
$products_arr = array();
|
534 |
+
$index=0;
|
535 |
+
foreach($collection as $prod) {
|
536 |
+
$store_curncy_add = 0;
|
537 |
+
foreach($attrs as $attr) {
|
538 |
+
|
539 |
+
$options = $attr['values'];
|
540 |
+
$att_tmp = '';
|
541 |
+
$price_additional_fixed = 0;
|
542 |
+
$price_additional_percent = 0;
|
543 |
+
foreach($options as $option) {
|
544 |
+
if($option['value_index'] == $prod[$attr['attribute_code']])
|
545 |
+
{
|
546 |
+
if($option['is_percent'])
|
547 |
+
$price_additional_percent = $option['pricing_value'];
|
548 |
+
else
|
549 |
+
{
|
550 |
+
if(!empty($option['pricing_value']))
|
551 |
+
$price_additional_fixed = $option['pricing_value'];
|
552 |
+
}
|
553 |
+
|
554 |
+
$att_tmp = $option['store_label'];
|
555 |
+
break;
|
556 |
+
}
|
557 |
+
}
|
558 |
+
//$products_arr[$index][$attr['attribute_code']] = $att_tmp;
|
559 |
+
$products_arr[$index][$attr['frontend_label']] = $att_tmp;
|
560 |
+
|
561 |
+
$_finalPriceInclTax = $product->getPrice();
|
562 |
+
$special_price = 0;
|
563 |
+
$special_price = $product->getSpecialPrice();
|
564 |
+
$today = date('Y-m-d');
|
565 |
+
|
566 |
+
if($special_price and strtotime($today.' 00:00:00') < strtotime($product['special_to_date']))
|
567 |
+
$store_curncy = $special_price;
|
568 |
+
else
|
569 |
+
$store_curncy = $_finalPriceInclTax;
|
570 |
+
// convert Currncy
|
571 |
+
if($bas_curncy_code != $cur_curncy_code
|
572 |
+
and array_key_exists($bas_curncy_code, $currencyRates)
|
573 |
+
and array_key_exists($cur_curncy_code, $currencyRates)
|
574 |
+
)
|
575 |
+
{
|
576 |
+
$store_curncy = Mage::helper('directory')
|
577 |
+
->currencyConvert($store_curncy, $bas_curncy_code, $cur_curncy_code);
|
578 |
+
}
|
579 |
+
|
580 |
+
if($price_additional_percent)
|
581 |
+
{
|
582 |
+
$store_curncy_add += $store_curncy*$price_additional_percent/100;
|
583 |
+
}
|
584 |
+
elseif($price_additional_fixed)
|
585 |
+
{
|
586 |
+
$store_curncy_add += $price_additional_fixed;
|
587 |
+
}
|
588 |
+
|
589 |
+
$products_arr[$index]['price'] = $store_curncy;
|
590 |
+
$products_arr[$index]['product_id'] = $prod->getId();
|
591 |
+
}
|
592 |
+
$products_arr[$index]['price'] += $store_curncy_add;
|
593 |
+
$index++;
|
594 |
+
}
|
595 |
+
|
596 |
+
echo json_encode($products_arr);exit;
|
597 |
+
|
598 |
+
}
|
599 |
+
|
600 |
+
}
|
601 |
+
}
|
602 |
+
protected function allProductsXml(){
|
603 |
+
|
604 |
+
$store_code = $this->getRequest()->getParam('store_code');
|
605 |
+
|
606 |
+
$store_id = $this->getStoreId($store_code);
|
607 |
+
$rot_url = rtrim(Mage::getRoot(), 'app');
|
608 |
+
$root_id = Mage::app()->getStore($store_code)->getRootCategoryId();
|
609 |
+
//$root_id = Mage::app()->getStore($store_id)->getRootCategoryId();
|
610 |
+
$root = Mage::getModel('catalog/category')->load($root_id);
|
611 |
+
$child_tmp = $root->getAllChildren(true);
|
612 |
+
|
613 |
+
$validCats = array();
|
614 |
+
$validCats = $this->getEnabledCategories($store_id, $child_tmp);
|
615 |
+
if(!count($validCats))
|
616 |
+
return;
|
617 |
+
|
618 |
+
$currency_symbol = Mage::app()
|
619 |
+
->getLocale()
|
620 |
+
->currency(Mage::app()->getStore($store_code)->getCurrentCurrencyCode())
|
621 |
+
->getSymbol();
|
622 |
+
|
623 |
+
// Making Collection with pagination
|
624 |
+
//$total_products_count=Mage::getModel('catalog/product')->getCollection()->count();
|
625 |
+
$total_products_count = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($store_code)
|
626 |
+
->joinField('qty',
|
627 |
+
'cataloginventory/stock_item',
|
628 |
+
'qty',
|
629 |
+
'product_id=entity_id',
|
630 |
+
'{{table}}.stock_id=1',
|
631 |
+
'left')
|
632 |
+
->joinField('is_in_stock',
|
633 |
+
'cataloginventory/stock_item',
|
634 |
+
'is_in_stock',
|
635 |
+
'product_id=entity_id',
|
636 |
+
'{{table}}.stock_id=1',
|
637 |
+
'left')
|
638 |
+
->addAttributeToSelect('*')
|
639 |
+
->addAttributeToFilter('status', '1')
|
640 |
+
->addAttributeToFilter('is_in_stock', '1')
|
641 |
+
->addAttributeToFilter('visibility', array('neq' => 1))->count();
|
642 |
+
|
643 |
+
|
644 |
+
|
645 |
+
$prod_limit = 300;
|
646 |
+
$pages = ceil($total_products_count/$prod_limit);
|
647 |
+
|
648 |
+
$page_num_rcv = 0;
|
649 |
+
if($this->getRequest()->getParam('next_page'))
|
650 |
+
{
|
651 |
+
$page_num_rcv = $this->getRequest()->getParam('next_page');
|
652 |
+
if($page_num_rcv > $pages)
|
653 |
+
return;
|
654 |
+
}
|
655 |
+
|
656 |
+
$offset = $prod_limit * $page_num_rcv;
|
657 |
+
|
658 |
+
/*$collection = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($store_code);
|
659 |
+
$collection->addAttributeToSelect('*'); */
|
660 |
+
$collection = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($store_code)
|
661 |
+
->joinField('qty',
|
662 |
+
'cataloginventory/stock_item',
|
663 |
+
'qty',
|
664 |
+
'product_id=entity_id',
|
665 |
+
'{{table}}.stock_id=1',
|
666 |
+
'left')
|
667 |
+
->joinField('is_in_stock',
|
668 |
+
'cataloginventory/stock_item',
|
669 |
+
'is_in_stock',
|
670 |
+
'product_id=entity_id',
|
671 |
+
'{{table}}.stock_id=1',
|
672 |
+
'left');
|
673 |
+
$collection->addAttributeToSelect('*');
|
674 |
+
$collection->addAttributeToFilter('status', '1');
|
675 |
+
$collection->addAttributeToFilter('is_in_stock', '1')
|
676 |
+
->addAttributeToFilter('visibility', array('neq' => 1));
|
677 |
+
$collection->getSelect()->limit($prod_limit, $offset);
|
678 |
+
|
679 |
+
$xml= '';
|
680 |
+
$all_product_cats = array();
|
681 |
+
$_taxHelper = Mage::helper('tax');
|
682 |
+
$_simplePricesTax = ($_taxHelper->displayPriceIncludingTax() || $_taxHelper->displayBothPrices());
|
683 |
+
|
684 |
+
$today = date('Y-m-d');
|
685 |
+
// Get Currency Code
|
686 |
+
$bas_curncy_code = Mage::app()->getStore()->getBaseCurrencyCode();
|
687 |
+
$cur_curncy_code = Mage::app()->getStore($store_code)->getCurrentCurrencyCode();
|
688 |
+
|
689 |
+
$collectTagProducts = Mage::getResourceModel('tag/product_collection');
|
690 |
+
$all_tags = $this->getAllTags();
|
691 |
+
$filtered_tags = array();
|
692 |
+
if(count($all_tags))
|
693 |
+
{
|
694 |
+
foreach ($collectTagProducts as $_tagProduct):
|
695 |
+
$tag_id = $_tagProduct->getTagId();
|
696 |
+
$tag_url = $all_tags[$tag_id];
|
697 |
+
$filtered_tags[$_tagProduct->getId()]['name'] = $_tagProduct->getTagName();
|
698 |
+
$filtered_tags[$_tagProduct->getId()]['link'] = $tag_url;
|
699 |
+
endforeach;
|
700 |
+
}
|
701 |
+
$allowedCurrencies = Mage::getModel('directory/currency')
|
702 |
+
->getConfigAllowCurrencies();
|
703 |
+
$currencyRates = Mage::getModel('directory/currency')
|
704 |
+
->getCurrencyRates($bas_curncy_code, array_values($allowedCurrencies));
|
705 |
+
|
706 |
+
|
707 |
+
$counter12 = 0;
|
708 |
+
//$counter_pre = $page_num * $counter1;
|
709 |
+
foreach($collection as $product)
|
710 |
+
{
|
711 |
+
$productid = $product->getId();
|
712 |
+
// Data Filtering
|
713 |
+
if($product->getStatus() == 2 or $product->getVisibility() == 1) //if product disabled or visiblity none
|
714 |
+
continue;
|
715 |
+
|
716 |
+
$cc = $product->getCategoryIds();
|
717 |
+
if(!count($cc)) // If product not belong to any category
|
718 |
+
continue;
|
719 |
+
$no_exist = true;
|
720 |
+
foreach($cc as $ctid)
|
721 |
+
{
|
722 |
+
if(in_array($ctid, $validCats))
|
723 |
+
{
|
724 |
+
$no_exist = false;
|
725 |
+
break;
|
726 |
+
}
|
727 |
+
}
|
728 |
+
if($no_exist)
|
729 |
+
continue;
|
730 |
+
|
731 |
+
$qty_obj = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
732 |
+
if($product['type_id'] == 'configurable')
|
733 |
+
{
|
734 |
+
$configChildIds = array();
|
735 |
+
$configChildIds = Mage::getModel('catalog/product_type_configurable')
|
736 |
+
->getChildrenIds($product->getId());
|
737 |
+
|
738 |
+
if(!count($configChildIds[0]))
|
739 |
+
continue;
|
740 |
+
}
|
741 |
+
else
|
742 |
+
{
|
743 |
+
$qty = $qty_obj->getQty();
|
744 |
+
if($qty < 1) // If Quantity is zero
|
745 |
+
continue;
|
746 |
+
}
|
747 |
+
|
748 |
+
if(empty($product['stock_item']->is_in_stock))
|
749 |
+
{
|
750 |
+
if(!$qty_obj->is_in_stock)
|
751 |
+
continue;
|
752 |
+
}
|
753 |
+
elseif($product['stock_item']->is_in_stock == 0) // Product out of stock
|
754 |
+
continue;
|
755 |
+
|
756 |
+
|
757 |
+
$productid = $product->getId();
|
758 |
+
$product_cats = array();
|
759 |
+
$product_cats = $product->getCategoryIds();
|
760 |
+
foreach($product_cats as $catId)
|
761 |
+
{
|
762 |
+
if(!in_array($catId, $validCats))
|
763 |
+
continue;
|
764 |
+
|
765 |
+
$f_parent = $this->getParent($catId);
|
766 |
+
|
767 |
+
if(array_key_exists($catId, $all_product_cats)) // If already exists in someone's parent
|
768 |
+
continue;
|
769 |
+
|
770 |
+
$parentId = $catId;
|
771 |
+
while(1)
|
772 |
+
{
|
773 |
+
$parentId = $this->getParent($parentId); // here should be parent ID otherwise unlimited loop
|
774 |
+
$ii = 0;
|
775 |
+
if($parentId === 0)
|
776 |
+
break;
|
777 |
+
else
|
778 |
+
$all_product_cats[$catId][] = $parentId;
|
779 |
+
if($ii++ == 20)
|
780 |
+
break;
|
781 |
+
}
|
782 |
+
}
|
783 |
+
|
784 |
+
$xml .= '<product>';
|
785 |
+
$xml .= '<product_id><![CDATA['.$productid.']]></product_id>';
|
786 |
+
if($product['type_id'] == 'configurable')
|
787 |
+
$xml .= '<is_configurable><![CDATA[1]]></is_configurable>';
|
788 |
+
else
|
789 |
+
$xml .= '<is_configurable><![CDATA[0]]></is_configurable>';
|
790 |
+
|
791 |
+
$xml .= '<title><![CDATA['.$this->__($product->getName()).']]>';
|
792 |
+
$xml .= '</title>';
|
793 |
+
|
794 |
+
$_finalPriceInclTax = $_taxHelper->getPrice($product, $product->getFinalPrice(), 2);
|
795 |
+
$special_price = 0;
|
796 |
+
$special_price = $_taxHelper->getPrice($product, $product->getSpecialPrice(), 2);
|
797 |
+
|
798 |
+
if($bas_curncy_code != $cur_curncy_code
|
799 |
+
and array_key_exists($bas_curncy_code, $currencyRates)
|
800 |
+
and array_key_exists($cur_curncy_code, $currencyRates)
|
801 |
+
)
|
802 |
+
{
|
803 |
+
if($special_price and strtotime($today.' 00:00:00') < strtotime($product['special_to_date']))
|
804 |
+
{
|
805 |
+
$store_curncy = Mage::helper('directory')->currencyConvert($special_price, $bas_curncy_code, $cur_curncy_code);
|
806 |
+
}
|
807 |
+
else
|
808 |
+
{
|
809 |
+
$store_curncy = Mage::helper('directory')->currencyConvert($_finalPriceInclTax, $bas_curncy_code, $cur_curncy_code);
|
810 |
+
}
|
811 |
+
}
|
812 |
+
else
|
813 |
+
{
|
814 |
+
if($special_price and strtotime($today.' 00:00:00') < strtotime($product['special_to_date']))
|
815 |
+
{
|
816 |
+
$store_curncy = $special_price;
|
817 |
+
}
|
818 |
+
else
|
819 |
+
{
|
820 |
+
$store_curncy = $_finalPriceInclTax;
|
821 |
+
}
|
822 |
+
}
|
823 |
+
$xml .= '<price><![CDATA['.round($store_curncy, 2).']]>';
|
824 |
+
$xml .= '</price>';
|
825 |
+
$xml .= '<currency_symbol><![CDATA['.$currency_symbol.']]>';
|
826 |
+
$xml .= '</currency_symbol>';
|
827 |
+
$xml .= '<shipping_info><![CDATA[]]>';
|
828 |
+
$xml .= '</shipping_info>';
|
829 |
+
if($product->getImage() == 'no_selection')
|
830 |
+
{
|
831 |
+
$xml .= '<image_small><![CDATA[]]></image_small>';
|
832 |
+
$xml .= '<image_large><![CDATA[]]>';
|
833 |
+
}
|
834 |
+
else
|
835 |
+
{
|
836 |
+
$img_size=0;
|
837 |
+
$imgurl_tmp = $rot_url.'media/catalog/product'.$product->getImage();
|
838 |
+
|
839 |
+
if(file_exists($imgurl_tmp))
|
840 |
+
{
|
841 |
+
$img_size = filesize($imgurl_tmp);
|
842 |
+
if($img_size)
|
843 |
+
{
|
844 |
+
$xml.= '<img>'.$imgurl_tmp.'</img>';
|
845 |
+
|
846 |
+
$xml .= '<image_small><![CDATA['.Mage::helper('catalog/image')->init($product, 'small_image')->resize(170).']]></image_small>';
|
847 |
+
$xml .= '<image_large><![CDATA['.Mage::helper('catalog/image')->init($product, 'image').']]>';
|
848 |
+
}
|
849 |
+
else
|
850 |
+
{
|
851 |
+
$xml .= '<image_small><![CDATA[]]></image_small>';
|
852 |
+
$xml .= '<image_large><![CDATA[]]>';
|
853 |
+
}
|
854 |
+
}
|
855 |
+
else
|
856 |
+
{
|
857 |
+
$xml .= '<image_small><![CDATA[]]></image_small>';
|
858 |
+
$xml .= '<image_large><![CDATA[]]>';
|
859 |
+
}
|
860 |
+
}
|
861 |
+
|
862 |
+
$xml .= '</image_large>';
|
863 |
+
$xml .= '<product_link><![CDATA['.$product->getProductUrl().']]>';
|
864 |
+
$xml .= '</product_link>';
|
865 |
+
|
866 |
+
$xml .= '<short_description><![CDATA['.$product->getShortDescription().']]></short_description>';
|
867 |
+
|
868 |
+
$desc = $product->getDescription();
|
869 |
+
if(empty($desc))
|
870 |
+
$desc = mage::helper('catalog/output')->productAttribute($product, nl2br($product->getDescription()), 'description');
|
871 |
+
|
872 |
+
$xml .= '<product_detail><![CDATA['.$desc.']]>';
|
873 |
+
$xml .= '</product_detail>';
|
874 |
+
$xml .= '<product_tags>';
|
875 |
+
if(array_key_exists($productid, $filtered_tags))
|
876 |
+
$xml .= '<tag link="'.$filtered_tags[$productid]['link'].'"><![CDATA['.$filtered_tags[$productid]['name'].']]></tag>';
|
877 |
+
|
878 |
+
$xml .= '</product_tags>';
|
879 |
+
|
880 |
+
$xml .= '<category_id><![CDATA[';
|
881 |
+
$xml_tmp = '';
|
882 |
+
foreach($product_cats as $catId)
|
883 |
+
{
|
884 |
+
if(!in_array($catId, $validCats))
|
885 |
+
continue;
|
886 |
+
|
887 |
+
if($root_id == $catId)
|
888 |
+
continue;
|
889 |
+
|
890 |
+
$tmp_arr = array();
|
891 |
+
if(array_key_exists($catId, $all_product_cats))
|
892 |
+
{
|
893 |
+
$tmp_arr = array_reverse($all_product_cats[$catId]);
|
894 |
+
$xml_tmp .= implode('/', $tmp_arr);
|
895 |
+
$xml_tmp .= '/'.$catId.',';
|
896 |
+
}
|
897 |
+
else
|
898 |
+
{
|
899 |
+
$xml_tmp .= $catId.',';
|
900 |
+
}
|
901 |
+
}
|
902 |
+
$xml .= rtrim($xml_tmp, ',');
|
903 |
+
$xml .= ']]></category_id>';
|
904 |
+
|
905 |
+
$xml .= '<multiple_images>';
|
906 |
+
$additional_images = Mage::getModel('catalog/product')->load($productid)->getMediaGalleryImages();
|
907 |
+
if(count($additional_images) > 0)
|
908 |
+
{
|
909 |
+
foreach ($additional_images as $images) {
|
910 |
+
$xml .= '<img><![CDATA['.$images->getUrl().']]></img>';
|
911 |
+
}
|
912 |
+
}
|
913 |
+
|
914 |
+
$xml .= '</multiple_images>';
|
915 |
+
|
916 |
+
$xml .= '<attributes>';
|
917 |
+
// Getting Additional information
|
918 |
+
$attributes = $product->getAttributes();
|
919 |
+
|
920 |
+
$data = array();
|
921 |
+
foreach ($attributes as $attribute) {
|
922 |
+
if ($attribute->getIsVisibleOnFront() && $attribute->getIsUserDefined()) {
|
923 |
+
$value = $attribute->getFrontend()->getValue($product);
|
924 |
+
|
925 |
+
if (!$product->hasData($attribute->getAttributeCode())) {
|
926 |
+
$value = 'N/A';
|
927 |
+
} elseif ((string)$value == '') {
|
928 |
+
$value = 'No';
|
929 |
+
}
|
930 |
+
$xml .= '<attribute label="'.$attribute->getFrontend()->getLabel().'"><![CDATA['.$value.']]></attribute>';
|
931 |
+
}
|
932 |
+
}
|
933 |
+
|
934 |
+
$xml .= '</attributes>';
|
935 |
+
|
936 |
+
$xml .= '</product>';
|
937 |
+
}
|
938 |
+
|
939 |
+
if($page_num_rcv < $pages)
|
940 |
+
{
|
941 |
+
$baseURL = Mage::getBaseUrl();
|
942 |
+
if(Mage::getStoreConfig('web/url/use_store'))
|
943 |
+
$baseURL = Mage::app()->getStore($storecode)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
|
944 |
+
|
945 |
+
echo '<next_page>'.$baseURL.'froomerce/rss/export/store_code/'.$store_code.'/next_page/'.($page_num_rcv + 1).'</next_page>';
|
946 |
+
}
|
947 |
+
return $xml;
|
948 |
+
}
|
949 |
+
|
950 |
+
protected function tmpAllProductsXml(){
|
951 |
+
|
952 |
+
$store_code = $this->getRequest()->getParam('store_code');
|
953 |
+
$store_id = $this->getStoreId($store_code);
|
954 |
+
$rot_url = rtrim(Mage::getRoot(), 'app');
|
955 |
+
$root_id = Mage::app()->getStore($store_code)->getRootCategoryId();
|
956 |
+
//$root_id = Mage::app()->getStore($store_id)->getRootCategoryId();
|
957 |
+
$root = Mage::getModel('catalog/category')->load($root_id);
|
958 |
+
$child_tmp = $root->getAllChildren(true);
|
959 |
+
$validCats = $this->getEnabledCategories($store_id, $child_tmp);
|
960 |
+
if(!count($validCats))
|
961 |
+
return;
|
962 |
+
|
963 |
+
$currency_symbol = Mage::app()
|
964 |
+
->getLocale()
|
965 |
+
->currency(Mage::app()->getStore($store_code)->getCurrentCurrencyCode())
|
966 |
+
->getSymbol();
|
967 |
+
|
968 |
+
//$collection = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($store_code);
|
969 |
+
//$collection->addAttributeToSelect('*');
|
970 |
+
$collection = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($store_code)
|
971 |
+
->joinField('qty',
|
972 |
+
'cataloginventory/stock_item',
|
973 |
+
'qty',
|
974 |
+
'product_id=entity_id',
|
975 |
+
'{{table}}.stock_id=1',
|
976 |
+
'left')
|
977 |
+
->joinField('is_in_stock',
|
978 |
+
'cataloginventory/stock_item',
|
979 |
+
'is_in_stock',
|
980 |
+
'product_id=entity_id',
|
981 |
+
'{{table}}.stock_id=1',
|
982 |
+
'left');
|
983 |
+
$collection->addAttributeToSelect('*');
|
984 |
+
$collection->addAttributeToFilter('status', '1');
|
985 |
+
$collection->addAttributeToFilter('is_in_stock', '1')
|
986 |
+
->addAttributeToFilter('visibility', array('neq' => 1));
|
987 |
+
//$collection->getSelect()->limit(2000);
|
988 |
+
|
989 |
+
$xml= '';
|
990 |
+
$all_product_cats = array();
|
991 |
+
$_taxHelper = Mage::helper('tax');
|
992 |
+
$_simplePricesTax = ($_taxHelper->displayPriceIncludingTax() || $_taxHelper->displayBothPrices());
|
993 |
+
|
994 |
+
$today = date('Y-m-d');
|
995 |
+
// Get Currency Code
|
996 |
+
$bas_curncy_code = Mage::app()->getStore()->getBaseCurrencyCode();
|
997 |
+
$cur_curncy_code = Mage::app()->getStore($store_code)->getCurrentCurrencyCode();
|
998 |
+
|
999 |
+
$collectTagProducts = Mage::getResourceModel('tag/product_collection');
|
1000 |
+
$all_tags = $this->getAllTags();
|
1001 |
+
$filtered_tags = array();
|
1002 |
+
if(count($all_tags))
|
1003 |
+
{
|
1004 |
+
foreach ($collectTagProducts as $_tagProduct):
|
1005 |
+
$tag_id = $_tagProduct->getTagId();
|
1006 |
+
$tag_url = $all_tags[$tag_id];
|
1007 |
+
$filtered_tags[$_tagProduct->getId()]['name'] = $_tagProduct->getTagName();
|
1008 |
+
$filtered_tags[$_tagProduct->getId()]['link'] = $tag_url;
|
1009 |
+
endforeach;
|
1010 |
+
}
|
1011 |
+
$allowedCurrencies = Mage::getModel('directory/currency')
|
1012 |
+
->getConfigAllowCurrencies();
|
1013 |
+
$currencyRates = Mage::getModel('directory/currency')
|
1014 |
+
->getCurrencyRates($bas_curncy_code, array_values($allowedCurrencies));
|
1015 |
+
|
1016 |
+
$tmp_count = 0;
|
1017 |
+
foreach($collection as $product)
|
1018 |
+
{
|
1019 |
+
// Data Filtering
|
1020 |
+
if($product->getStatus() == 2 or $product->getVisibility() == 1) // if product disabled or visiblity none
|
1021 |
+
continue;
|
1022 |
+
|
1023 |
+
$cc = $product->getCategoryIds();
|
1024 |
+
if(!count($cc)) // If product not belong to any category
|
1025 |
+
continue;
|
1026 |
+
$no_exist = true;
|
1027 |
+
foreach($cc as $ctid)
|
1028 |
+
{
|
1029 |
+
if(in_array($ctid, $validCats))
|
1030 |
+
{
|
1031 |
+
$no_exist = false;
|
1032 |
+
break;
|
1033 |
+
}
|
1034 |
+
}
|
1035 |
+
if($no_exist)
|
1036 |
+
continue;
|
1037 |
+
|
1038 |
+
$qty_obj = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
1039 |
+
|
1040 |
+
if($product['type_id'] == 'configurable')
|
1041 |
+
{
|
1042 |
+
$configChildIds = array();
|
1043 |
+
$configChildIds = Mage::getModel('catalog/product_type_configurable')
|
1044 |
+
->getChildrenIds($product->getId());
|
1045 |
+
if(!count($configChildIds[0]))
|
1046 |
+
continue;
|
1047 |
+
}
|
1048 |
+
else
|
1049 |
+
{
|
1050 |
+
$qty = $qty_obj->getQty();
|
1051 |
+
if($qty < 1) // If Quantity is zero
|
1052 |
+
continue;
|
1053 |
+
}
|
1054 |
+
|
1055 |
+
if(empty($product['stock_item']->is_in_stock))
|
1056 |
+
{
|
1057 |
+
if(!$qty_obj->is_in_stock)
|
1058 |
+
continue;
|
1059 |
+
}
|
1060 |
+
elseif($product['stock_item']->is_in_stock == 0) // Product out of stock
|
1061 |
+
continue;
|
1062 |
+
|
1063 |
+
|
1064 |
+
$productid = $product->getId();
|
1065 |
+
$product_cats = array();
|
1066 |
+
$product_cats = $product->getCategoryIds();
|
1067 |
+
|
1068 |
+
foreach($product_cats as $catId)
|
1069 |
+
{
|
1070 |
+
if(!in_array($catId, $validCats))
|
1071 |
+
continue;
|
1072 |
+
|
1073 |
+
if(array_key_exists($catId, $all_product_cats)) // If already exists in someone's parent
|
1074 |
+
continue;
|
1075 |
+
|
1076 |
+
$parentId = $catId;
|
1077 |
+
while(1)
|
1078 |
+
{
|
1079 |
+
$parentId = $this->getParent($parentId); // here should be parent ID otherwise unlimited loop
|
1080 |
+
$ii = 0;
|
1081 |
+
if($parentId === 0)
|
1082 |
+
break;
|
1083 |
+
else
|
1084 |
+
$all_product_cats[$catId][] = $parentId;
|
1085 |
+
if($ii++ == 20)
|
1086 |
+
break;
|
1087 |
+
}
|
1088 |
+
}
|
1089 |
+
|
1090 |
+
$xml .= '<product>';
|
1091 |
+
$xml .= '<product_id><![CDATA['.$productid.']]></product_id>';
|
1092 |
+
if($product['type_id'] == 'configurable')
|
1093 |
+
$xml .= '<is_configurable><![CDATA[1]]></is_configurable>';
|
1094 |
+
else
|
1095 |
+
$xml .= '<is_configurable><![CDATA[0]]></is_configurable>';
|
1096 |
+
|
1097 |
+
$xml .= '<title><![CDATA['.$this->__($product->getName()).']]>';
|
1098 |
+
$xml .= '</title>';
|
1099 |
+
|
1100 |
+
$_finalPriceInclTax = $_taxHelper->getPrice($product, $product->getFinalPrice(), 2);
|
1101 |
+
$special_price = 0;
|
1102 |
+
$special_price = $_taxHelper->getPrice($product, $product->getSpecialPrice(), 2);
|
1103 |
+
|
1104 |
+
if($bas_curncy_code != $cur_curncy_code
|
1105 |
+
and array_key_exists($bas_curncy_code, $currencyRates)
|
1106 |
+
and array_key_exists($cur_curncy_code, $currencyRates)
|
1107 |
+
)
|
1108 |
+
{
|
1109 |
+
if($special_price and strtotime($today.' 00:00:00') < strtotime($product['special_to_date']))
|
1110 |
+
{
|
1111 |
+
$store_curncy = Mage::helper('directory')->currencyConvert($special_price, $bas_curncy_code, $cur_curncy_code);
|
1112 |
+
}
|
1113 |
+
else
|
1114 |
+
{
|
1115 |
+
$store_curncy = Mage::helper('directory')->currencyConvert($_finalPriceInclTax, $bas_curncy_code, $cur_curncy_code);
|
1116 |
+
}
|
1117 |
+
}
|
1118 |
+
else
|
1119 |
+
{
|
1120 |
+
if($special_price and strtotime($today.' 00:00:00') < strtotime($product['special_to_date']))
|
1121 |
+
{
|
1122 |
+
$store_curncy = $special_price;
|
1123 |
+
}
|
1124 |
+
else
|
1125 |
+
{
|
1126 |
+
$store_curncy = $_finalPriceInclTax;
|
1127 |
+
}
|
1128 |
+
}
|
1129 |
+
$xml .= '<price><![CDATA['.round($store_curncy, 2).']]>';
|
1130 |
+
$xml .= '</price>';
|
1131 |
+
$xml .= '<currency_symbol><![CDATA['.$currency_symbol.']]>';
|
1132 |
+
$xml .= '</currency_symbol>';
|
1133 |
+
$xml .= '<shipping_info><![CDATA[]]>';
|
1134 |
+
$xml .= '</shipping_info>';
|
1135 |
+
if($product->getImage() == 'no_selection')
|
1136 |
+
{
|
1137 |
+
$xml .= '<image_small><![CDATA[]]></image_small>';
|
1138 |
+
$xml .= '<image_large><![CDATA[]]>';
|
1139 |
+
}
|
1140 |
+
else
|
1141 |
+
{
|
1142 |
+
$img_size=0;
|
1143 |
+
$imgurl_tmp = $rot_url.'media/catalog/product'.$product->getImage();
|
1144 |
+
|
1145 |
+
if(file_exists($imgurl_tmp))
|
1146 |
+
{
|
1147 |
+
$img_size = filesize($imgurl_tmp);
|
1148 |
+
if($img_size)
|
1149 |
+
{
|
1150 |
+
$xml.= '<img>'.$imgurl_tmp.'</img>';
|
1151 |
+
|
1152 |
+
$xml .= '<image_small><![CDATA['.Mage::helper('catalog/image')->init($product, 'small_image')->resize(170).']]></image_small>';
|
1153 |
+
$xml .= '<image_large><![CDATA['.Mage::helper('catalog/image')->init($product, 'image').']]>';
|
1154 |
+
}
|
1155 |
+
else
|
1156 |
+
{
|
1157 |
+
$xml .= '<image_small><![CDATA[]]></image_small>';
|
1158 |
+
$xml .= '<image_large><![CDATA[]]>';
|
1159 |
+
}
|
1160 |
+
}
|
1161 |
+
else
|
1162 |
+
{
|
1163 |
+
$xml .= '<image_small><![CDATA[]]></image_small>';
|
1164 |
+
$xml .= '<image_large><![CDATA[]]>';
|
1165 |
+
}
|
1166 |
+
}
|
1167 |
+
|
1168 |
+
$xml .= '</image_large>';
|
1169 |
+
$xml .= '<product_link><![CDATA['.$product->getProductUrl().']]>';
|
1170 |
+
$xml .= '</product_link>';
|
1171 |
+
|
1172 |
+
$xml .= '<short_description><![CDATA['.$product->getShortDescription().']]></short_description>';
|
1173 |
+
|
1174 |
+
$desc = $product->getDescription();
|
1175 |
+
if(empty($desc))
|
1176 |
+
$desc = mage::helper('catalog/output')->productAttribute($product, nl2br($product->getDescription()), 'description');
|
1177 |
+
|
1178 |
+
$xml .= '<product_detail><![CDATA['.$desc.']]>';
|
1179 |
+
$xml .= '</product_detail>';
|
1180 |
+
$xml .= '<product_tags>';
|
1181 |
+
if(array_key_exists($productid, $filtered_tags))
|
1182 |
+
$xml .= '<tag link="'.$filtered_tags[$productid]['link'].'"><![CDATA['.$filtered_tags[$productid]['name'].']]></tag>';
|
1183 |
+
|
1184 |
+
$xml .= '</product_tags>';
|
1185 |
+
|
1186 |
+
$xml .= '<category_id><![CDATA[';
|
1187 |
+
$xml_tmp = '';
|
1188 |
+
foreach($product_cats as $catId)
|
1189 |
+
{
|
1190 |
+
if(!in_array($catId, $validCats))
|
1191 |
+
continue;
|
1192 |
+
|
1193 |
+
if($root_id == $catId)
|
1194 |
+
continue;
|
1195 |
+
|
1196 |
+
$tmp_arr = array();
|
1197 |
+
if(array_key_exists($catId, $all_product_cats))
|
1198 |
+
{
|
1199 |
+
$tmp_arr = array_reverse($all_product_cats[$catId]);
|
1200 |
+
$xml_tmp .= implode('/', $tmp_arr);
|
1201 |
+
$xml_tmp .= '/'.$catId.',';
|
1202 |
+
}
|
1203 |
+
else
|
1204 |
+
{
|
1205 |
+
$xml_tmp .= $catId.',';
|
1206 |
+
}
|
1207 |
+
}
|
1208 |
+
$xml .= rtrim($xml_tmp, ',');
|
1209 |
+
$xml .= ']]></category_id>';
|
1210 |
+
|
1211 |
+
$xml .= '<multiple_images>';
|
1212 |
+
$additional_images = Mage::getModel('catalog/product')->load($productid)->getMediaGalleryImages();
|
1213 |
+
if(count($additional_images) > 0)
|
1214 |
+
{
|
1215 |
+
foreach ($additional_images as $images) {
|
1216 |
+
$xml .= '<img><![CDATA['.$images->getUrl().']]></img>';
|
1217 |
+
}
|
1218 |
+
}
|
1219 |
+
$xml .= '</multiple_images>';
|
1220 |
+
$xml .= '<attributes>';
|
1221 |
+
|
1222 |
+
// Getting Additional information
|
1223 |
+
$attributes = $product->getAttributes();
|
1224 |
+
|
1225 |
+
$data = array();
|
1226 |
+
foreach ($attributes as $attribute) {
|
1227 |
+
if ($attribute->getIsVisibleOnFront() && $attribute->getIsUserDefined()) {
|
1228 |
+
$value = $attribute->getFrontend()->getValue($product);
|
1229 |
+
|
1230 |
+
if (!$product->hasData($attribute->getAttributeCode())) {
|
1231 |
+
$value = 'N/A';
|
1232 |
+
} elseif ((string)$value == '') {
|
1233 |
+
$value = 'No';
|
1234 |
+
}
|
1235 |
+
$xml .= '<attribute label="'.$attribute->getFrontend()->getLabel().'"><![CDATA['.$value.']]></attribute>';
|
1236 |
+
}
|
1237 |
+
}
|
1238 |
+
|
1239 |
+
$xml .= '</attributes>';
|
1240 |
+
|
1241 |
+
$xml .= '</product>';
|
1242 |
+
if($tmp_count++ == 199)
|
1243 |
+
break;
|
1244 |
+
}
|
1245 |
+
if($tmp_count < 199)
|
1246 |
+
{
|
1247 |
+
$model = Mage::getModel('froomerce/config');
|
1248 |
+
|
1249 |
+
$cnfg_id = 0;
|
1250 |
+
$froomerce_config = Mage::getModel('froomerce/config')->getCollection();
|
1251 |
+
foreach($froomerce_config as $cnfig)
|
1252 |
+
{
|
1253 |
+
if($store_id == $cnfig['store_id'])
|
1254 |
+
{
|
1255 |
+
$cnfg_id = $cnfig->getId();
|
1256 |
+
break;
|
1257 |
+
}
|
1258 |
+
}
|
1259 |
+
if($cnfg_id)
|
1260 |
+
{
|
1261 |
+
$export_status = 'Exported';
|
1262 |
+
$dataa = array(
|
1263 |
+
'status'=>$export_status,
|
1264 |
+
);
|
1265 |
+
$model->setData($dataa)
|
1266 |
+
->setId($cnfg_id);
|
1267 |
+
try {
|
1268 |
+
$model->save();
|
1269 |
+
} catch (Exception $e) {
|
1270 |
+
|
1271 |
+
}
|
1272 |
+
}
|
1273 |
+
}
|
1274 |
+
|
1275 |
+
return $xml;
|
1276 |
+
}
|
1277 |
+
|
1278 |
+
protected function categoriesxml() {
|
1279 |
+
|
1280 |
+
$store_code = $this->getRequest()->getParam('store_code');
|
1281 |
+
$store_id = $this->getStoreId($store_code);
|
1282 |
+
|
1283 |
+
$root_id = Mage::app()->getStore($store_id)->getRootCategoryId();
|
1284 |
+
$root = Mage::getModel('catalog/category')->load($root_id);
|
1285 |
+
$child = $root->getAllChildren(true);
|
1286 |
+
|
1287 |
+
$validCats = $this->getEnabledCategories($store_id, $child);
|
1288 |
+
if(!count($validCats))
|
1289 |
+
return;
|
1290 |
+
|
1291 |
+
$categories = Mage::getModel('catalog/category')
|
1292 |
+
->getCollection()
|
1293 |
+
->setStoreId($store_id)
|
1294 |
+
->addAttributeToSelect('*');
|
1295 |
+
|
1296 |
+
$xml = '';
|
1297 |
+
|
1298 |
+
foreach($categories as $cate)
|
1299 |
+
{
|
1300 |
+
$name = $cate->getName();
|
1301 |
+
if(empty($name) || !in_array($cate->getId(), $validCats))
|
1302 |
+
continue;
|
1303 |
+
|
1304 |
+
$parent_id = $cate->parent_id;
|
1305 |
+
|
1306 |
+
if($parent_id == $root_id)
|
1307 |
+
$parent_id = 0;
|
1308 |
+
|
1309 |
+
$xml .= '<category>';
|
1310 |
+
$xml .= '<parent_id><![CDATA['.$parent_id.']]></parent_id>';
|
1311 |
+
$xml .= '<category_id><![CDATA['.$cate->getId().']]>';
|
1312 |
+
$xml .= '</category_id>';
|
1313 |
+
$xml .= '<category_name><![CDATA['.$name.']]>';
|
1314 |
+
$xml .= '</category_name>';
|
1315 |
+
$xml .= '</category>';
|
1316 |
+
|
1317 |
+
}
|
1318 |
+
return $xml;
|
1319 |
+
}
|
1320 |
+
|
1321 |
+
protected function getParent($cat_id = 0){
|
1322 |
+
|
1323 |
+
$store_code = $this->getRequest()->getParam('store_code');
|
1324 |
+
$website_code = $this->getWebsiteCode($store_code);
|
1325 |
+
$stores = Mage::app()->getWebsite($website_code)->getStores();
|
1326 |
+
|
1327 |
+
foreach($stores as $lang)
|
1328 |
+
{
|
1329 |
+
if($store_code == $lang->getCode())
|
1330 |
+
{
|
1331 |
+
$store_id = $lang->getId();
|
1332 |
+
break;
|
1333 |
+
}
|
1334 |
+
}
|
1335 |
+
|
1336 |
+
$root_id = Mage::app()->getStore($store_id)->getRootCategoryId();
|
1337 |
+
$parent_id_tmp = -1;
|
1338 |
+
$collection_cat = Mage::getModel('catalog/category')->getCollection();
|
1339 |
+
$collection_cat->addAttributeToFilter('entity_id',$cat_id);
|
1340 |
+
$collection_cat->addAttributeToSelect('*');
|
1341 |
+
$found = true;
|
1342 |
+
foreach($collection_cat as $tmp_cat)
|
1343 |
+
{
|
1344 |
+
$found = false;
|
1345 |
+
$parent_id_tmp = $tmp_cat->parent_id;
|
1346 |
+
}
|
1347 |
+
if($found)
|
1348 |
+
return 0;
|
1349 |
+
|
1350 |
+
if($parent_id_tmp == $root_id || $parent_id_tmp == 0 || $parent_id_tmp == 1) // if it's parent is a root category
|
1351 |
+
return 0;
|
1352 |
+
else
|
1353 |
+
return $parent_id_tmp;
|
1354 |
+
|
1355 |
+
}
|
1356 |
+
|
1357 |
+
public function getWebsiteCode($store_code = 0)
|
1358 |
+
{
|
1359 |
+
$website_code='';
|
1360 |
+
$websites = Mage::app()->getWebsites(true);
|
1361 |
+
foreach ($websites as $website){
|
1362 |
+
if(!$website->getId())
|
1363 |
+
continue;
|
1364 |
+
|
1365 |
+
foreach ($website->getGroups() as $group) {
|
1366 |
+
|
1367 |
+
foreach($group->getStores() as $lang)
|
1368 |
+
{
|
1369 |
+
if($store_code == $lang->getCode())
|
1370 |
+
{
|
1371 |
+
return $website_code = $website->getCode();
|
1372 |
+
}
|
1373 |
+
}
|
1374 |
+
}
|
1375 |
+
}
|
1376 |
+
return 0;
|
1377 |
+
}
|
1378 |
+
|
1379 |
+
function getStructure($indices, $index, $attributes) {
|
1380 |
+
if ($index < count($indices)) {
|
1381 |
+
$group_by = $indices[$index];
|
1382 |
+
$values = array();
|
1383 |
+
foreach ($attributes as $attribute) {
|
1384 |
+
if(!empty($attribute[$group_by])){
|
1385 |
+
if (array_key_exists($attribute[$group_by], $values)) {
|
1386 |
+
$values[$attribute[$group_by]][] = $attribute;
|
1387 |
+
} else {
|
1388 |
+
$values[$attribute[$group_by]] = array($attribute);
|
1389 |
+
}
|
1390 |
+
}
|
1391 |
+
}
|
1392 |
+
foreach($values as $key => $value){
|
1393 |
+
$values[$key] = $this->getStructure($indices, $index+1, $value);
|
1394 |
+
}
|
1395 |
+
$return=array(
|
1396 |
+
'attribute' => $group_by,
|
1397 |
+
'values' => $values
|
1398 |
+
);
|
1399 |
+
return $return;
|
1400 |
+
} else {
|
1401 |
+
return array('product_id' => $attributes[0]['product_id'],'price' => $attributes[0]['price']);
|
1402 |
+
}
|
1403 |
+
}
|
1404 |
+
|
1405 |
+
// Getting All Available Tags
|
1406 |
+
public function getAllTags()
|
1407 |
+
{
|
1408 |
+
$store_code = $this->getRequest()->getParam('store_code');
|
1409 |
+
$store_id = $this->getStoreId($store_code);
|
1410 |
+
|
1411 |
+
$collectTag = Mage::getResourceModel('tag/tag_collection');
|
1412 |
+
$tags_array = array();
|
1413 |
+
foreach ($collectTag as $_tag):
|
1414 |
+
if($_tag['status'] and $_tag['first_store_id'] == $store_id)
|
1415 |
+
{
|
1416 |
+
$tags_array[$_tag->getId()] = $_tag->getTaggedProductsUrl();
|
1417 |
+
}
|
1418 |
+
endforeach;
|
1419 |
+
return $tags_array;
|
1420 |
+
}
|
1421 |
+
public function getStoreCode($storeid = 0) {
|
1422 |
+
if($storeid)
|
1423 |
+
{
|
1424 |
+
$website_name='';
|
1425 |
+
$websites = Mage::app()->getWebsites(true);
|
1426 |
+
foreach ($websites as $website){
|
1427 |
+
if(!$website->getId())
|
1428 |
+
continue;
|
1429 |
+
|
1430 |
+
foreach ($website->getGroups() as $group) {
|
1431 |
+
foreach($group->getStores() as $lang)
|
1432 |
+
{
|
1433 |
+
if($storeid == $lang->getId())
|
1434 |
+
{
|
1435 |
+
$storecode = $lang->getCode();
|
1436 |
+
return $storecode;
|
1437 |
+
}
|
1438 |
+
}
|
1439 |
+
}
|
1440 |
+
}
|
1441 |
+
return false;
|
1442 |
+
}
|
1443 |
+
}
|
1444 |
+
|
1445 |
+
public function getStoreId($storecode = 0) {
|
1446 |
+
if($storecode)
|
1447 |
+
{
|
1448 |
+
$website_name='';
|
1449 |
+
$websites = Mage::app()->getWebsites(true);
|
1450 |
+
foreach ($websites as $website){
|
1451 |
+
if(!$website->getId())
|
1452 |
+
continue;
|
1453 |
+
|
1454 |
+
foreach ($website->getGroups() as $group) {
|
1455 |
+
foreach($group->getStores() as $lang)
|
1456 |
+
{
|
1457 |
+
if($storecode == $lang->getCode())
|
1458 |
+
{
|
1459 |
+
$storeid = $lang->getId();
|
1460 |
+
return $storeid;
|
1461 |
+
}
|
1462 |
+
}
|
1463 |
+
}
|
1464 |
+
}
|
1465 |
+
return false;
|
1466 |
+
}
|
1467 |
+
}
|
1468 |
+
|
1469 |
+
public function getEnabledCategories($store_id, $child_tmp = array())
|
1470 |
+
{
|
1471 |
+
$categories = Mage::getModel('catalog/category')
|
1472 |
+
->getCollection()
|
1473 |
+
->setStoreId($store_id)
|
1474 |
+
->addAttributeToFilter('is_active', 1)
|
1475 |
+
//->addAttributeToFilter('include_in_menu', 1)
|
1476 |
+
->addAttributeToSelect('*');
|
1477 |
+
|
1478 |
+
$return = array();
|
1479 |
+
foreach($categories as $cats)
|
1480 |
+
{
|
1481 |
+
$parent_id = $cats->parent_id;
|
1482 |
+
if(in_array($cats->getId(), $child_tmp) and $parent_id != 1)
|
1483 |
+
{
|
1484 |
+
$parent_cat_tmp = Mage::getModel('catalog/category')->load($parent_id);
|
1485 |
+
if($parent_cat_tmp->is_active)
|
1486 |
+
{
|
1487 |
+
$return[] = $cats->getId();
|
1488 |
+
}
|
1489 |
+
}
|
1490 |
+
}
|
1491 |
+
return $return;
|
1492 |
+
}
|
1493 |
+
|
1494 |
+
public function testAction()
|
1495 |
+
{
|
1496 |
+
$modules = Mage::getConfig()->getNode('modules')->children();
|
1497 |
+
$modulesArray = (array)$modules;
|
1498 |
+
echo '<pre>';
|
1499 |
+
print_r($modulesArray['OrganicInternet_SimpleConfigurableProducts']);
|
1500 |
+
exit;
|
1501 |
+
}
|
1502 |
+
|
1503 |
+
}
|
app/code/local/Addon/Froomerce/etc/adminhtml.xml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" ?>
|
2 |
+
<config>
|
3 |
+
<menu>
|
4 |
+
<froomerce translate="title" module="froomerce">
|
5 |
+
<title>Froomerce</title>
|
6 |
+
<sort_order>70</sort_order>
|
7 |
+
<!--<action>froomerce/adminhtml_froomerce</action>-->
|
8 |
+
<children>
|
9 |
+
<credentials translate="title" module="froomerce">
|
10 |
+
<title>Settings</title>
|
11 |
+
<sort_order>70</sort_order>
|
12 |
+
<action>froomerce/adminhtml_froomerce</action>
|
13 |
+
</credentials>
|
14 |
+
<facebook translate="title" module="froomerce">
|
15 |
+
<title>Facebook</title>
|
16 |
+
<sort_order>71</sort_order>
|
17 |
+
<action>froomerce/adminhtml_froomerce/facebook</action>
|
18 |
+
</facebook>
|
19 |
+
</children>
|
20 |
+
</froomerce>
|
21 |
+
</menu>
|
22 |
+
</config>
|
app/code/local/Addon/Froomerce/etc/config.xml
ADDED
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Addon_Froomerce>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Addon_Froomerce>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<froomerce>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Addon_Froomerce</module>
|
14 |
+
<frontName>froomerce</frontName>
|
15 |
+
</args>
|
16 |
+
</froomerce>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<froomerce>
|
21 |
+
<file>froomerce.xml</file>
|
22 |
+
</froomerce>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<admin>
|
27 |
+
<routers>
|
28 |
+
<froomerce>
|
29 |
+
<use>admin</use>
|
30 |
+
<args>
|
31 |
+
<module>Addon_Froomerce</module>
|
32 |
+
<frontName>froomerce</frontName>
|
33 |
+
</args>
|
34 |
+
</froomerce>
|
35 |
+
</routers>
|
36 |
+
</admin>
|
37 |
+
<adminhtml>
|
38 |
+
|
39 |
+
<menu>
|
40 |
+
<froomerce translate="title" module="froomerce">
|
41 |
+
<title>Froomerce</title>
|
42 |
+
<sort_order>70</sort_order>
|
43 |
+
<depends>
|
44 |
+
<module>Addon_Froomerce</module>
|
45 |
+
</depends>
|
46 |
+
<children>
|
47 |
+
<credentials translate="title" module="froomerce">
|
48 |
+
<title>Settings</title>
|
49 |
+
<sort_order>70</sort_order>
|
50 |
+
<action>froomerce/adminhtml_froomerce</action>
|
51 |
+
</credentials>
|
52 |
+
<facebook translate="title" module="froomerce">
|
53 |
+
<title>Facebook</title>
|
54 |
+
<sort_order>71</sort_order>
|
55 |
+
<action>froomerce/adminhtml_froomerce/facebook</action>
|
56 |
+
</facebook>
|
57 |
+
</children>
|
58 |
+
</froomerce>
|
59 |
+
</menu>
|
60 |
+
|
61 |
+
<!-- <menu>
|
62 |
+
<froomerce module="froomerce">
|
63 |
+
<title>Froomerce</title>
|
64 |
+
<sort_order>71</sort_order>
|
65 |
+
<action>froomerce/adminhtml_froomerce</action>
|
66 |
+
<children>
|
67 |
+
<items module="froomerce">
|
68 |
+
<title>Credentials</title>
|
69 |
+
<sort_order>10</sort_order>
|
70 |
+
<action>froomerce/adminhtml_froomerce</action>
|
71 |
+
</items>
|
72 |
+
</children>
|
73 |
+
|
74 |
+
</froomerce>
|
75 |
+
</menu>-->
|
76 |
+
<acl>
|
77 |
+
<resources>
|
78 |
+
<all>
|
79 |
+
<title>Allow Everything</title>
|
80 |
+
</all>
|
81 |
+
<admin>
|
82 |
+
<children>
|
83 |
+
<Addon_Froomerce>
|
84 |
+
<title>Froomerce Module</title>
|
85 |
+
<sort_order>10</sort_order>
|
86 |
+
</Addon_Froomerce>
|
87 |
+
</children>
|
88 |
+
</admin>
|
89 |
+
</resources>
|
90 |
+
</acl>
|
91 |
+
<layout>
|
92 |
+
<updates>
|
93 |
+
<froomerce>
|
94 |
+
<file>froomerce.xml</file>
|
95 |
+
</froomerce>
|
96 |
+
</updates>
|
97 |
+
</layout>
|
98 |
+
</adminhtml>
|
99 |
+
<global>
|
100 |
+
<models>
|
101 |
+
<froomerce>
|
102 |
+
<class>Addon_Froomerce_Model</class>
|
103 |
+
<resourceModel>froomerce_mysql4</resourceModel>
|
104 |
+
</froomerce>
|
105 |
+
<froomerce_mysql4>
|
106 |
+
<class>Addon_Froomerce_Model_Mysql4</class>
|
107 |
+
<entities>
|
108 |
+
<froomerce_users>
|
109 |
+
<table>froomerce_users</table>
|
110 |
+
</froomerce_users>
|
111 |
+
<froomerce_config>
|
112 |
+
<table>froomerce_config</table>
|
113 |
+
</froomerce_config>
|
114 |
+
<froomerce_products>
|
115 |
+
<table>froomerce_products</table>
|
116 |
+
</froomerce_products>
|
117 |
+
</entities>
|
118 |
+
</froomerce_mysql4>
|
119 |
+
<!--
|
120 |
+
<catalog_resource_eav_mysql4>
|
121 |
+
<rewrite>
|
122 |
+
<product_collection>Addon_Froomerce_Model_Resource_Eav_Mysql4_Product_Collection</product_collection>
|
123 |
+
</rewrite>
|
124 |
+
</catalog_resource_eav_mysql4>
|
125 |
+
-->
|
126 |
+
</models>
|
127 |
+
|
128 |
+
<events>
|
129 |
+
<checkout_submit_all_after>
|
130 |
+
<observers>
|
131 |
+
<addon_froomerce_observer>
|
132 |
+
<type>singleton</type>
|
133 |
+
<class>Addon_Froomerce_Model_Observer</class>
|
134 |
+
<method>checkoutAfter</method>
|
135 |
+
</addon_froomerce_observer>
|
136 |
+
</observers>
|
137 |
+
</checkout_submit_all_after>
|
138 |
+
|
139 |
+
<catalog_product_save_after>
|
140 |
+
<observers>
|
141 |
+
<addon_froomerce_observer>
|
142 |
+
<type>model</type>
|
143 |
+
<class>Addon_Froomerce_Model_Observer</class>
|
144 |
+
<method>sendNewProductRequest</method>
|
145 |
+
</addon_froomerce_observer>
|
146 |
+
</observers>
|
147 |
+
</catalog_product_save_after>
|
148 |
+
|
149 |
+
</events>
|
150 |
+
|
151 |
+
<resources>
|
152 |
+
<froomerce_setup>
|
153 |
+
<setup>
|
154 |
+
<module>Addon_Froomerce</module>
|
155 |
+
</setup>
|
156 |
+
<connection>
|
157 |
+
<use>core_setup</use>
|
158 |
+
</connection>
|
159 |
+
</froomerce_setup>
|
160 |
+
<froomerce_write>
|
161 |
+
<connection>
|
162 |
+
<use>core_write</use>
|
163 |
+
</connection>
|
164 |
+
</froomerce_write>
|
165 |
+
<froomerce_read>
|
166 |
+
<connection>
|
167 |
+
<use>core_read</use>
|
168 |
+
</connection>
|
169 |
+
</froomerce_read>
|
170 |
+
</resources>
|
171 |
+
<blocks>
|
172 |
+
<froomerce>
|
173 |
+
<class>Addon_Froomerce_Block</class>
|
174 |
+
</froomerce>
|
175 |
+
<froomerce1>
|
176 |
+
<class>Addon_Froomerce_Block</class>
|
177 |
+
</froomerce1>
|
178 |
+
</blocks>
|
179 |
+
<helpers>
|
180 |
+
<froomerce>
|
181 |
+
<class>Addon_Froomerce_Helper</class>
|
182 |
+
</froomerce>
|
183 |
+
</helpers>
|
184 |
+
</global>
|
185 |
+
</config>
|
app/code/local/Addon/Froomerce/sql/Froomerce_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
-- DROP TABLE IF EXISTS {$this->getTable('froomerce_users')};
|
9 |
+
CREATE TABLE {$this->getTable('froomerce_users')} (
|
10 |
+
`user_id` int(100) unsigned NOT NULL AUTO_INCREMENT,
|
11 |
+
`email` varchar(255) NOT NULL DEFAULT '',
|
12 |
+
`password` varchar(255) NOT NULL DEFAULT '',
|
13 |
+
`froomerce_user_id` int(100) NOT NULL DEFAULT '0',
|
14 |
+
PRIMARY KEY (`user_id`)
|
15 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
16 |
+
|
17 |
+
");
|
18 |
+
|
19 |
+
$installer->run("
|
20 |
+
-- DROP TABLE IF EXISTS {$this->getTable('froomerce_config')};
|
21 |
+
CREATE TABLE {$this->getTable('froomerce_config')} (
|
22 |
+
`id` int(100) unsigned NOT NULL AUTO_INCREMENT,
|
23 |
+
`region_id` int(100) NOT NULL DEFAULT '0',
|
24 |
+
`group_id` varchar(200) NOT NULL,
|
25 |
+
`store_id` int(100) NOT NULL DEFAULT '0',
|
26 |
+
`froomerce_shop_id` int(100) NOT NULL DEFAULT '0',
|
27 |
+
`status` enum('Inprogress','Exported') NOT NULL,
|
28 |
+
PRIMARY KEY (`id`)
|
29 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
30 |
+
");
|
31 |
+
|
32 |
+
$installer->run("
|
33 |
+
-- DROP TABLE IF EXISTS {$this->getTable('froomerce_config')};
|
34 |
+
CREATE TABLE {$this->getTable('froomerce_products')} (
|
35 |
+
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
36 |
+
`store_id` bigint(20) NOT NULL,
|
37 |
+
`product_id` bigint(20) NOT NULL,
|
38 |
+
`status` tinyint(5) NOT NULL,
|
39 |
+
PRIMARY KEY (`id`),
|
40 |
+
UNIQUE KEY `product_id` (`product_id`)
|
41 |
+
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
42 |
+
");
|
43 |
+
|
44 |
+
$installer->endSetup();
|
45 |
+
|
46 |
+
/*
|
47 |
+
|
48 |
+
|
49 |
+
|
50 |
+
*/
|
app/design/adminhtml/default/default/layout/froomerce.xml
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<froomerce_adminhtml_froomerce_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="froomerce/adminhtml_froomerce" name="froomerce" />
|
6 |
+
</reference>
|
7 |
+
</froomerce_adminhtml_froomerce_index>
|
8 |
+
|
9 |
+
<froomerce_adminhtml_froomerce_export>
|
10 |
+
<reference name="content">
|
11 |
+
<block type="froomerce/adminhtml_froomerce/export" name="froomerce_export" />
|
12 |
+
</reference>
|
13 |
+
</froomerce_adminhtml_froomerce_export>
|
14 |
+
|
15 |
+
<froomerce_adminhtml_froomerce_check>
|
16 |
+
<reference name="content">
|
17 |
+
<block type="froomerce/adminhtml_froomerce/check" name="froomerce_check">
|
18 |
+
<block type="adminhtml/store_switcher" name="store_switcher" as="store_switcher" template="addon/froomerce/switcher.phtml">
|
19 |
+
<action method="setUseConfirm"><params>0</params></action>
|
20 |
+
</block>
|
21 |
+
</block>
|
22 |
+
<!-- template="addon/froomerce/grid.phtml" -->
|
23 |
+
</reference>
|
24 |
+
</froomerce_adminhtml_froomerce_check>
|
25 |
+
|
26 |
+
<froomerce_adminhtml_froomerce_postwidget>
|
27 |
+
<reference name="content">
|
28 |
+
<block type="froomerce/adminhtml_froomerce/postwidget" name="froomerce_postwidget" template="addon/froomerce/grid.phtml"/>
|
29 |
+
</reference>
|
30 |
+
</froomerce_adminhtml_froomerce_postwidget>
|
31 |
+
|
32 |
+
<froomerce_adminhtml_froomerce_region>
|
33 |
+
<reference name="content">
|
34 |
+
<block type="froomerce/adminhtml_froomerce/postwidget" name="froomerce_postwidget" template="addon/froomerce/loading.phtml"/>
|
35 |
+
</reference>
|
36 |
+
</froomerce_adminhtml_froomerce_region>
|
37 |
+
|
38 |
+
<default>
|
39 |
+
<reference name="head">
|
40 |
+
<action method="addCss"><stylesheet>css/local.css</stylesheet></action>
|
41 |
+
</reference>
|
42 |
+
</default>
|
43 |
+
|
44 |
+
</layout>
|
app/design/adminhtml/default/default/template/addon/froomerce/grid.phtml
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @see Addon_Froomerce_Block_Grid
|
5 |
+
*/
|
6 |
+
?>
|
7 |
+
<?php
|
8 |
+
$credntl=$this->getCredentials();
|
9 |
+
$_url = $this->getPostUrl();
|
10 |
+
$widgetId = $this->getWidgetId();
|
11 |
+
$admin_url = $this->getAdminUrl();
|
12 |
+
$message = $this->getMessage();
|
13 |
+
$secret_token = $this->getSecrettoken();
|
14 |
+
?>
|
15 |
+
<div style="text-align:center;">
|
16 |
+
Your widget has been created, click <a id="hiddenlink" href="<?php echo $_url.'?hash='.$credntl.'&widget_id='.$widgetId.'&secret_token='.$secret_token;?>" onClick="openUrl();" target="_blank">here</a>
|
17 |
+
to post to facebook wall
|
18 |
+
</div>
|
19 |
+
|
20 |
+
<script type="text/javascript">
|
21 |
+
function openUrl()
|
22 |
+
{
|
23 |
+
window.location= '<?php echo $admin_url;?>';
|
24 |
+
}
|
25 |
+
</script>
|
app/design/adminhtml/default/default/template/addon/froomerce/loading.phtml
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package default_modern
|
23 |
+
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php
|
28 |
+
/**
|
29 |
+
* Product list template
|
30 |
+
*
|
31 |
+
* @see Mage_Catalog_Block_Product_List
|
32 |
+
*/
|
33 |
+
?>
|
34 |
+
<?php $baseURL = rtrim(Mage::getBaseUrl(), 'index.php/'); ?>
|
35 |
+
<div style="display:none" id="loading-mask">
|
36 |
+
<p id="loading_mask_loader" class="loader"><img alt="Exporting..." src="<?php echo $baseURL;?>/skin/adminhtml/default/default/images/ajax-loader-tr.gif"><br>Please wait...</p>
|
37 |
+
</div>
|
38 |
+
<script type="text/javascript">
|
39 |
+
function show()
|
40 |
+
{
|
41 |
+
alert('me');
|
42 |
+
document.getElementById('loading-mask').style.display = 'block';
|
43 |
+
return false;
|
44 |
+
}
|
45 |
+
</script>
|
app/design/adminhtml/default/default/template/addon/froomerce/product.phtml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @see Mage_Adminhtml_Block_Addon_Froomerce_Product
|
4 |
+
*/
|
5 |
+
?>
|
6 |
+
<div class="content-header">
|
7 |
+
<table cellspacing="0">
|
8 |
+
<tr>
|
9 |
+
<td style="width:50%;"><h3 class="icon-head head-products"><?php echo Mage::helper('froomerce')->__('Export as widget to Facebook') ?></h3></td>
|
10 |
+
<td class="a-right">
|
11 |
+
<?php echo $this->getButtonsHtml() ?>
|
12 |
+
</td>
|
13 |
+
</tr>
|
14 |
+
</table>
|
15 |
+
</div>
|
16 |
+
<?php
|
17 |
+
if( !$this->isSingleStoreMode() ): ?>
|
18 |
+
<?php echo $this->getChildHtml('store_switcher');?>
|
19 |
+
<?php endif;?>
|
20 |
+
<div>
|
21 |
+
<?php echo $this->getGridHtml() ?>
|
22 |
+
</div>
|
app/design/adminhtml/default/default/template/addon/froomerce/switcher.phtml
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if ($websites = $this->getWebsites()): ?>
|
2 |
+
<?php
|
3 |
+
$froomerce_config = Mage::getModel('froomerce/config')->getCollection();
|
4 |
+
$storeids = array();
|
5 |
+
foreach($froomerce_config as $cnfig)
|
6 |
+
{
|
7 |
+
if($cnfig->getRegionId())
|
8 |
+
$storeids[] = $cnfig['store_id'];
|
9 |
+
}
|
10 |
+
?>
|
11 |
+
<p class="switcher"><label for="store_switcher"><?php echo $this->__('Choose Store View') ?>:</label>
|
12 |
+
<select name="store_switcher" id="store_switcher" onchange="return switchStore(this);">
|
13 |
+
<?php foreach ($websites as $website): ?>
|
14 |
+
<?php $showWebsite=false; ?>
|
15 |
+
<?php foreach ($website->getGroups() as $group): ?>
|
16 |
+
<?php $showGroup=false; ?>
|
17 |
+
<?php foreach ($this->getStores($group) as $store): ?>
|
18 |
+
<?php if(!in_array($store->getId(), $storeids)) continue;?>
|
19 |
+
|
20 |
+
<?php if ($showWebsite == false): ?>
|
21 |
+
<?php $showWebsite = true; ?>
|
22 |
+
<optgroup label="<?php echo $website->getName() ?>"></optgroup>
|
23 |
+
<?php endif; ?>
|
24 |
+
<?php if ($showGroup == false): ?>
|
25 |
+
<?php $showGroup = true; ?>
|
26 |
+
<optgroup label=" <?php echo $group->getName() ?>">
|
27 |
+
<?php endif; ?>
|
28 |
+
<option value="<?php echo $store->getId() ?>"<?php if($this->getStoreId() == $store->getId()): ?> selected="selected"<?php endif; ?>> <?php echo $store->getName() ?></option>
|
29 |
+
<?php endforeach; ?>
|
30 |
+
<?php if ($showGroup): ?>
|
31 |
+
</optgroup>
|
32 |
+
<?php endif; ?>
|
33 |
+
<?php endforeach; ?>
|
34 |
+
<?php endforeach; ?>
|
35 |
+
</select>
|
36 |
+
</p>
|
37 |
+
<script type="text/javascript">
|
38 |
+
function switchStore(obj){
|
39 |
+
var storeParam = obj.value ? 'store/'+obj.value + '/' : '';
|
40 |
+
if(obj.switchParams){
|
41 |
+
storeParam+= obj.switchParams;
|
42 |
+
}
|
43 |
+
<?php if($this->getUseConfirm()): ?>
|
44 |
+
if(confirm("<?php echo $this->__('Please confirm site switching. All data that hasn\'t been saved will be lost.') ?>")){
|
45 |
+
setLocation('<?php echo $this->getSwitchUrl() ?>'+storeParam);
|
46 |
+
return true;
|
47 |
+
}
|
48 |
+
else {
|
49 |
+
obj.value = '<?php echo $this->getStoreId() ?>';
|
50 |
+
}
|
51 |
+
return false;
|
52 |
+
<?php else: ?>
|
53 |
+
setLocation('<?php echo $this->getSwitchUrl() ?>'+storeParam);
|
54 |
+
<?php endif; ?>
|
55 |
+
}
|
56 |
+
</script>
|
57 |
+
<?php endif; ?>
|
app/etc/modules/Addon_Froomerce.xml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Addon_Froomerce>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Addon_Froomerce>
|
8 |
+
</modules>
|
9 |
+
|
10 |
+
<frontend>
|
11 |
+
<routers>
|
12 |
+
<rss>
|
13 |
+
<args>
|
14 |
+
<modules>
|
15 |
+
<Addon_Froomerce after="Mage_Rss">Addon_Froomerce</Addon_Froomerce>
|
16 |
+
</modules>
|
17 |
+
</args>
|
18 |
+
</rss>
|
19 |
+
</routers>
|
20 |
+
</frontend>
|
21 |
+
|
22 |
+
</config>
|
app/locale/de_De/Addon_Froomerce.csv
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"User does not exist","User does not exist"
|
2 |
+
"Unable to save as remote authentication failed","Unable to save as remote authentication failed"
|
3 |
+
"Please select both ( Store and Region )","Please select both ( Store and Region )"
|
4 |
+
"New shop created successfully","New shop created successfully"
|
5 |
+
"Unable to Create Shop","Unable to Create Shop"
|
6 |
+
"Products Exported Successfully from","Products Exported Successfully from"
|
7 |
+
"Store View","Store View"
|
8 |
+
"Could Not Export Products","Could Not Export Products"
|
9 |
+
"Please Export Store to Froomerce first","Please Export Store to Froomerce first"
|
10 |
+
"Please Authenticate First","Please Authenticate First"
|
11 |
+
"The widget has been created \n Although the products which have not beed updated to froomerce were not included","The widget has been created \n Although the products which have not beed updated to froomerce were not included"
|
12 |
+
"Select one of your magento website to export to '.$from.'<span class="contactus">Having Problems? Contact us","Select one of your magento website to export to '.$from.'<span class="contactus">Having Problems? Contact us"
|
13 |
+
"here","here"
|
14 |
+
"Only those stores can be exported to facebook which are already exported to froomerce","Only those stores can be exported to facebook which are already exported to froomerce"
|
15 |
+
"Exporting products","Exporting products"
|
16 |
+
"<b>Select your website : </b>","<b>Select your website : </b>"
|
17 |
+
"Select Website","Select Website"
|
18 |
+
"<b>Select your magento store view to export : </b>","<b>Select your magento store view to export : </b>"
|
19 |
+
"User information","User information"
|
20 |
+
"Select one of your magento store views to export to froomerce","Select one of your magento store views to export to froomerce"
|
21 |
+
"Exported","Exported"
|
22 |
+
"<b> Choose the region that is related to your store :</b>","<b> Choose the region that is related to your store :</b>"
|
23 |
+
"<label>Export to Facebook</lable>","<label>Export to Facebook</lable>"
|
24 |
+
"Only those stores can be exported to facebook which are already exported to froomerce","Only those stores can be exported to facebook which are already exported to froomerce"
|
25 |
+
"Export Store to Facebook","Export Store to Facebook"
|
26 |
+
"<small>Not exported on froomerce yet</small>","<small>Not exported on froomerce yet</small>"
|
27 |
+
"Export","Export"
|
28 |
+
"Export Widgets to Facebook","Export Widgets to Facebook"
|
29 |
+
"No store exported on froomerce yet","No store exported on froomerce yet"
|
30 |
+
"Select one of your magento store to export to","Select one of your magento store to export to"
|
31 |
+
"<b>Select your magento store : </b>","<b>Select your magento store : </b>"
|
32 |
+
"<small>Already exported on facebook</small>","<small>Already exported on facebook</small>"
|
33 |
+
"facebook","facebook"
|
34 |
+
"froomerce","froomerce"
|
35 |
+
"Select your website :","Select your website :"
|
36 |
+
"Select Website","Select Website"
|
37 |
+
"Settings","Settings"
|
38 |
+
"Export stores to Froomerce","Export stores to Froomerce"
|
39 |
+
"Export Stores","Export Stores"
|
40 |
+
"Select Store","Select Store"
|
41 |
+
"Export to Facebook","Export to Facebook"
|
42 |
+
"<b>Export Store to Facebook</b>","<b>Export Store to Facebook</b>"
|
43 |
+
"Having Problems? Contact us","aving Problems? Contact us"
|
44 |
+
"Froomerce User","Froomerce User"
|
45 |
+
"Next","Next"
|
46 |
+
"Export to Froomerce","Export to Froomerce"
|
47 |
+
"Authenticate","Authenticate"
|
48 |
+
"Froomerce username","Froomerce username"
|
49 |
+
"Froomerce password","Froomerce password"
|
50 |
+
"Your widget has been created, click","Your widget has been created, click"
|
51 |
+
"here","here"
|
52 |
+
"to post to facebook wall","to post to facebook wall"
|
53 |
+
|
app/locale/fr_FR/Addon_Froomerce.csv
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"User does not exist","User does not exist"
|
2 |
+
"Unable to save as remote authentication failed","Unable to save as remote authentication failed"
|
3 |
+
"Please select both ( Store and Region )","Please select both ( Store and Region )"
|
4 |
+
"New shop created successfully","New shop created successfully"
|
5 |
+
"Unable to Create Shop","Unable to Create Shop"
|
6 |
+
"Products Exported Successfully from","Products Exported Successfully from"
|
7 |
+
"Store View","Store View"
|
8 |
+
"Could Not Export Products","Could Not Export Products"
|
9 |
+
"Please Export Store to Froomerce first","Please Export Store to Froomerce first"
|
10 |
+
"Please Authenticate First","Please Authenticate First"
|
11 |
+
"The widget has been created \n Although the products which have not beed updated to froomerce were not included","The widget has been created \n Although the products which have not beed updated to froomerce were not included"
|
12 |
+
"Select one of your magento website to export to '.$from.'<span class="contactus">Having Problems? Contact us","Select one of your magento website to export to '.$from.'<span class="contactus">Having Problems? Contact us"
|
13 |
+
"here","here"
|
14 |
+
"Only those stores can be exported to facebook which are already exported to froomerce","Only those stores can be exported to facebook which are already exported to froomerce"
|
15 |
+
"Exporting products","Exporting products"
|
16 |
+
"<b>Select your website : </b>","<b>Select your website : </b>"
|
17 |
+
"Select Website","Select Website"
|
18 |
+
"<b>Select your magento store view to export : </b>","<b>Select your magento store view to export : </b>"
|
19 |
+
"User information","User information"
|
20 |
+
"Select one of your magento store views to export to froomerce","Select one of your magento store views to export to froomerce"
|
21 |
+
"Exported","Exported"
|
22 |
+
"<b> Choose the region that is related to your store :</b>","<b> Choose the region that is related to your store :</b>"
|
23 |
+
"<label>Export to Facebook</lable>","<label>Export to Facebook</lable>"
|
24 |
+
"Only those stores can be exported to facebook which are already exported to froomerce","Only those stores can be exported to facebook which are already exported to froomerce"
|
25 |
+
"Export Store to Facebook","Export Store to Facebook"
|
26 |
+
"<small>Not exported on froomerce yet</small>","<small>Not exported on froomerce yet</small>"
|
27 |
+
"Export","Export"
|
28 |
+
"Export Widgets to Facebook","Export Widgets to Facebook"
|
29 |
+
"No store exported on froomerce yet","No store exported on froomerce yet"
|
30 |
+
"Select one of your magento store to export to","Select one of your magento store to export to"
|
31 |
+
"<b>Select your magento store : </b>","<b>Select your magento store : </b>"
|
32 |
+
"<small>Already exported on facebook</small>","<small>Already exported on facebook</small>"
|
33 |
+
"facebook","facebook"
|
34 |
+
"froomerce","froomerce"
|
35 |
+
"Select your website :","Select your website :"
|
36 |
+
"Select Website","Select Website"
|
37 |
+
"Settings","Settings"
|
38 |
+
"Export stores to Froomerce","Export stores to Froomerce"
|
39 |
+
"Export Stores","Export Stores"
|
40 |
+
"Select Store","Select Store"
|
41 |
+
"Export to Facebook","Export to Facebook"
|
42 |
+
"<b>Export Store to Facebook</b>","<b>Export Store to Facebook</b>"
|
43 |
+
"Having Problems? Contact us","aving Problems? Contact us"
|
44 |
+
"Froomerce User","Froomerce User"
|
45 |
+
"Next","Next"
|
46 |
+
"Export to Froomerce","Export to Froomerce"
|
47 |
+
"Authenticate","Authenticate"
|
48 |
+
"Froomerce username","Froomerce username"
|
49 |
+
"Froomerce password","Froomerce password"
|
50 |
+
"Your widget has been created, click","Your widget has been created, click"
|
51 |
+
"here","here"
|
52 |
+
"to post to facebook wall","to post to facebook wall"
|
53 |
+
|
package.xml
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Addon_Froomerce</name>
|
4 |
+
<version>0.1.3</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/OSL-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Create your store to Facebook and create product widgets for your Fan Page.</summary>
|
10 |
+
<description>F.Connect integrates your existing store with Facebook in a few steps. It not only lets you create complete Facebook store but also give you ability to post your products to your Fan Page wall. This allows you to reach your customers on Facebook directly from the wall. You can also run social campaigns to promote your products and engage customers. All of this can be done without writing a single line of code! 
|
11 |
+
<p></p>
|
12 |
+
This extensions requires you to create an account on <a href="http://froomerce.com/merchant/merchantplatform/fconnect" title="Froomerce"> Froomerce F.Connect</a>
|
13 |
+
<p></p>
|
14 |
+
<h2>Your Benefits</h2>
|
15 |
+

|
16 |
+
<h2>Easy porting of store to Facebook</h2>
|
17 |
+
You just need to install the plugin and export the store to your Page. If you have multiple stores or a multi-store architecture you can export all stores separately. 
|
18 |
+
<p></p>
|
19 |
+
<h2>Social sharing widgets</h2>
|
20 |
+
Your users can share and like products from your Fan Page. 
|
21 |
+
<p></p>
|
22 |
+
<h2>Selling or redirecting to main store</h2>
|
23 |
+
Depending on what you require, you can let users add all products to their Facebook cart or you can redirect users to go to the main site. 
|
24 |
+
<p></p>
|
25 |
+
<h2>Product widgets</h2>
|
26 |
+
You can create product widgets and post them directly on the wall. This will enable you to reach out to your Fans directly on their walls! When they like or share the widgets, their friends will also get exposure to your products. 
|
27 |
+
<p></p>
|
28 |
+
<h2>Custom verbs support</h2>
|
29 |
+
You can choose to have new custom verbs apart from “like”. For example, you can configure the store to have “Want” and “Need” buttons. 
|
30 |
+
<p></p>
|
31 |
+
<h2>Detailed Statistics</h2>
|
32 |
+
You get detailed statistics on not only the products but also demographics from Facebook Page e.g., how many males and females came on your page, what were their age groups etc. You receive weekly statistics emails. 
|
33 |
+
<p></p>
|
34 |
+
<h2>Custom campaigns</h2>
|
35 |
+
You can choose to have your own Welcome page. You can also choose to allow only users how like your page to view your store. 
|
36 |
+
<p></p>
|
37 |
+
<h2>Customizations</h2>
|
38 |
+
You can have your own design for the stores and the product widgets. 
|
39 |
+
<p></p>
|
40 |
+
<h2>Support</h2>
|
41 |
+
You get free email support for all packages. With Professional Pro packages you also get direct phone support.</description>
|
42 |
+
<notes>First stable release. 
|
43 |
+

|
44 |
+
Allows creation of Facebook stores. Multiple stores can be exported separately. 
|
45 |
+

|
46 |
+
Product widgets can be created and exported to the Fan Page wall.</notes>
|
47 |
+
<authors><author><name>Adeel Ahsan</name><user>auto-converted</user><email>adeel.ahsan@coues-solutions.de</email></author></authors>
|
48 |
+
<date>2012-01-31</date>
|
49 |
+
<time>09:50:04</time>
|
50 |
+
<contents><target name="magelocal"><dir name="Addon"><dir name="Froomerce"><dir name="Block"><dir name="Adminhtml"><dir name="Froomerce"><dir name="Edit"><dir name="Tab"><file name="Facebook.php" hash="f8486fc5e45335450f18730890ac0250"/><file name="Form.php" hash="6090bc08aa0738f0b468f44502ad08f4"/></dir><file name="Form.php" hash="68b17e08f49028758b881d8d5d34e2d2"/><file name="Tabs.php" hash="d36af9cab593884cd377b79f1a7a02c7"/></dir><dir name="Facebook"><dir name="Tab"><file name="Facebook.php" hash="fbb94d031f9c19b94115ee939ea031f9"/></dir><file name="Tabs.php" hash="85327bf39f376019991c5e57ed51a1b3"/></dir><dir name="Groups"><dir name="Tab"><file name="Form.php" hash="2728030ecd9aaf346a0d3acf1f2108aa"/></dir><file name="Form.php" hash="0076864962838e99842eee56ac497e25"/><file name="Tabs.php" hash="ac634adeeaf500efbe36540abc8b6ac2"/></dir><dir name="Region"><dir name="Tab"><file name="Form.php" hash="cee870121fdd6b667922f123342665fe"/></dir><file name="Form.php" hash="29df80b7b956905c608942aef169376b"/><file name="Tabs.php" hash="b732f6b8d832c6fe0890b4922f01d32e"/></dir><dir name="Websites"><dir name="Tab"><file name="Form.php" hash="e858ba49559840dfc7c3d7b6336fa893"/></dir><file name="Form.php" hash="f89c293008d9843d887a8ed608c92183"/><file name="Tabs.php" hash="34879fbc80c4f2fd7e1d0af007440858"/></dir><dir name="grid_backup"><file name="Grid.php" hash="5c6cb6e5b4df04bf338d421f3cf652d2"/></dir><file name="Edit.php" hash="e41113bed2b1d66212de9cb1b0d7d2fa"/><file name="Facebook.php" hash="acf7f03bb9bcddf1d6e1eaa393af2c7b"/><file name="Grid.php" hash="cbc9b46660b071f20bbb9fb88166999b"/><file name="Groups.php" hash="88e6fea6b859c579d49802a0c606da4a"/><file name="Region.php" hash="81efc36871288f2f193f973eb30547bc"/><file name="Websites.php" hash="ee3922131ced26457c083dafc775c5a8"/></dir><file name="Froomerce.php" hash="db5c3d462ca144f39ebd92c9bfbfe864"/></dir><file name="Froomerce.php" hash="c713a4e9cd3b184de1a6a25b8c3e0c77"/></dir><dir name="Helper"><file name="Data.php" hash="6707203ff90b5d40f8f13bee2e70acd0"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Config"><file name="Collection.php" hash="37fd3516387837301d724f829f5d1c9e"/></dir><dir name="Froomerce"><file name="Collection.php" hash="a6c503480dd1e6e4b0c95d5c1aa23ab1"/></dir><dir name="Products"><file name="Collection.php" hash="89a1fe79738844d1019c915343b3a972"/></dir><file name="Collection.php" hash="7786f92b360e26b0c10bec2a3777d4ff"/><file name="Config.php" hash="342579a4a764b48c29b26e869dffbe29"/><file name="Froomerce.php" hash="0e1660b813162fb1887b87a9bd1cc215"/><file name="Products.php" hash="c4538248e6afb9f9e44228d3437560b9"/></dir><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><dir name="Product"><file name="Collection.php" hash="3c9abfc50bf0ff0482920e8590d9cf3e"/></dir></dir></dir></dir><file name="Config.php" hash="0627048fa6637c9e06b57f7ac9697b66"/><file name="Froomerce.php" hash="51cc34a7063fa6763d4d551d49e91866"/><file name="Observer.php" hash="330756a25158d7f054323cbd2cfff4d5"/><file name="Products.php" hash="4a90c0d82dce429c274b7bda741cea09"/><file name="Status.php" hash="d23e21e0f558bb61492cb9a5e313eb1b"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="FroomerceController.php" hash="da48b3d439899df4215c5e960bf2b615"/></dir><file name="IndexController.php" hash="3797e5043e745b91ca908c22bb88cbf2"/><file name="RssController.php" hash="1057c5449d1d64d2d7f08e519bf87e42"/></dir><dir name="etc"><file name="adminhtml.xml" hash="a73c67900bce654999789c6ddfe8cdef"/><file name="config.xml" hash="08badc393706c1c3cedfacd6ee501e2f"/></dir><dir name="sql"><dir name="Froomerce_setup"><file name="mysql4-install-0.1.0.php" hash="7d6a66ec707eba21f1538160ad9a2910"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Addon_Froomerce.xml" hash="8c6d06981b56ff692e7f3da24328e7d4"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="addon"><dir name="froomerce"><file name="grid.phtml" hash="bbd8ef939257e66330fb5474cb5a64f0"/><file name="loading.phtml" hash="7529ba0590a84cd2ec753a7436ff62a5"/><file name="product.phtml" hash="d922ff2449a18666577a3eb7563f23c7"/><file name="switcher.phtml" hash="d671b6cdc213cd74c101e94451dc4b26"/></dir></dir></dir><dir name="layout"><file name="froomerce.xml" hash="daa69aacf0e70988d0dce52de2bad697"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="css"><file name="local.css" hash="88ced81b9d7f03a40043534dface2e7c"/></dir><dir name="images"><file name="joinbottom.gif" hash="4b3daa7f2cc584f1aac0d142275d7cba"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="de_De"><file name="Addon_Froomerce.csv" hash="f4e41f905a1a6b8faac8fff63688e02f"/></dir><dir name="fr_FR"><file name="Addon_Froomerce.csv" hash="f4e41f905a1a6b8faac8fff63688e02f"/></dir></target></contents>
|
51 |
+
<compatible/>
|
52 |
+
<dependencies/>
|
53 |
+
</package>
|
skin/adminhtml/default/default/css/local.css
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#froomerce_region label {
|
2 |
+
width:292px;
|
3 |
+
}
|
4 |
+
|
5 |
+
#froomerce_form label {
|
6 |
+
width:292px;
|
7 |
+
}
|
8 |
+
|
9 |
+
#froomerce_form label .alert {
|
10 |
+
width:515px;
|
11 |
+
}
|
12 |
+
#froomerce_region label .alert {
|
13 |
+
width:515px;
|
14 |
+
}
|
15 |
+
|
16 |
+
.entry-edit span.contactus {
|
17 |
+
float:right;
|
18 |
+
color:#FFF;
|
19 |
+
}
|
20 |
+
.head-edit-form {
|
21 |
+
width:100% !important;
|
22 |
+
}
|
skin/adminhtml/default/default/images/joinbottom.gif
ADDED
Binary file
|