Version Notes
Free Version
Download this release
Release Info
Developer | Magento Core Team |
Extension | FacebookProductDirectoryCommunity |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/local/Magestore/Facebook/Block/Adminhtml/Facebook.php +12 -0
- app/code/local/Magestore/Facebook/Block/Adminhtml/Facebook/Edit.php +45 -0
- app/code/local/Magestore/Facebook/Block/Adminhtml/Facebook/Edit/Form.php +19 -0
- app/code/local/Magestore/Facebook/Block/Adminhtml/Facebook/Edit/Tab/Form.php +58 -0
- app/code/local/Magestore/Facebook/Block/Adminhtml/Facebook/Edit/Tabs.php +24 -0
- app/code/local/Magestore/Facebook/Block/Adminhtml/Facebook/Grid.php +116 -0
- app/code/local/Magestore/Facebook/Block/Facebook.php +17 -0
- app/code/local/Magestore/Facebook/Helper/Data.php +56 -0
- app/code/local/Magestore/Facebook/Model/Export.php +177 -0
- app/code/local/Magestore/Facebook/Model/Facebook.php +25 -0
- app/code/local/Magestore/Facebook/Model/Mysql4/Facebook.php +10 -0
- app/code/local/Magestore/Facebook/Model/Mysql4/Facebook/Collection.php +10 -0
- app/code/local/Magestore/Facebook/Model/Status.php +15 -0
- app/code/local/Magestore/Facebook/controllers/Adminhtml/FacebookController.php +214 -0
- app/code/local/Magestore/Facebook/controllers/IndexController.php +85 -0
- app/code/local/Magestore/Facebook/etc/config.xml +147 -0
- app/code/local/Magestore/Facebook/etc/system.xml +109 -0
- app/etc/modules/Magestore_Facebook.xml +9 -0
- package.xml +20 -0
app/code/local/Magestore/Facebook/Block/Adminhtml/Facebook.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Magestore_Facebook_Block_Adminhtml_Facebook extends Mage_Adminhtml_Block_Widget_Grid_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->_controller = 'adminhtml_facebook';
|
7 |
+
$this->_blockGroup = 'facebook';
|
8 |
+
$this->_headerText = Mage::helper('facebook')->__('Item Manager');
|
9 |
+
$this->_addButtonLabel = Mage::helper('facebook')->__('Add Item');
|
10 |
+
parent::__construct();
|
11 |
+
}
|
12 |
+
}
|
app/code/local/Magestore/Facebook/Block/Adminhtml/Facebook/Edit.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Facebook_Block_Adminhtml_Facebook_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
|
9 |
+
$this->_objectId = 'id';
|
10 |
+
$this->_blockGroup = 'facebook';
|
11 |
+
$this->_controller = 'adminhtml_facebook';
|
12 |
+
|
13 |
+
$this->_updateButton('save', 'label', Mage::helper('facebook')->__('Save Item'));
|
14 |
+
$this->_updateButton('delete', 'label', Mage::helper('facebook')->__('Delete Item'));
|
15 |
+
|
16 |
+
$this->_addButton('saveandcontinue', array(
|
17 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
18 |
+
'onclick' => 'saveAndContinueEdit()',
|
19 |
+
'class' => 'save',
|
20 |
+
), -100);
|
21 |
+
|
22 |
+
$this->_formScripts[] = "
|
23 |
+
function toggleEditor() {
|
24 |
+
if (tinyMCE.getInstanceById('facebook_content') == null) {
|
25 |
+
tinyMCE.execCommand('mceAddControl', false, 'facebook_content');
|
26 |
+
} else {
|
27 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'facebook_content');
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
function saveAndContinueEdit(){
|
32 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
33 |
+
}
|
34 |
+
";
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getHeaderText()
|
38 |
+
{
|
39 |
+
if( Mage::registry('facebook_data') && Mage::registry('facebook_data')->getId() ) {
|
40 |
+
return Mage::helper('facebook')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('facebook_data')->getTitle()));
|
41 |
+
} else {
|
42 |
+
return Mage::helper('facebook')->__('Add Item');
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
app/code/local/Magestore/Facebook/Block/Adminhtml/Facebook/Edit/Form.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Facebook_Block_Adminhtml_Facebook_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form(array(
|
8 |
+
'id' => 'edit_form',
|
9 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
10 |
+
'method' => 'post',
|
11 |
+
'enctype' => 'multipart/form-data'
|
12 |
+
)
|
13 |
+
);
|
14 |
+
|
15 |
+
$form->setUseContainer(true);
|
16 |
+
$this->setForm($form);
|
17 |
+
return parent::_prepareForm();
|
18 |
+
}
|
19 |
+
}
|
app/code/local/Magestore/Facebook/Block/Adminhtml/Facebook/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Facebook_Block_Adminhtml_Facebook_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form();
|
8 |
+
$this->setForm($form);
|
9 |
+
$fieldset = $form->addFieldset('facebook_form', array('legend'=>Mage::helper('facebook')->__('Item information')));
|
10 |
+
|
11 |
+
$fieldset->addField('title', 'text', array(
|
12 |
+
'label' => Mage::helper('facebook')->__('Title'),
|
13 |
+
'class' => 'required-entry',
|
14 |
+
'required' => true,
|
15 |
+
'name' => 'title',
|
16 |
+
));
|
17 |
+
|
18 |
+
$fieldset->addField('filename', 'file', array(
|
19 |
+
'label' => Mage::helper('facebook')->__('File'),
|
20 |
+
'required' => false,
|
21 |
+
'name' => 'filename',
|
22 |
+
));
|
23 |
+
|
24 |
+
$fieldset->addField('status', 'select', array(
|
25 |
+
'label' => Mage::helper('facebook')->__('Status'),
|
26 |
+
'name' => 'status',
|
27 |
+
'values' => array(
|
28 |
+
array(
|
29 |
+
'value' => 1,
|
30 |
+
'label' => Mage::helper('facebook')->__('Enabled'),
|
31 |
+
),
|
32 |
+
|
33 |
+
array(
|
34 |
+
'value' => 2,
|
35 |
+
'label' => Mage::helper('facebook')->__('Disabled'),
|
36 |
+
),
|
37 |
+
),
|
38 |
+
));
|
39 |
+
|
40 |
+
$fieldset->addField('content', 'editor', array(
|
41 |
+
'name' => 'content',
|
42 |
+
'label' => Mage::helper('facebook')->__('Content'),
|
43 |
+
'title' => Mage::helper('facebook')->__('Content'),
|
44 |
+
'style' => 'width:700px; height:500px;',
|
45 |
+
'wysiwyg' => false,
|
46 |
+
'required' => true,
|
47 |
+
));
|
48 |
+
|
49 |
+
if ( Mage::getSingleton('adminhtml/session')->getFacebookData() )
|
50 |
+
{
|
51 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getFacebookData());
|
52 |
+
Mage::getSingleton('adminhtml/session')->setFacebookData(null);
|
53 |
+
} elseif ( Mage::registry('facebook_data') ) {
|
54 |
+
$form->setValues(Mage::registry('facebook_data')->getData());
|
55 |
+
}
|
56 |
+
return parent::_prepareForm();
|
57 |
+
}
|
58 |
+
}
|
app/code/local/Magestore/Facebook/Block/Adminhtml/Facebook/Edit/Tabs.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Facebook_Block_Adminhtml_Facebook_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('facebook_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle(Mage::helper('facebook')->__('Item Information'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$this->addTab('form_section', array(
|
17 |
+
'label' => Mage::helper('facebook')->__('Item Information'),
|
18 |
+
'title' => Mage::helper('facebook')->__('Item Information'),
|
19 |
+
'content' => $this->getLayout()->createBlock('facebook/adminhtml_facebook_edit_tab_form')->toHtml(),
|
20 |
+
));
|
21 |
+
|
22 |
+
return parent::_beforeToHtml();
|
23 |
+
}
|
24 |
+
}
|
app/code/local/Magestore/Facebook/Block/Adminhtml/Facebook/Grid.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Facebook_Block_Adminhtml_Facebook_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('facebookGrid');
|
9 |
+
$this->setDefaultSort('facebook_id');
|
10 |
+
$this->setDefaultDir('ASC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _prepareCollection()
|
15 |
+
{
|
16 |
+
$collection = Mage::getModel('facebook/facebook')->getCollection();
|
17 |
+
$this->setCollection($collection);
|
18 |
+
return parent::_prepareCollection();
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _prepareColumns()
|
22 |
+
{
|
23 |
+
$this->addColumn('facebook_id', array(
|
24 |
+
'header' => Mage::helper('facebook')->__('ID'),
|
25 |
+
'align' =>'right',
|
26 |
+
'width' => '50px',
|
27 |
+
'index' => 'facebook_id',
|
28 |
+
));
|
29 |
+
|
30 |
+
$this->addColumn('title', array(
|
31 |
+
'header' => Mage::helper('facebook')->__('Title'),
|
32 |
+
'align' =>'left',
|
33 |
+
'index' => 'title',
|
34 |
+
));
|
35 |
+
|
36 |
+
/*
|
37 |
+
$this->addColumn('content', array(
|
38 |
+
'header' => Mage::helper('facebook')->__('Item Content'),
|
39 |
+
'width' => '150px',
|
40 |
+
'index' => 'content',
|
41 |
+
));
|
42 |
+
*/
|
43 |
+
|
44 |
+
$this->addColumn('status', array(
|
45 |
+
'header' => Mage::helper('facebook')->__('Status'),
|
46 |
+
'align' => 'left',
|
47 |
+
'width' => '80px',
|
48 |
+
'index' => 'status',
|
49 |
+
'type' => 'options',
|
50 |
+
'options' => array(
|
51 |
+
1 => 'Enabled',
|
52 |
+
2 => 'Disabled',
|
53 |
+
),
|
54 |
+
));
|
55 |
+
|
56 |
+
$this->addColumn('action',
|
57 |
+
array(
|
58 |
+
'header' => Mage::helper('facebook')->__('Action'),
|
59 |
+
'width' => '100',
|
60 |
+
'type' => 'action',
|
61 |
+
'getter' => 'getId',
|
62 |
+
'actions' => array(
|
63 |
+
array(
|
64 |
+
'caption' => Mage::helper('facebook')->__('Edit'),
|
65 |
+
'url' => array('base'=> '*/*/edit'),
|
66 |
+
'field' => 'id'
|
67 |
+
)
|
68 |
+
),
|
69 |
+
'filter' => false,
|
70 |
+
'sortable' => false,
|
71 |
+
'index' => 'stores',
|
72 |
+
'is_system' => true,
|
73 |
+
));
|
74 |
+
|
75 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('facebook')->__('CSV'));
|
76 |
+
$this->addExportType('*/*/exportXml', Mage::helper('facebook')->__('XML'));
|
77 |
+
|
78 |
+
return parent::_prepareColumns();
|
79 |
+
}
|
80 |
+
|
81 |
+
protected function _prepareMassaction()
|
82 |
+
{
|
83 |
+
$this->setMassactionIdField('facebook_id');
|
84 |
+
$this->getMassactionBlock()->setFormFieldName('facebook');
|
85 |
+
|
86 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
87 |
+
'label' => Mage::helper('facebook')->__('Delete'),
|
88 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
89 |
+
'confirm' => Mage::helper('facebook')->__('Are you sure?')
|
90 |
+
));
|
91 |
+
|
92 |
+
$statuses = Mage::getSingleton('facebook/status')->getOptionArray();
|
93 |
+
|
94 |
+
array_unshift($statuses, array('label'=>'', 'value'=>''));
|
95 |
+
$this->getMassactionBlock()->addItem('status', array(
|
96 |
+
'label'=> Mage::helper('facebook')->__('Change status'),
|
97 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
98 |
+
'additional' => array(
|
99 |
+
'visibility' => array(
|
100 |
+
'name' => 'status',
|
101 |
+
'type' => 'select',
|
102 |
+
'class' => 'required-entry',
|
103 |
+
'label' => Mage::helper('facebook')->__('Status'),
|
104 |
+
'values' => $statuses
|
105 |
+
)
|
106 |
+
)
|
107 |
+
));
|
108 |
+
return $this;
|
109 |
+
}
|
110 |
+
|
111 |
+
public function getRowUrl($row)
|
112 |
+
{
|
113 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
114 |
+
}
|
115 |
+
|
116 |
+
}
|
app/code/local/Magestore/Facebook/Block/Facebook.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Magestore_Facebook_Block_Facebook extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
public function _prepareLayout()
|
5 |
+
{
|
6 |
+
return parent::_prepareLayout();
|
7 |
+
}
|
8 |
+
|
9 |
+
public function getFacebook()
|
10 |
+
{
|
11 |
+
if (!$this->hasData('facebook')) {
|
12 |
+
$this->setData('facebook', Mage::registry('facebook'));
|
13 |
+
}
|
14 |
+
return $this->getData('facebook');
|
15 |
+
|
16 |
+
}
|
17 |
+
}
|
app/code/local/Magestore/Facebook/Helper/Data.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Facebook_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
public function getDataToSend()
|
6 |
+
{
|
7 |
+
$data = Mage::getStoreConfig('facebook/general');
|
8 |
+
|
9 |
+
$data['base_url'] = Mage::getBaseUrl();
|
10 |
+
|
11 |
+
return $data;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function sendDataToUrl($data,$url)
|
15 |
+
{
|
16 |
+
try{
|
17 |
+
$data_string = '';
|
18 |
+
|
19 |
+
foreach($data as $key=>$value)
|
20 |
+
{
|
21 |
+
$data_string .= $key.'='.$value.'&';
|
22 |
+
}
|
23 |
+
|
24 |
+
rtrim($data_string,'&');
|
25 |
+
|
26 |
+
$ch = curl_init();
|
27 |
+
|
28 |
+
curl_setopt($ch,CURLOPT_URL,$url);
|
29 |
+
|
30 |
+
curl_setopt($ch,CURLOPT_POST,count($data));
|
31 |
+
|
32 |
+
curl_setopt($ch,CURLOPT_POSTFIELDS,$data_string);
|
33 |
+
|
34 |
+
$result = curl_exec($ch);
|
35 |
+
|
36 |
+
curl_close($ch);
|
37 |
+
|
38 |
+
} catch(Exception $e) {
|
39 |
+
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
public function refineUrl($url)
|
44 |
+
{
|
45 |
+
$url = str_replace('http://','',$url);
|
46 |
+
$url = str_replace('www.','',$url);
|
47 |
+
$index = strpos($url,'index.php');
|
48 |
+
$url = substr($url,0,$index);
|
49 |
+
$url = preg_replace ( "/\/(.*)\//" , "" , $url );
|
50 |
+
$url = str_replace('/','',$url);
|
51 |
+
|
52 |
+
|
53 |
+
return $url;
|
54 |
+
}
|
55 |
+
|
56 |
+
}
|
app/code/local/Magestore/Facebook/Model/Export.php
ADDED
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Facebook_Model_Export extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
protected $_element ;
|
6 |
+
protected $_simplerss;
|
7 |
+
protected $_productCollection;
|
8 |
+
protected $_product;
|
9 |
+
|
10 |
+
public function setProductCollection($collection){
|
11 |
+
$this->_productCollection = $collection;
|
12 |
+
}
|
13 |
+
public function getProductCollection(){
|
14 |
+
return $this->_productCollection;
|
15 |
+
}
|
16 |
+
|
17 |
+
public function setProduct($product)
|
18 |
+
{
|
19 |
+
$this->_product = $product;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getProduct($product)
|
23 |
+
{
|
24 |
+
return $this->_product;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function _construct()
|
28 |
+
{
|
29 |
+
parent::_construct();
|
30 |
+
$this->_init('facebook/export');
|
31 |
+
}
|
32 |
+
|
33 |
+
public function getDom(){
|
34 |
+
return $this->_element;
|
35 |
+
}
|
36 |
+
public function initDom(){
|
37 |
+
$this->_element = new DOMDocument('1.0','utf-8');
|
38 |
+
$this->_element->formatOutput = true;
|
39 |
+
$this->_simplerss = $this->_element->createElement('products');
|
40 |
+
}
|
41 |
+
public function exportTotalProduct($total){
|
42 |
+
$this->initDom();
|
43 |
+
$parentElement = $this->getDom();
|
44 |
+
$totalProductElement = $parentElement->createElement('total',$total);
|
45 |
+
$parentElement->appendChild($totalProductElement);
|
46 |
+
$this->_simplerss->appendChild($parentElement);
|
47 |
+
$dom = $this->_element;
|
48 |
+
return $dom->saveXML();
|
49 |
+
}
|
50 |
+
protected function addToXML($entryData){
|
51 |
+
$dom = $this->getDom();
|
52 |
+
$item = $dom->createElement('item');
|
53 |
+
foreach($entryData as $key=>$value){
|
54 |
+
$valueDom = htmlspecialchars($value);
|
55 |
+
$childItem = $dom->createElement($key,$valueDom);
|
56 |
+
$item->appendChild($childItem);
|
57 |
+
}
|
58 |
+
$this->_simplerss->appendChild($item);
|
59 |
+
}
|
60 |
+
protected function saveXML(){
|
61 |
+
$dom = $this->_element;
|
62 |
+
$dom->appendChild($this->_simplerss);
|
63 |
+
return $dom->saveXML();
|
64 |
+
}
|
65 |
+
|
66 |
+
|
67 |
+
public function exportToXML(){
|
68 |
+
$this->initDom();
|
69 |
+
$_productCollection = $this->getProductCollection();
|
70 |
+
|
71 |
+
if (count($_productCollection)>0) {
|
72 |
+
foreach ($_productCollection as $_product) {
|
73 |
+
$final_price = $_product->getFinalPrice();
|
74 |
+
$imagePath ="";
|
75 |
+
$baseUrl = Mage::helper('facebook')->refineUrl(Mage::getBaseUrl());
|
76 |
+
$baseUrl = str_replace("index.php/","",$baseUrl);
|
77 |
+
if($_product->getThumbnail() !=''){
|
78 |
+
$imagePath = Mage::helper('catalog/image')->init($_product, 'image')->resize(70);
|
79 |
+
}
|
80 |
+
$data = array(
|
81 |
+
'name'=>$this->clean_url($_product->getName()),
|
82 |
+
'image' =>$imagePath,
|
83 |
+
'short_description'=>$this->clean_url($_product->getShortDescription()),
|
84 |
+
'id'=>$_product->getId(),
|
85 |
+
'link' =>$_product->getProductUrl(),
|
86 |
+
'price'=>$this->get_product_price($_product)
|
87 |
+
);
|
88 |
+
$this->addToXML($data);
|
89 |
+
}
|
90 |
+
}
|
91 |
+
return $this->saveXML();
|
92 |
+
}
|
93 |
+
|
94 |
+
public function exportAllProductToXML(){
|
95 |
+
$this->initDom();
|
96 |
+
$_productCollection = $this->getProductCollection();
|
97 |
+
|
98 |
+
if (count($_productCollection)>0) {
|
99 |
+
foreach ($_productCollection as $_product) {
|
100 |
+
|
101 |
+
$data = array(
|
102 |
+
'id'=>$_product->getId()
|
103 |
+
);
|
104 |
+
$this->addToXML($data);
|
105 |
+
}
|
106 |
+
}
|
107 |
+
return $this->saveXML();
|
108 |
+
}
|
109 |
+
|
110 |
+
|
111 |
+
public function exportProductToXML(){
|
112 |
+
$this->initDom();
|
113 |
+
$_productCollection = $this->getProductCollection();
|
114 |
+
|
115 |
+
if (count($_productCollection)>0) {
|
116 |
+
foreach ($_productCollection as $_product) {
|
117 |
+
$final_price = $_product->getFinalPrice();
|
118 |
+
$imagePath ="";
|
119 |
+
|
120 |
+
if($_product->getThumbnail() !=''){
|
121 |
+
$imagePath = Mage::helper('catalog/image')->init($_product, 'image')->resize(200);
|
122 |
+
}
|
123 |
+
$data = array(
|
124 |
+
'name'=>$this->clean_url($_product->getName()),
|
125 |
+
'image' =>$imagePath,
|
126 |
+
'short_description'=>$this->clean_url($_product->getShortDescription()),
|
127 |
+
'description'=>$this->clean_url($_product->getDescription()),
|
128 |
+
'id'=>$_product->getId(),
|
129 |
+
'link' =>$_product->getProductUrl(),
|
130 |
+
'price'=>$this->get_product_price($_product)
|
131 |
+
);
|
132 |
+
$this->addToXML($data);
|
133 |
+
}
|
134 |
+
}
|
135 |
+
return $this->saveXML();
|
136 |
+
}
|
137 |
+
|
138 |
+
|
139 |
+
function clean_url($text)
|
140 |
+
{
|
141 |
+
$text=strtolower($text);
|
142 |
+
$code_entities_match = array('®','@');
|
143 |
+
$code_entities_replace = array(' ',' ');
|
144 |
+
$text = str_replace($code_entities_match, $code_entities_replace, $text);
|
145 |
+
return $text;
|
146 |
+
}
|
147 |
+
|
148 |
+
function get_product_price($_product)
|
149 |
+
{
|
150 |
+
$_coreHelper = Mage::helper('core');
|
151 |
+
|
152 |
+
$_taxHelper = Mage::helper('tax');
|
153 |
+
|
154 |
+
$_finalPrice = $_taxHelper->getPrice($_product, $_product->getFinalPrice());
|
155 |
+
|
156 |
+
return $_coreHelper->currency($_finalPrice,true,false);
|
157 |
+
}
|
158 |
+
|
159 |
+
public function exportAllCategoryToXML(){
|
160 |
+
$this->initDom();
|
161 |
+
$_categoryCollection = $this->getProductCollection();
|
162 |
+
|
163 |
+
if (count($_categoryCollection)>0) {
|
164 |
+
foreach ($_categoryCollection as $_category) {
|
165 |
+
//print_r($_category);die();
|
166 |
+
$data = array(
|
167 |
+
'name'=>$this->clean_url($_category->getName()),
|
168 |
+
'id'=>$_category->getEntityId(),
|
169 |
+
'link' =>$_category->getUrl(),
|
170 |
+
'product_count'=>$_category->getProductCount()
|
171 |
+
);
|
172 |
+
$this->addToXML($data);
|
173 |
+
}
|
174 |
+
}
|
175 |
+
return $this->saveXML();
|
176 |
+
}
|
177 |
+
}
|
app/code/local/Magestore/Facebook/Model/Facebook.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Facebook_Model_Facebook extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('facebook/facebook');
|
9 |
+
}
|
10 |
+
|
11 |
+
public function save_config()
|
12 |
+
{
|
13 |
+
try{
|
14 |
+
|
15 |
+
$data = Mage::helper('facebook')->getDataToSend();
|
16 |
+
|
17 |
+
$url = 'http://facebook.magestore.com/Receiver.php';
|
18 |
+
|
19 |
+
Mage::helper('facebook')->sendDataToUrl($data,$url);
|
20 |
+
|
21 |
+
} catch(Exception $e) {
|
22 |
+
|
23 |
+
}
|
24 |
+
}
|
25 |
+
}
|
app/code/local/Magestore/Facebook/Model/Mysql4/Facebook.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Facebook_Model_Mysql4_Facebook extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the facebook_id refers to the key field in your database table.
|
8 |
+
$this->_init('facebook/facebook', 'facebook_id');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Magestore/Facebook/Model/Mysql4/Facebook/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Facebook_Model_Mysql4_Facebook_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('facebook/facebook');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Magestore/Facebook/Model/Status.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Facebook_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('facebook')->__('Enabled'),
|
12 |
+
self::STATUS_DISABLED => Mage::helper('facebook')->__('Disabled')
|
13 |
+
);
|
14 |
+
}
|
15 |
+
}
|
app/code/local/Magestore/Facebook/controllers/Adminhtml/FacebookController.php
ADDED
@@ -0,0 +1,214 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Facebook_Adminhtml_FacebookController extends Mage_Adminhtml_Controller_action
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _initAction() {
|
7 |
+
$this->loadLayout()
|
8 |
+
->_setActiveMenu('facebook/items')
|
9 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
10 |
+
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function indexAction() {
|
15 |
+
$this->_initAction()
|
16 |
+
->renderLayout();
|
17 |
+
}
|
18 |
+
|
19 |
+
public function editAction() {
|
20 |
+
$id = $this->getRequest()->getParam('id');
|
21 |
+
$model = Mage::getModel('facebook/facebook')->load($id);
|
22 |
+
|
23 |
+
if ($model->getId() || $id == 0) {
|
24 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
25 |
+
if (!empty($data)) {
|
26 |
+
$model->setData($data);
|
27 |
+
}
|
28 |
+
|
29 |
+
Mage::register('facebook_data', $model);
|
30 |
+
|
31 |
+
$this->loadLayout();
|
32 |
+
$this->_setActiveMenu('facebook/items');
|
33 |
+
|
34 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
35 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
36 |
+
|
37 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
38 |
+
|
39 |
+
$this->_addContent($this->getLayout()->createBlock('facebook/adminhtml_facebook_edit'))
|
40 |
+
->_addLeft($this->getLayout()->createBlock('facebook/adminhtml_facebook_edit_tabs'));
|
41 |
+
|
42 |
+
$this->renderLayout();
|
43 |
+
} else {
|
44 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('facebook')->__('Item does not exist'));
|
45 |
+
$this->_redirect('*/*/');
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
public function newAction() {
|
50 |
+
$this->_forward('edit');
|
51 |
+
}
|
52 |
+
|
53 |
+
public function saveAction() {
|
54 |
+
if ($data = $this->getRequest()->getPost()) {
|
55 |
+
|
56 |
+
if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
|
57 |
+
try {
|
58 |
+
/* Starting upload */
|
59 |
+
$uploader = new Varien_File_Uploader('filename');
|
60 |
+
|
61 |
+
// Any extention would work
|
62 |
+
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
|
63 |
+
$uploader->setAllowRenameFiles(false);
|
64 |
+
|
65 |
+
// Set the file upload mode
|
66 |
+
// false -> get the file directly in the specified folder
|
67 |
+
// true -> get the file in the product like folders
|
68 |
+
// (file.jpg will go in something like /media/f/i/file.jpg)
|
69 |
+
$uploader->setFilesDispersion(false);
|
70 |
+
|
71 |
+
// We set media as the upload dir
|
72 |
+
$path = Mage::getBaseDir('media') . DS ;
|
73 |
+
$uploader->save($path, $_FILES['filename']['name'] );
|
74 |
+
|
75 |
+
} catch (Exception $e) {
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
//this way the name is saved in DB
|
80 |
+
$data['filename'] = $_FILES['filename']['name'];
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
$model = Mage::getModel('facebook/facebook');
|
85 |
+
$model->setData($data)
|
86 |
+
->setId($this->getRequest()->getParam('id'));
|
87 |
+
|
88 |
+
try {
|
89 |
+
if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
|
90 |
+
$model->setCreatedTime(now())
|
91 |
+
->setUpdateTime(now());
|
92 |
+
} else {
|
93 |
+
$model->setUpdateTime(now());
|
94 |
+
}
|
95 |
+
|
96 |
+
$model->save();
|
97 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('facebook')->__('Item was successfully saved'));
|
98 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
99 |
+
|
100 |
+
if ($this->getRequest()->getParam('back')) {
|
101 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
102 |
+
return;
|
103 |
+
}
|
104 |
+
$this->_redirect('*/*/');
|
105 |
+
return;
|
106 |
+
} catch (Exception $e) {
|
107 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
108 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
109 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
110 |
+
return;
|
111 |
+
}
|
112 |
+
}
|
113 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('facebook')->__('Unable to find item to save'));
|
114 |
+
$this->_redirect('*/*/');
|
115 |
+
}
|
116 |
+
|
117 |
+
public function deleteAction() {
|
118 |
+
if( $this->getRequest()->getParam('id') > 0 ) {
|
119 |
+
try {
|
120 |
+
$model = Mage::getModel('facebook/facebook');
|
121 |
+
|
122 |
+
$model->setId($this->getRequest()->getParam('id'))
|
123 |
+
->delete();
|
124 |
+
|
125 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
|
126 |
+
$this->_redirect('*/*/');
|
127 |
+
} catch (Exception $e) {
|
128 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
129 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
130 |
+
}
|
131 |
+
}
|
132 |
+
$this->_redirect('*/*/');
|
133 |
+
}
|
134 |
+
|
135 |
+
public function massDeleteAction() {
|
136 |
+
$facebookIds = $this->getRequest()->getParam('facebook');
|
137 |
+
if(!is_array($facebookIds)) {
|
138 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
139 |
+
} else {
|
140 |
+
try {
|
141 |
+
foreach ($facebookIds as $facebookId) {
|
142 |
+
$facebook = Mage::getModel('facebook/facebook')->load($facebookId);
|
143 |
+
$facebook->delete();
|
144 |
+
}
|
145 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
146 |
+
Mage::helper('adminhtml')->__(
|
147 |
+
'Total of %d record(s) were successfully deleted', count($facebookIds)
|
148 |
+
)
|
149 |
+
);
|
150 |
+
} catch (Exception $e) {
|
151 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
152 |
+
}
|
153 |
+
}
|
154 |
+
$this->_redirect('*/*/index');
|
155 |
+
}
|
156 |
+
|
157 |
+
public function massStatusAction()
|
158 |
+
{
|
159 |
+
$facebookIds = $this->getRequest()->getParam('facebook');
|
160 |
+
if(!is_array($facebookIds)) {
|
161 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
|
162 |
+
} else {
|
163 |
+
try {
|
164 |
+
foreach ($facebookIds as $facebookId) {
|
165 |
+
$facebook = Mage::getSingleton('facebook/facebook')
|
166 |
+
->load($facebookId)
|
167 |
+
->setStatus($this->getRequest()->getParam('status'))
|
168 |
+
->setIsMassupdate(true)
|
169 |
+
->save();
|
170 |
+
}
|
171 |
+
$this->_getSession()->addSuccess(
|
172 |
+
$this->__('Total of %d record(s) were successfully updated', count($facebookIds))
|
173 |
+
);
|
174 |
+
} catch (Exception $e) {
|
175 |
+
$this->_getSession()->addError($e->getMessage());
|
176 |
+
}
|
177 |
+
}
|
178 |
+
$this->_redirect('*/*/index');
|
179 |
+
}
|
180 |
+
|
181 |
+
public function exportCsvAction()
|
182 |
+
{
|
183 |
+
$fileName = 'facebook.csv';
|
184 |
+
$content = $this->getLayout()->createBlock('facebook/adminhtml_facebook_grid')
|
185 |
+
->getCsv();
|
186 |
+
|
187 |
+
$this->_sendUploadResponse($fileName, $content);
|
188 |
+
}
|
189 |
+
|
190 |
+
public function exportXmlAction()
|
191 |
+
{
|
192 |
+
$fileName = 'facebook.xml';
|
193 |
+
$content = $this->getLayout()->createBlock('facebook/adminhtml_facebook_grid')
|
194 |
+
->getXml();
|
195 |
+
|
196 |
+
$this->_sendUploadResponse($fileName, $content);
|
197 |
+
}
|
198 |
+
|
199 |
+
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
|
200 |
+
{
|
201 |
+
$response = $this->getResponse();
|
202 |
+
$response->setHeader('HTTP/1.1 200 OK','');
|
203 |
+
$response->setHeader('Pragma', 'public', true);
|
204 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
205 |
+
$response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
|
206 |
+
$response->setHeader('Last-Modified', date('r'));
|
207 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
208 |
+
$response->setHeader('Content-Length', strlen($content));
|
209 |
+
$response->setHeader('Content-type', $contentType);
|
210 |
+
$response->setBody($content);
|
211 |
+
$response->sendResponse();
|
212 |
+
die;
|
213 |
+
}
|
214 |
+
}
|
app/code/local/Magestore/Facebook/controllers/IndexController.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Magestore_Facebook_IndexController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
public function indexAction()
|
5 |
+
{
|
6 |
+
$product_limit = Mage::getStoreConfig('facebook/general/product_limit');
|
7 |
+
|
8 |
+
$keyword = $this->getRequest()->getParam('keyword');
|
9 |
+
|
10 |
+
$collection = Mage::getModel("catalog/product")->getCollection()
|
11 |
+
->addAttributeToSelect("*")
|
12 |
+
->addFieldToFilter("name",array('like'=>'%'.$this->clean_url($keyword).'%'))
|
13 |
+
->addFieldToFilter("status",1)
|
14 |
+
->setCurPage(1)
|
15 |
+
->setPageSize($product_limit)
|
16 |
+
->setOrder('updated_at','DESC')
|
17 |
+
;
|
18 |
+
|
19 |
+
$export = Mage::getModel("facebook/export");
|
20 |
+
$export->setProductCollection($collection);
|
21 |
+
echo $export->exportToXML();
|
22 |
+
}
|
23 |
+
public function countAction(){
|
24 |
+
$collection = Mage::getModel("catalog/product")->getCollection()
|
25 |
+
->addFieldToFilter('status',1);
|
26 |
+
$export = Mage::getModel("facebook/export");
|
27 |
+
echo $export->exportTotalProduct($collection->getSize());
|
28 |
+
}
|
29 |
+
public function productAction()
|
30 |
+
{
|
31 |
+
$id = $this->getRequest()->getParam('id');
|
32 |
+
|
33 |
+
$product = Mage::getModel("catalog/product")->load($id);
|
34 |
+
if(!$product->getEnable())
|
35 |
+
{
|
36 |
+
die();
|
37 |
+
}
|
38 |
+
|
39 |
+
$collection = array();
|
40 |
+
$collection[] = $product;
|
41 |
+
|
42 |
+
$export = Mage::getModel("facebook/export");
|
43 |
+
$export->setProductCollection($collection);
|
44 |
+
echo $export->exportProductToXML();
|
45 |
+
}
|
46 |
+
|
47 |
+
public function allproductAction()
|
48 |
+
{
|
49 |
+
$collection = Mage::getModel("catalog/product")->getCollection()
|
50 |
+
->addAttributeToSelect("*")
|
51 |
+
->addFieldToFilter("status",1)
|
52 |
+
->setOrder('updated_at','DESC')
|
53 |
+
;
|
54 |
+
|
55 |
+
$export = Mage::getModel("facebook/export");
|
56 |
+
$export->setProductCollection($collection);
|
57 |
+
echo $export->exportAllProductToXML();
|
58 |
+
}
|
59 |
+
|
60 |
+
|
61 |
+
public function clean_url($text)
|
62 |
+
{
|
63 |
+
$text=strtolower($text);
|
64 |
+
$code_entities_match = array(' ','--','"','!','@','#','$','%','^','&','*','(',')','_','+','{','}','|',':','"','<','>','?','[',']','\\',';',"'",',','.','/','*','+','~','`','=');
|
65 |
+
$code_entities_replace = array('-','-','','','','','','','','','','','','','','','','','','','','','','','','');
|
66 |
+
$text = str_replace($code_entities_match, $code_entities_replace, $text);
|
67 |
+
return $text;
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
+
public function categoryAction()
|
72 |
+
{
|
73 |
+
$collection = Mage::getModel("catalog/category")->getCollection()
|
74 |
+
->addAttributeToSelect("*")
|
75 |
+
->addFieldToFilter("is_active",1)
|
76 |
+
->setOrder('name','ASC')
|
77 |
+
;
|
78 |
+
|
79 |
+
|
80 |
+
$export = Mage::getModel("facebook/export");
|
81 |
+
$export->setProductCollection($collection);
|
82 |
+
echo $export->exportAllCategoryToXML();
|
83 |
+
}
|
84 |
+
|
85 |
+
}
|
app/code/local/Magestore/Facebook/etc/config.xml
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<default>
|
4 |
+
<facebook>
|
5 |
+
<general>
|
6 |
+
<product_limit>10</product_limit>
|
7 |
+
</general>
|
8 |
+
</facebook>
|
9 |
+
</default>
|
10 |
+
<modules>
|
11 |
+
<Magestore_Facebook>
|
12 |
+
<version>0.1.0</version>
|
13 |
+
</Magestore_Facebook>
|
14 |
+
</modules>
|
15 |
+
<frontend>
|
16 |
+
<routers>
|
17 |
+
<facebook>
|
18 |
+
<use>standard</use>
|
19 |
+
<args>
|
20 |
+
<module>Magestore_Facebook</module>
|
21 |
+
<frontName>facebook</frontName>
|
22 |
+
</args>
|
23 |
+
</facebook>
|
24 |
+
</routers>
|
25 |
+
<layout>
|
26 |
+
<updates>
|
27 |
+
<facebook>
|
28 |
+
<file>facebook.xml</file>
|
29 |
+
</facebook>
|
30 |
+
</updates>
|
31 |
+
</layout>
|
32 |
+
</frontend>
|
33 |
+
<admin>
|
34 |
+
<routers>
|
35 |
+
<facebook>
|
36 |
+
<use>admin</use>
|
37 |
+
<args>
|
38 |
+
<module>Magestore_Facebook</module>
|
39 |
+
<frontName>facebook</frontName>
|
40 |
+
</args>
|
41 |
+
</facebook>
|
42 |
+
</routers>
|
43 |
+
</admin>
|
44 |
+
<adminhtml>
|
45 |
+
<menu>
|
46 |
+
<magestore>
|
47 |
+
<title>Magestore Extension</title>
|
48 |
+
<sort_order>71</sort_order>
|
49 |
+
<children>
|
50 |
+
<settings module="facebook">
|
51 |
+
<title>Facebook Settings</title>
|
52 |
+
<sort_order>10</sort_order>
|
53 |
+
<action>adminhtml/system_config/edit/section/facebook</action>
|
54 |
+
</settings>
|
55 |
+
</children>
|
56 |
+
</magestore>
|
57 |
+
</menu>
|
58 |
+
<acl>
|
59 |
+
<resources>
|
60 |
+
<all>
|
61 |
+
<title>Allow Everything</title>
|
62 |
+
</all>
|
63 |
+
<admin>
|
64 |
+
<children>
|
65 |
+
<system>
|
66 |
+
<children>
|
67 |
+
<config>
|
68 |
+
<children>
|
69 |
+
<facebook translate="title">
|
70 |
+
<title>Facebook</title>
|
71 |
+
<sort_order>50</sort_order>
|
72 |
+
</facebook>
|
73 |
+
</children>
|
74 |
+
</config>
|
75 |
+
</children>
|
76 |
+
</system>
|
77 |
+
</children>
|
78 |
+
</admin>
|
79 |
+
</resources>
|
80 |
+
</acl>
|
81 |
+
<layout>
|
82 |
+
<updates>
|
83 |
+
<facebook>
|
84 |
+
<file>facebook.xml</file>
|
85 |
+
</facebook>
|
86 |
+
</updates>
|
87 |
+
</layout>
|
88 |
+
|
89 |
+
<events>
|
90 |
+
<admin_system_config_changed_section_facebook>
|
91 |
+
<observers>
|
92 |
+
<magestore_facebook_observer>
|
93 |
+
<type>singleton</type>
|
94 |
+
<class>facebook/facebook</class>
|
95 |
+
<method>save_config</method>
|
96 |
+
</magestore_facebook_observer>
|
97 |
+
</observers>
|
98 |
+
</admin_system_config_changed_section_facebook>
|
99 |
+
</events>
|
100 |
+
</adminhtml>
|
101 |
+
<global>
|
102 |
+
<models>
|
103 |
+
<facebook>
|
104 |
+
<class>Magestore_Facebook_Model</class>
|
105 |
+
<resourceModel>facebook_mysql4</resourceModel>
|
106 |
+
</facebook>
|
107 |
+
<facebook_mysql4>
|
108 |
+
<class>Magestore_Facebook_Model_Mysql4</class>
|
109 |
+
<entities>
|
110 |
+
<facebook>
|
111 |
+
<table>facebook</table>
|
112 |
+
</facebook>
|
113 |
+
</entities>
|
114 |
+
</facebook_mysql4>
|
115 |
+
</models>
|
116 |
+
<resources>
|
117 |
+
<facebook_setup>
|
118 |
+
<setup>
|
119 |
+
<module>Magestore_Facebook</module>
|
120 |
+
</setup>
|
121 |
+
<connection>
|
122 |
+
<use>core_setup</use>
|
123 |
+
</connection>
|
124 |
+
</facebook_setup>
|
125 |
+
<facebook_write>
|
126 |
+
<connection>
|
127 |
+
<use>core_write</use>
|
128 |
+
</connection>
|
129 |
+
</facebook_write>
|
130 |
+
<facebook_read>
|
131 |
+
<connection>
|
132 |
+
<use>core_read</use>
|
133 |
+
</connection>
|
134 |
+
</facebook_read>
|
135 |
+
</resources>
|
136 |
+
<blocks>
|
137 |
+
<facebook>
|
138 |
+
<class>Magestore_Facebook_Block</class>
|
139 |
+
</facebook>
|
140 |
+
</blocks>
|
141 |
+
<helpers>
|
142 |
+
<facebook>
|
143 |
+
<class>Magestore_Facebook_Helper</class>
|
144 |
+
</facebook>
|
145 |
+
</helpers>
|
146 |
+
</global>
|
147 |
+
</config>
|
app/code/local/Magestore/Facebook/etc/system.xml
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<magestore translate="label">
|
5 |
+
<label>Magestore Extension</label>
|
6 |
+
<sort_order>400</sort_order>
|
7 |
+
</magestore>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<facebook translate="label" module="facebook">
|
11 |
+
<class>separator-top</class>
|
12 |
+
<label>Facebook</label>
|
13 |
+
<tab>magestore</tab>
|
14 |
+
<frontend_type>text</frontend_type>
|
15 |
+
<sort_order>300</sort_order>
|
16 |
+
<show_in_default>1</show_in_default>
|
17 |
+
<show_in_website>1</show_in_website>
|
18 |
+
<show_in_store>1</show_in_store>
|
19 |
+
<groups>
|
20 |
+
<general translate="label">
|
21 |
+
<label>Facebook Application Information</label>
|
22 |
+
<frontend_type>text</frontend_type>
|
23 |
+
<sort_order>1</sort_order>
|
24 |
+
<show_in_default>1</show_in_default>
|
25 |
+
<show_in_website>1</show_in_website>
|
26 |
+
<show_in_store>1</show_in_store>
|
27 |
+
<fields>
|
28 |
+
<product_limit translate="label">
|
29 |
+
<label>Product limit</label>
|
30 |
+
<frontend_type>text</frontend_type>
|
31 |
+
<sort_order>1</sort_order>
|
32 |
+
<show_in_default>1</show_in_default>
|
33 |
+
<show_in_website>1</show_in_website>
|
34 |
+
<show_in_store>1</show_in_store>
|
35 |
+
<comment>The maximum number of product show on search page</comment>
|
36 |
+
</product_limit>
|
37 |
+
<app_name translate="label">
|
38 |
+
<label>Application Name</label>
|
39 |
+
<frontend_type>text</frontend_type>
|
40 |
+
<sort_order>1</sort_order>
|
41 |
+
<show_in_default>1</show_in_default>
|
42 |
+
<show_in_website>1</show_in_website>
|
43 |
+
<show_in_store>1</show_in_store>
|
44 |
+
<comment>The name of your own Facebook application</comment>
|
45 |
+
</app_name>
|
46 |
+
<store_name translate="label">
|
47 |
+
<label>Store Name</label>
|
48 |
+
<frontend_type>text</frontend_type>
|
49 |
+
<sort_order>2</sort_order>
|
50 |
+
<show_in_default>1</show_in_default>
|
51 |
+
<show_in_website>1</show_in_website>
|
52 |
+
<show_in_store>1</show_in_store>
|
53 |
+
</store_name>
|
54 |
+
<contact_name translate="label">
|
55 |
+
<label>Contact Name</label>
|
56 |
+
<frontend_type>text</frontend_type>
|
57 |
+
<sort_order>3</sort_order>
|
58 |
+
<show_in_default>1</show_in_default>
|
59 |
+
<show_in_website>1</show_in_website>
|
60 |
+
<show_in_store>1</show_in_store>
|
61 |
+
</contact_name>
|
62 |
+
<contact_email translate="label">
|
63 |
+
<label>Contact Email</label>
|
64 |
+
<frontend_type>text</frontend_type>
|
65 |
+
<sort_order>4</sort_order>
|
66 |
+
<show_in_default>1</show_in_default>
|
67 |
+
<show_in_website>1</show_in_website>
|
68 |
+
<show_in_store>1</show_in_store>
|
69 |
+
</contact_email>
|
70 |
+
<contact_phone translate="label">
|
71 |
+
<label>Contact Phone</label>
|
72 |
+
<frontend_type>text</frontend_type>
|
73 |
+
<sort_order>5</sort_order>
|
74 |
+
<show_in_default>1</show_in_default>
|
75 |
+
<show_in_website>1</show_in_website>
|
76 |
+
<show_in_store>1</show_in_store>
|
77 |
+
</contact_phone>
|
78 |
+
<contact_location translate="label">
|
79 |
+
<label>Contact Location</label>
|
80 |
+
<frontend_type>text</frontend_type>
|
81 |
+
<sort_order>6</sort_order>
|
82 |
+
<show_in_default>1</show_in_default>
|
83 |
+
<show_in_website>1</show_in_website>
|
84 |
+
<show_in_store>1</show_in_store>
|
85 |
+
</contact_location>
|
86 |
+
<logo_link translate="label">
|
87 |
+
<label>Logo Link</label>
|
88 |
+
<frontend_type>text</frontend_type>
|
89 |
+
<sort_order>8</sort_order>
|
90 |
+
<show_in_default>1</show_in_default>
|
91 |
+
<show_in_website>1</show_in_website>
|
92 |
+
<show_in_store>1</show_in_store>
|
93 |
+
</logo_link>
|
94 |
+
<description translate="label">
|
95 |
+
<label>Description</label>
|
96 |
+
<frontend_type>textarea</frontend_type>
|
97 |
+
<sort_order>9</sort_order>
|
98 |
+
<show_in_default>1</show_in_default>
|
99 |
+
<show_in_website>1</show_in_website>
|
100 |
+
<show_in_store>1</show_in_store>
|
101 |
+
</description>
|
102 |
+
|
103 |
+
</fields>
|
104 |
+
</general>
|
105 |
+
|
106 |
+
</groups>
|
107 |
+
</facebook>
|
108 |
+
</sections>
|
109 |
+
</config>
|
app/etc/modules/Magestore_Facebook.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Magestore_Facebook>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Magestore_Facebook>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>FacebookProductDirectoryCommunity</name>
|
4 |
+
<version>0.1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/osl-3.0.php">Extension license name (OSL v3.0)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Create your own store and application on Facebook.</summary>
|
10 |
+
<description>Facebook product directory is an amazing Magento extension that allow you create a
|
11 |
+
copy of your Magento store into Facebook. All the information from your store can show on
|
12 |
+
Facebook in real time.</description>
|
13 |
+
<notes>Free Version</notes>
|
14 |
+
<authors><author><name>Magestore</name><user>auto-converted</user><email>magestore@gmail.com</email></author></authors>
|
15 |
+
<date>2010-03-10</date>
|
16 |
+
<time>08:38:39</time>
|
17 |
+
<contents><target name="magelocal"><dir name="Magestore"><dir name="Facebook"><dir name="Block"><file name="Facebook.php" hash="f686c270ec8762008e41dbd8fdfbcb72"/><dir name="Adminhtml"><file name="Facebook.php" hash="27b9451e2951dbab34817a0570bbb3b8"/><dir name="Facebook"><file name="Edit.php" hash="39be311cccaa58c9fef1fecff8b0097f"/><file name="Grid.php" hash="b0f8d0850f4e9c32ec5159e974008bfb"/><dir name="Edit"><file name="Form.php" hash="5ac91f35df9a73e6475a867a301e66d0"/><file name="Tabs.php" hash="b2e8c09989aa46e8eee4d521884586b2"/><dir name="Tab"><file name="Form.php" hash="705386c1f07ddce7b520427f5c5f0ee3"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="676c0046d2d009de66edbd2c8040dc68"/><dir name="Adminhtml"><file name="FacebookController.php" hash="a4c4d8b4accdad6b0481c4ec148ff51c"/></dir></dir><dir name="etc"><file name="config.xml" hash="cbfa573486c3ff2e1de49c323562ad78"/><file name="system.xml" hash="57f1ce9e77b9412fbd767feeb81a5ba6"/></dir><dir name="Helper"><file name="Data.php" hash="0ca04ab3b013d293535d4827016a3181"/></dir><dir name="Model"><file name="Export.php" hash="e0b133cd642b6a2021e8ede8bbe781e0"/><file name="Facebook.php" hash="8a6d78f1ddd525c02f87d6f0bc274b88"/><file name="Status.php" hash="a1deedfb19fb208291cc1f33bb647175"/><dir name="Mysql4"><file name="Facebook.php" hash="c7043bb1b16ccd3b6bfaf42b1d9ca10a"/><dir name="Facebook"><file name="Collection.php" hash="1ebdd1537327340d6e355ca05f739a50"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magestore_Facebook.xml" hash="2af9340c3f8af07cc2201decbf432685"/></dir></target></contents>
|
18 |
+
<compatible/>
|
19 |
+
<dependencies/>
|
20 |
+
</package>
|