Version Notes
Init Version.
Download this release
Release Info
Developer | Rafael Mor |
Extension | Pixelshop_Integration |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Pixelshop/Integration/Block/Adminhtml/Form/Edit.php +17 -0
- app/code/community/Pixelshop/Integration/Block/Adminhtml/Form/Edit/Form.php +24 -0
- app/code/community/Pixelshop/Integration/Block/Adminhtml/Form/Edit/Renderer/Label.php +27 -0
- app/code/community/Pixelshop/Integration/Block/Adminhtml/Form/Edit/Renderer/Multienabled.php +29 -0
- app/code/community/Pixelshop/Integration/Block/Adminhtml/Form/Edit/Tab/General.php +37 -0
- app/code/community/Pixelshop/Integration/Block/Adminhtml/Form/Edit/Tabs.php +32 -0
- app/code/community/Pixelshop/Integration/Helper/Data.php +3 -0
- app/code/community/Pixelshop/Integration/controllers/Adminhtml/ExportoController.php +74 -0
- app/code/community/Pixelshop/Integration/controllers/IndexController.php +12 -0
- app/code/community/Pixelshop/Integration/etc/adminhtml.xml +44 -0
- app/code/community/Pixelshop/Integration/etc/config.xml +82 -0
- app/code/community/Pixelshop/Integration/etc/system.xml +38 -0
- app/design/adminhtml/default/default/layout/pixelshop.xml +19 -0
- lib/Pixelshop/Pixelshop.php +85 -0
- lib/Pixelshop/Pixelshop/Export.php +25 -0
- package.xml +18 -0
- skin/adminhtml/default/default/pixelshop/integration/pixelshop.css +10 -0
app/code/community/Pixelshop/Integration/Block/Adminhtml/Form/Edit.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pixelshop_Integration_Block_Adminhtml_Form_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Constructor
|
8 |
+
*/
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
$this->_blockGroup = 'pixelshop';
|
13 |
+
$this->_controller = 'adminhtml_form';
|
14 |
+
$this->_headerText = Mage::helper('pixelshop')->__('Export Products');
|
15 |
+
}
|
16 |
+
|
17 |
+
}
|
app/code/community/Pixelshop/Integration/Block/Adminhtml/Form/Edit/Form.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pixelshop_Integration_Block_Adminhtml_Form_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Preparing form
|
7 |
+
*
|
8 |
+
* @return Mage_Adminhtml_Block_Widget_Form
|
9 |
+
*/
|
10 |
+
protected function _prepareForm()
|
11 |
+
{
|
12 |
+
$form = new Varien_Data_Form(
|
13 |
+
array(
|
14 |
+
'id' => 'edit_form',
|
15 |
+
'action' => $this->getUrl('*/*/save'),
|
16 |
+
'method' => 'post',
|
17 |
+
)
|
18 |
+
);
|
19 |
+
|
20 |
+
$form->setUseContainer(true);
|
21 |
+
$this->setForm($form);
|
22 |
+
return parent::_prepareForm();
|
23 |
+
}
|
24 |
+
}
|
app/code/community/Pixelshop/Integration/Block/Adminhtml/Form/Edit/Renderer/Label.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pixelshop_Integration_Block_Adminhtml_Form_Edit_Renderer_Label
|
4 |
+
extends Mage_Adminhtml_Block_Widget
|
5 |
+
implements Varien_Data_Form_Element_Renderer_Interface
|
6 |
+
{
|
7 |
+
|
8 |
+
/**
|
9 |
+
* renderer
|
10 |
+
*
|
11 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
12 |
+
*/
|
13 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
14 |
+
{
|
15 |
+
$element->setDisabled(true);
|
16 |
+
$disabled = true;
|
17 |
+
$htmlId = 'use_config_' . $element->getHtmlId();
|
18 |
+
$html = '<tr><td class="label">' . $element->getLabelHtml() . '</td><td class="value">';
|
19 |
+
$html .= '<input id="' . $htmlId . '" name="use_c[]" value="' . $element->getId() . '"'. ($disabled ? ' checked="checked"' : '');
|
20 |
+
$html .= ' onclick="toggleValueElements(this, this.parentNode);" class="checkbox" type="checkbox" />';
|
21 |
+
$html .= ' <label for="' . $htmlId . '" class="normal">' . Mage::helper('turnkeye_adminform')->__('Do not change value') . '</label>';
|
22 |
+
$html .= $element->getElementHtml();
|
23 |
+
$html .= '<script type="text/javascript">toggleValueElements($(\'' . $htmlId . '\'), $(\'' . $htmlId . '\').parentNode);</script>';
|
24 |
+
|
25 |
+
return $html . '</td><td class="scope - label"><span class="nobr"></span></td></tr>';
|
26 |
+
}
|
27 |
+
}
|
app/code/community/Pixelshop/Integration/Block/Adminhtml/Form/Edit/Renderer/Multienabled.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pixelshop_Integration_Block_Adminhtml_Form_Edit_Renderer_Multienabled extends Varien_Data_Form_Element_Multiselect
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Retrieve Element HTML fragment
|
8 |
+
*
|
9 |
+
* @return string
|
10 |
+
*/
|
11 |
+
public function getElementHtml()
|
12 |
+
{
|
13 |
+
$disabled = false;
|
14 |
+
if (!$this->getValue()) {
|
15 |
+
$this->setData('disabled', 'disabled');
|
16 |
+
$disabled = true;
|
17 |
+
}
|
18 |
+
$html = parent::getElementHtml();
|
19 |
+
$htmlId = 'use_config_' . $this->getHtmlId();
|
20 |
+
$html .= '<input id="' . $htmlId . '" name="use_config[]" value="' . $this->getId() . '"';
|
21 |
+
$html .= ($disabled ? ' checked="checked"' : '') . ($this->getReadonly()? ' disabled="disabled"':'');
|
22 |
+
$html .= ' onclick="toggleValueElements(this, this.parentNode);" class="checkbox" type="checkbox" />';
|
23 |
+
$html .= ' <label for="' . $htmlId . '" class="normal">' . $this->getCheckboxLabel() . '</label>';
|
24 |
+
$html .= '<script type="text/javascript">toggleValueElements($(\'' . $htmlId . '\'), $(\'' . $htmlId . '\').parentNode);</script>';
|
25 |
+
|
26 |
+
return $html;
|
27 |
+
}
|
28 |
+
|
29 |
+
}
|
app/code/community/Pixelshop/Integration/Block/Adminhtml/Form/Edit/Tab/General.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pixelshop_Integration_Block_Adminhtml_Form_Edit_Tab_General extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* prepare form in tab
|
8 |
+
*/
|
9 |
+
protected function _prepareForm()
|
10 |
+
{
|
11 |
+
$helper = Mage::helper('pixelshop');
|
12 |
+
$form = new Varien_Data_Form();
|
13 |
+
$form->setHtmlIdPrefix('general_');
|
14 |
+
$form->setFieldNameSuffix('general');
|
15 |
+
|
16 |
+
// $fieldset = $form->addFieldset('display', array(
|
17 |
+
// 'legend' => $helper->__('Display Settings'),
|
18 |
+
// 'class' => 'fieldset-wide'
|
19 |
+
// ));
|
20 |
+
|
21 |
+
// $fieldset->addField('label', 'text', array(
|
22 |
+
// 'name' => 'label',
|
23 |
+
// 'label' => $helper->__('Label'),
|
24 |
+
// ));
|
25 |
+
|
26 |
+
$fieldset = $form->addField('submit', 'submit', array(
|
27 |
+
'value' => 'Export Products',
|
28 |
+
'after_element_html' => '<small></small>',
|
29 |
+
'class' => 'form-button',
|
30 |
+
'tabindex' => 1
|
31 |
+
));
|
32 |
+
|
33 |
+
$this->setForm($form);
|
34 |
+
return parent::_prepareForm();
|
35 |
+
}
|
36 |
+
|
37 |
+
}
|
app/code/community/Pixelshop/Integration/Block/Adminhtml/Form/Edit/Tabs.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pixelshop_Integration_Block_Adminhtml_Form_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Constructor
|
8 |
+
*/
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
$this->setId('edit_home_tabs');
|
13 |
+
$this->setDestElementId('edit_form');
|
14 |
+
$this->setTitle(Mage::helper('pixelshop')->__('Pixelshop'));
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* add tabs before output
|
19 |
+
*
|
20 |
+
* @return pixelshop_Block_Adminhtml_Form_Edit_Tabs
|
21 |
+
*/
|
22 |
+
protected function _beforeToHtml()
|
23 |
+
{
|
24 |
+
$this->addTab('general', array(
|
25 |
+
'label' => Mage::helper('pixelshop')->__('Export'),
|
26 |
+
'title' => Mage::helper('pixelshop')->__('Export'),
|
27 |
+
'content' => $this->getLayout()->createBlock('pixelshop/adminhtml_form_edit_tab_general')->toHtml(),
|
28 |
+
));
|
29 |
+
|
30 |
+
return parent::_beforeToHtml();
|
31 |
+
}
|
32 |
+
}
|
app/code/community/Pixelshop/Integration/Helper/Data.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Pixelshop_Integration_Helper_Data extends Mage_Core_Helper_Abstract {
|
3 |
+
}
|
app/code/community/Pixelshop/Integration/controllers/Adminhtml/ExportoController.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pixelshop_Integration_Adminhtml_ExportoController extends Mage_Adminhtml_Controller_Action
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* View form action
|
8 |
+
*/
|
9 |
+
public function indexAction()
|
10 |
+
{
|
11 |
+
// $this->_registryObject();
|
12 |
+
$this->loadLayout();
|
13 |
+
$this->_setActiveMenu('pixelshop/exporto');
|
14 |
+
$this->renderLayout();
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Grid Action
|
19 |
+
* Display list of products related to current category
|
20 |
+
*
|
21 |
+
* @return void
|
22 |
+
*/
|
23 |
+
public function saveAction()
|
24 |
+
{
|
25 |
+
if ( Mage::getStoreConfig( 'pixelshop/pixelshop/api_key' ) === '' )
|
26 |
+
{
|
27 |
+
Mage::getModel('core/session')->addError(Mage::helper('pixelshop')->__('Error! Pixelshop API Key missing.'));
|
28 |
+
|
29 |
+
$this->_redirect('*/*/');
|
30 |
+
}
|
31 |
+
|
32 |
+
$pixelshop = new Pixelshop_Pixelshop( Mage::getStoreConfig('pixelshop/pixelshop/api_key') );
|
33 |
+
|
34 |
+
$products = Mage::getModel('catalog/product')->getCollection();
|
35 |
+
$products->addAttributeToSelect('*');
|
36 |
+
|
37 |
+
$pixelshop_products = array();
|
38 |
+
|
39 |
+
$i = 0;
|
40 |
+
foreach( $products as $prod )
|
41 |
+
{
|
42 |
+
$sync_id = $prod->getId();
|
43 |
+
|
44 |
+
$_product = Mage::getModel('catalog/product')->load($sync_id);
|
45 |
+
|
46 |
+
$pixelshop_products[$i] = [
|
47 |
+
'sync_id' => $sync_id,
|
48 |
+
'link' => $_product->getProductUrl(),
|
49 |
+
'title' => $_product->getName(),
|
50 |
+
'description' => $_product->getShortDescription(),
|
51 |
+
'price' => $_product->getPrice(),
|
52 |
+
'tags' => $_product->getMetaKeyword()
|
53 |
+
];
|
54 |
+
|
55 |
+
if( $_product->getImage() && $_product->getImage() != 'no_selection' )
|
56 |
+
$pixelshop_products[$i]['thumb'] = $_product->getImageUrl();
|
57 |
+
|
58 |
+
$i++;
|
59 |
+
}
|
60 |
+
|
61 |
+
$export = $pixelshop->export->products($pixelshop_products);
|
62 |
+
|
63 |
+
if( isset($export['error']) )
|
64 |
+
{
|
65 |
+
Mage::getModel('core/session')->addError(Mage::helper('pixelshop')->__('Error! Pixelshop API Key incorrect.'));
|
66 |
+
}
|
67 |
+
else
|
68 |
+
{
|
69 |
+
Mage::getModel('core/session')->addSuccess(Mage::helper('pixelshop')->__('Success! %s Products success and %s products exists or with error.', $export['success'], $export['error'] + $export['exists']));
|
70 |
+
}
|
71 |
+
|
72 |
+
$this->_redirect('*/*/');
|
73 |
+
}
|
74 |
+
}
|
app/code/community/Pixelshop/Integration/controllers/IndexController.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pixelshop_Integration_IndexController extends Mage_Adminhtml_Controller_Action
|
4 |
+
{
|
5 |
+
|
6 |
+
public function indexAction()
|
7 |
+
{
|
8 |
+
$this->loadLayout();
|
9 |
+
$this->renderLayout();
|
10 |
+
}
|
11 |
+
|
12 |
+
}
|
app/code/community/Pixelshop/Integration/etc/adminhtml.xml
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<menu>
|
4 |
+
<pixelshop translate="title" module="pixelshop">
|
5 |
+
<title>Pixelshop</title>
|
6 |
+
<sort_order>90</sort_order>
|
7 |
+
<children>
|
8 |
+
<form translate="title" module="pixelshop">
|
9 |
+
<title>Export</title>
|
10 |
+
<sort_order>10</sort_order>
|
11 |
+
<action>adminhtml/exporto</action>
|
12 |
+
</form>
|
13 |
+
</children>
|
14 |
+
<children>
|
15 |
+
<settings translate="title" module="pixelshop">
|
16 |
+
<title>Settings</title>
|
17 |
+
<sort_order>2</sort_order>
|
18 |
+
<action>*/system_config/edit/section/pixelshop</action>
|
19 |
+
</settings>
|
20 |
+
</children>
|
21 |
+
</pixelshop>
|
22 |
+
</menu>
|
23 |
+
<acl>
|
24 |
+
<resources>
|
25 |
+
<all>
|
26 |
+
<title>Allow Everything</title>
|
27 |
+
</all>
|
28 |
+
<admin>
|
29 |
+
<children>
|
30 |
+
<pixelshop>
|
31 |
+
<title>Pixelshop</title>
|
32 |
+
<sort_order>90</sort_order>
|
33 |
+
<children>
|
34 |
+
<form>
|
35 |
+
<title>Export</title>
|
36 |
+
<sort_order>10</sort_order>
|
37 |
+
</form>
|
38 |
+
</children>
|
39 |
+
</pixelshop>
|
40 |
+
</children>
|
41 |
+
</admin>
|
42 |
+
</resources>
|
43 |
+
</acl>
|
44 |
+
</config>
|
app/code/community/Pixelshop/Integration/etc/config.xml
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Pixelshop_Integration>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</Pixelshop_Integration>
|
7 |
+
</modules>
|
8 |
+
|
9 |
+
<default>
|
10 |
+
<pixelshop>
|
11 |
+
<pixelshop>
|
12 |
+
<active>0</active>
|
13 |
+
<api_key></api_key>
|
14 |
+
</pixelshop>
|
15 |
+
<general>
|
16 |
+
<default_sort_by><![CDATA[position]]></default_sort_by>
|
17 |
+
</general>
|
18 |
+
</pixelshop>
|
19 |
+
</default>
|
20 |
+
|
21 |
+
<global>
|
22 |
+
<blocks>
|
23 |
+
<pixelshop>
|
24 |
+
<class>Pixelshop_Integration_Block</class>
|
25 |
+
</pixelshop>
|
26 |
+
</blocks>
|
27 |
+
|
28 |
+
<helpers>
|
29 |
+
<pixelshop>
|
30 |
+
<class>Pixelshop_Integration_Helper</class>
|
31 |
+
</pixelshop>
|
32 |
+
</helpers>
|
33 |
+
|
34 |
+
<models>
|
35 |
+
<pixelshop>
|
36 |
+
<class>Pixelshop_Integration_Model</class>
|
37 |
+
</pixelshop>
|
38 |
+
</models>
|
39 |
+
</global>
|
40 |
+
|
41 |
+
<admin>
|
42 |
+
<routers>
|
43 |
+
<adminhtml>
|
44 |
+
<args>
|
45 |
+
<modules>
|
46 |
+
<pixelshop after="Mage_Adminhtml">Pixelshop_Integration_Adminhtml</pixelshop>
|
47 |
+
</modules>
|
48 |
+
</args>
|
49 |
+
</adminhtml>
|
50 |
+
</routers>
|
51 |
+
</admin>
|
52 |
+
|
53 |
+
<adminhtml>
|
54 |
+
<layout>
|
55 |
+
<updates>
|
56 |
+
<pixelshop>
|
57 |
+
<file>pixelshop.xml</file>
|
58 |
+
</pixelshop>
|
59 |
+
</updates>
|
60 |
+
</layout>
|
61 |
+
|
62 |
+
<acl>
|
63 |
+
<resources>
|
64 |
+
<admin>
|
65 |
+
<children>
|
66 |
+
<system>
|
67 |
+
<children>
|
68 |
+
<config>
|
69 |
+
<children>
|
70 |
+
<pixelshop translate="title" module="pixelshop">
|
71 |
+
<title>Pixelshop Integration</title>
|
72 |
+
</pixelshop>
|
73 |
+
</children>
|
74 |
+
</config>
|
75 |
+
</children>
|
76 |
+
</system>
|
77 |
+
</children>
|
78 |
+
</admin>
|
79 |
+
</resources>
|
80 |
+
</acl>
|
81 |
+
</adminhtml>
|
82 |
+
</config>
|
app/code/community/Pixelshop/Integration/etc/system.xml
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
<sections>
|
5 |
+
<pixelshop>
|
6 |
+
<label>Pixelshop Integration</label>
|
7 |
+
<tab>general</tab>
|
8 |
+
<class>pixelshop</class>
|
9 |
+
<frontend_type>text</frontend_type>
|
10 |
+
<sort_order>1100</sort_order>
|
11 |
+
<show_in_default>1</show_in_default>
|
12 |
+
<show_in_website>1</show_in_website>
|
13 |
+
<show_in_store>1</show_in_store>
|
14 |
+
|
15 |
+
<groups>
|
16 |
+
<pixelshop translate="label" module="pixelshop">
|
17 |
+
<label>Pixelshop Integration</label>
|
18 |
+
<frontend_type>text</frontend_type>
|
19 |
+
<sort_order>10</sort_order>
|
20 |
+
<show_in_default>1</show_in_default>
|
21 |
+
<show_in_website>1</show_in_website>
|
22 |
+
<show_in_store>1</show_in_store>
|
23 |
+
<fields>
|
24 |
+
<api_key translate="label">
|
25 |
+
<label>API Key</label>
|
26 |
+
<frontend_type>text</frontend_type>
|
27 |
+
<sort_order>20</sort_order>
|
28 |
+
<show_in_default>1</show_in_default>
|
29 |
+
<show_in_website>1</show_in_website>
|
30 |
+
<show_in_store>1</show_in_store>
|
31 |
+
<comment>Enter the API Key provided by Pixelshop.</comment>
|
32 |
+
</api_key>
|
33 |
+
</fields>
|
34 |
+
</pixelshop>
|
35 |
+
</groups>
|
36 |
+
</pixelshop>
|
37 |
+
</sections>
|
38 |
+
</config>
|
app/design/adminhtml/default/default/layout/pixelshop.xml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout>
|
3 |
+
<adminhtml_system_config_edit>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="addCss"><stylesheet>pixelshop/integration/pixelshop.css</stylesheet></action>
|
6 |
+
</reference>
|
7 |
+
</adminhtml_system_config_edit>
|
8 |
+
|
9 |
+
<adminhtml_exporto_index>
|
10 |
+
<update handle="editor"/>
|
11 |
+
<remove name="content-header"/>
|
12 |
+
<reference name="content">
|
13 |
+
<block type="pixelshop/adminhtml_form_edit" name="adminform"/>
|
14 |
+
</reference>
|
15 |
+
<reference name="left">
|
16 |
+
<block type="pixelshop/adminhtml_form_edit_tabs" name="adminform_tabs"/>
|
17 |
+
</reference>
|
18 |
+
</adminhtml_exporto_index>
|
19 |
+
</layout>
|
lib/Pixelshop/Pixelshop.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once Mage::getBaseDir( 'lib' ) . '/Pixelshop/Pixelshop/Export.php';
|
4 |
+
|
5 |
+
class Pixelshop_Pixelshop {
|
6 |
+
|
7 |
+
public $apikey;
|
8 |
+
public $ch;
|
9 |
+
public $root = 'http://pixelshop.app/api/';
|
10 |
+
public $debug = false;
|
11 |
+
|
12 |
+
public function __construct($apikey=null) {
|
13 |
+
$this->apikey = $apikey;
|
14 |
+
|
15 |
+
$this->ch = curl_init();
|
16 |
+
curl_setopt($this->ch, CURLOPT_USERAGENT, 'Pixelshop-PHP/1.0.0');
|
17 |
+
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, false);
|
18 |
+
curl_setopt($this->ch, CURLOPT_POST, true);
|
19 |
+
curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true);
|
20 |
+
curl_setopt($this->ch, CURLOPT_HEADER, false);
|
21 |
+
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
|
22 |
+
curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, 30);
|
23 |
+
curl_setopt($this->ch, CURLOPT_TIMEOUT, 600);
|
24 |
+
|
25 |
+
$this->root = rtrim($this->root, '/') . '/';
|
26 |
+
|
27 |
+
$this->export = new Pixelshop_Export($this);
|
28 |
+
}
|
29 |
+
|
30 |
+
public function __destruct() {
|
31 |
+
curl_close($this->ch);
|
32 |
+
}
|
33 |
+
|
34 |
+
public function call($url, $params) {
|
35 |
+
$params['key'] = $this->apikey;
|
36 |
+
|
37 |
+
$params = json_encode($params);
|
38 |
+
|
39 |
+
$ch = $this->ch;
|
40 |
+
|
41 |
+
curl_setopt($ch, CURLOPT_URL, $this->root . $url);
|
42 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
43 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
|
44 |
+
curl_setopt($ch, CURLOPT_VERBOSE, $this->debug);
|
45 |
+
|
46 |
+
$start = microtime(true);
|
47 |
+
|
48 |
+
$this->log('Call to ' . $this->root . $url . ' ' . $params);
|
49 |
+
|
50 |
+
$response_body = curl_exec($ch);
|
51 |
+
$info = curl_getinfo($ch);
|
52 |
+
|
53 |
+
$time = microtime(true) - $start;
|
54 |
+
|
55 |
+
$this->log('Completed in ' . number_format($time * 1000, 2) . 'ms');
|
56 |
+
$this->log('Got response: ' . $response_body);
|
57 |
+
|
58 |
+
if(curl_error($ch)) {
|
59 |
+
throw new Exception("API call to $url failed: " . curl_error($ch));
|
60 |
+
}
|
61 |
+
|
62 |
+
$result = json_decode($response_body, true);
|
63 |
+
|
64 |
+
if( isset($result->error) ) throw new Exception('API Key not valid, Pixelshop API Error: ' . $result->error);
|
65 |
+
|
66 |
+
if($result === null) throw new Exception('We were unable to decode the JSON response from the Pixelshop API: ' . $response_body);
|
67 |
+
|
68 |
+
if(floor($info['http_code'] / 100) >= 4) {
|
69 |
+
throw $this->castError($result);
|
70 |
+
}
|
71 |
+
|
72 |
+
return $result;
|
73 |
+
}
|
74 |
+
|
75 |
+
public function castError($result) {
|
76 |
+
if($result['status'] !== 'error' || !$result['name']) throw new Exception('We received an unexpected error: ' . json_encode($result));
|
77 |
+
|
78 |
+
$class = (isset(self::$error_map[$result['name']])) ? self::$error_map[$result['name']] : 'Exception';
|
79 |
+
return new $class($result['message'], $result['code']);
|
80 |
+
}
|
81 |
+
|
82 |
+
public function log($msg) {
|
83 |
+
if($this->debug) error_log($msg);
|
84 |
+
}
|
85 |
+
}
|
lib/Pixelshop/Pixelshop/Export.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pixelshop_Export {
|
4 |
+
|
5 |
+
public function __construct(Pixelshop $master) {
|
6 |
+
$this->master = $master;
|
7 |
+
}
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Export product to Pixelshop through API
|
11 |
+
* @param products array an array of product information.
|
12 |
+
* - product[] struct a single product information.
|
13 |
+
* - link string url to the product to purchase
|
14 |
+
* - title string the product title
|
15 |
+
* - description string the product description
|
16 |
+
* - price integer the product price
|
17 |
+
* - thumb string url to the thumbnail
|
18 |
+
* - tags string comma seperated tags
|
19 |
+
* @return string status of the export
|
20 |
+
*/
|
21 |
+
public function products($products, $async=false) {
|
22 |
+
$_params = array("products" => $products, "async" => $async);
|
23 |
+
return $this->master->call('export', $_params);
|
24 |
+
}
|
25 |
+
}
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Pixelshop_Integration</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>GPL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Wordpress plugin for pixelshop.io Integration.</summary>
|
10 |
+
<description>Wordpress plugin for pixelshop.io Integration.</description>
|
11 |
+
<notes>Init Version.</notes>
|
12 |
+
<authors><author><name>Rafael Mor</name><user>MAG003256829</user><email>hello@pixelshop.io</email></author></authors>
|
13 |
+
<date>2016-01-04</date>
|
14 |
+
<time>00:13:42</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Pixelshop"><dir name="Integration"><dir name="Block"><dir name="Adminhtml"><dir name="Form"><dir name="Edit"><file name="Form.php" hash="0df16f804b101e2c97f9f6c4a7f494e8"/><dir name="Renderer"><file name="Label.php" hash="930fd900edbce86ba8a5b2d7beff0e98"/><file name="Multienabled.php" hash="301a459c880f8a9ebd46e1d751b61747"/></dir><dir name="Tab"><file name="General.php" hash="7f65cc6eae52d15367851713a86efb57"/></dir><file name="Tabs.php" hash="3081d5cd38467d7680a41bcfd01f583e"/></dir><file name="Edit.php" hash="f91b49add8cc9e0b3233e11fa03115ff"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="0884df2e4ec177a73d5a579ca274a015"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ExportoController.php" hash="03989dd2469d900cdfa291885351dd64"/></dir><file name="IndexController.php" hash="a25e29209d6f19149548833650ecf648"/></dir><dir name="etc"><file name="adminhtml.xml" hash="f9a835131ebdb683db9bc81341b40398"/><file name="config.xml" hash="147434bbf4c147ff85d41871632eae77"/><file name="system.xml" hash="0f2fa9ccc2bccf944582f922cd1aaa47"/></dir></dir></dir></target><target name="magelib"><dir name="Pixelshop"><dir name="Pixelshop"><file name="Export.php" hash="c380a11e2a726c84be2d5db6f01d1022"/></dir><file name="Pixelshop.php" hash="59923c917497b056ceb0cbda77b5fc57"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="pixelshop.xml" hash="370a0fd810b833fcf9d8e0380672c3c3"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="pixelshop"><dir name="integration"><file name="pixelshop.css" hash="4cb6365e6c3601fc759ca408410935b5"/></dir></dir></dir></dir></dir></target><target name="magelocal"><dir name="modules"><file name="Pixelshop_Integration.xml" hash=""/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><extension><name>curl</name><min/><max/></extension></required></dependencies>
|
18 |
+
</package>
|
skin/adminhtml/default/default/pixelshop/integration/pixelshop.css
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
ul.tabs a.pixelshop {
|
2 |
+
border-bottom:1px dotted;
|
3 |
+
}
|
4 |
+
ul.tabs a.pixelshop span,
|
5 |
+
ul.tabs a.pixelshop:hover span {
|
6 |
+
background-image:url(pixelshop-icon.png) !important;
|
7 |
+
background-repeat:no-repeat;
|
8 |
+
background-position:18px center;
|
9 |
+
padding-left:40px;
|
10 |
+
}
|