Virtooal_MagicMirror - Version 1.0.0

Version Notes

First Release

Download this release

Release Info

Developer Ondrej Bagin
Extension Virtooal_MagicMirror
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Virtooal/MagicMirror/Block/Adminhtml/Catalog/Product/Tab.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Virtooal_MagicMirror_Block_Adminhtml_Catalog_Product_Tab
3
+ extends Mage_Adminhtml_Block_Template
4
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
5
+ {
6
+ /**
7
+ * Set the template for the block
8
+ */
9
+ public function _construct()
10
+ {
11
+ parent::_construct();
12
+ $this->setTemplate('catalog/product/tab/magicmirror.phtml');
13
+ }
14
+
15
+ /**
16
+ * Retrieve currently edited product object
17
+ *
18
+ * @return Mage_Catalog_Model_Product
19
+ */
20
+ public function getProduct()
21
+ {
22
+ return Mage::registry('current_product');
23
+ }
24
+
25
+ public function getWidgetParameters()
26
+ {
27
+ $resource = Mage::getSingleton('core/resource');
28
+
29
+ /**
30
+ * Retrieve the read connection
31
+ */
32
+ $readConnection = $resource->getConnection('core_read');
33
+
34
+ /**
35
+ * Retrieve our table name
36
+ */
37
+ $prefix = Mage::getConfig()->getTablePrefix();
38
+
39
+ $query = $readConnection->query("SELECT * FROM ".$prefix."widget_instance WHERE instance_type='magicmirror/magicmirror' ORDER BY instance_id desc");
40
+
41
+ $row = $query->fetch();
42
+ if(!$row){
43
+ return null;
44
+ }
45
+ return unserialize($row['widget_parameters']);
46
+ }
47
+
48
+ /**
49
+ * Retrieve the label used for the tab relating to this block
50
+ *
51
+ * @return string
52
+ */
53
+ public function getTabLabel()
54
+ {
55
+ return $this->__('Add Magic Mirror');
56
+ }
57
+
58
+ /**
59
+ * Retrieve the title used by this tab
60
+ *
61
+ * @return string
62
+ */
63
+ public function getTabTitle()
64
+ {
65
+ return $this->__('Add Magic Mirror');
66
+ }
67
+
68
+ /**
69
+ * Determines whether to display the tab
70
+ * Add logic here to decide whether you want the tab to display
71
+ *
72
+ * @return bool
73
+ */
74
+ public function canShowTab()
75
+ {
76
+ return true;
77
+ }
78
+
79
+ /**
80
+ * Stops the tab being hidden
81
+ *
82
+ * @return bool
83
+ */
84
+ public function isHidden()
85
+ {
86
+ return false;
87
+ }
88
+ }
app/code/community/Virtooal/MagicMirror/Block/Magicmirror.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Virtooal Magic Mirror HTML5 Widget
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-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 info@sostanza.it so we can send you a copy immediately.
14
+ *
15
+ * @category Virtooal
16
+ * @package Virtooal_MagicMirror
17
+ * @copyright Copyright 2015 Eureco s.r.o. (http://www.virtooal.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ ?>
21
+ <?php
22
+ class Virtooal_MagicMirror_Block_Magicmirror extends Mage_Core_Block_Abstract implements Mage_Widget_Block_Interface
23
+ {
24
+
25
+ }
app/code/community/Virtooal/MagicMirror/Helper/Data.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Virtooal Magic Mirror HTML5 Widget
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-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 info@sostanza.it so we can send you a copy immediately.
14
+ *
15
+ * @category Virtooal
16
+ * @package Virtooal_MagicMirror
17
+ * @copyright Copyright 2015 Eureco s.r.o. (http://www.virtooal.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ ?>
21
+ <?php
22
+ class Virtooal_MagicMirror_Helper_Data extends Mage_Core_Helper_Abstract
23
+ {
24
+ /*******/
25
+ }
app/code/community/Virtooal/MagicMirror/Model/Language.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Virtooal_MagicMirror_Model_Language{
3
+ protected $_options;
4
+
5
+ public function toOptionArray(){
6
+ if (!$this->_options) {
7
+ $this->_options = array(
8
+ array(
9
+ 'value'=>'en',
10
+ 'label'=>Mage::helper('virtooal_magicmirror')->__('English'),
11
+ ),
12
+ array(
13
+ 'value'=>'de',
14
+ 'label'=>Mage::helper('virtooal_magicmirror')->__('Deutch'),
15
+ ),
16
+ array(
17
+ 'value'=>'fr',
18
+ 'label'=>Mage::helper('virtooal_magicmirror')->__('French'),
19
+ ),
20
+ array(
21
+ 'value'=>'pl',
22
+ 'label'=>Mage::helper('virtooal_magicmirror')->__('Polish'),
23
+ ),
24
+ array(
25
+ 'value'=>'hu',
26
+ 'label'=>Mage::helper('virtooal_magicmirror')->__('Hungarian'),
27
+ ),
28
+ array(
29
+ 'value'=>'cz',
30
+ 'label'=>Mage::helper('virtooal_magicmirror')->__('Czech'),
31
+ ),
32
+ array(
33
+ 'value'=>'sk',
34
+ 'label'=>Mage::helper('virtooal_magicmirror')->__('Slovak'),
35
+ ),
36
+
37
+
38
+ );
39
+ }
40
+ return $this->_options;
41
+ }
42
+ }
app/code/community/Virtooal/MagicMirror/Model/Observer.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Virtooal_MagicMirror_Model_Observer
4
+ {
5
+ public function insertBlock($observer)
6
+ {
7
+ /** @var $_block Mage_Core_Block_Abstract */
8
+ /*Get block instance*/
9
+ $_block = $observer->getBlock();
10
+ /*get Block type*/
11
+ $_type = $_block->getType();
12
+ /*get Block name*/
13
+ $_name = $_block->getNameInLayout();
14
+ /*Check block type*/
15
+ $position = Mage::getStoreConfig('magicmirror_options/magicmirror_settings/magicmirror_position');
16
+ $enable = Mage::getStoreConfig('magicmirror_options/magicmirror_settings/magicmirror_enable');
17
+
18
+ $position = explode('-',$position);
19
+ if ($enable==1
20
+ && $_type == 'catalog/'.$position[0]
21
+ && (!isset($position[1]) || (isset($position[1]) && $_name == $position[1])))
22
+ {
23
+ /*Clone block instance*/
24
+ $_child = clone $_block;
25
+ /*set another type for block*/
26
+ $_child->setType('magicmirror/block');
27
+ /*set child for block*/
28
+ $_block->setChild('child', $_child);
29
+ /*set our template*/
30
+ $_block->setTemplate('magicmirror/magicmirror.phtml');
31
+ }
32
+ }
33
+ }
app/code/community/Virtooal/MagicMirror/Model/Position.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Virtooal_MagicMirror_Model_Position{
3
+ protected $_options;
4
+ const POSITION_UNDERIMAGE = 'product_view_media';
5
+ const POSITION_UNDERCART = 'product_view-product.info.addtocart';
6
+ const POSITION_UNDERADDTO = 'product_view-product.info.addto';
7
+
8
+ public function toOptionArray(){
9
+ if (!$this->_options) {
10
+ $this->_options[] = array(
11
+ 'value'=>self::POSITION_UNDERIMAGE,
12
+ 'label'=>Mage::helper('virtooal_magicmirror')->__('Under product pictures')
13
+ );
14
+ $this->_options[] = array(
15
+ 'value'=>self::POSITION_UNDERCART,
16
+ 'label'=>Mage::helper('virtooal_magicmirror')->__('Under product "add to cart" button')
17
+ );
18
+ $this->_options[] = array(
19
+ 'value'=>self::POSITION_UNDERADDTO,
20
+ 'label'=>Mage::helper('virtooal_magicmirror')->__('Under "add to" links')
21
+ );
22
+ }
23
+ return $this->_options;
24
+ }
25
+ }
app/code/community/Virtooal/MagicMirror/controllers/Adminhtml/MagicmirrorController.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Virtooal Magic Mirror HTML5 Widget
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-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 info@sostanza.it so we can send you a copy immediately.
14
+ *
15
+ * @category Virtooal
16
+ * @package Virtooal_MagicMirror
17
+ * @copyright Copyright 2015 Eureco s.r.o. (http://www.virtooal.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ ?>
21
+ <?php
22
+ class Virtooal_MagicMirror_Adminhtml_MagicmirrorController extends Mage_Adminhtml_Controller_Action
23
+ {
24
+ private $query;
25
+
26
+ public function indexAction()
27
+ {
28
+ $this->loadLayout()->_setActiveMenu('virtooal_magicmirror_tab')->_title($this->__('Create Widget'));
29
+
30
+ $url = Mage::helper("adminhtml")->getUrl("adminhtml/system_config/edit/section/magicmirror_options/");
31
+ $this->getResponse()->setRedirect($url);
32
+ $this->renderLayout();
33
+ }
34
+
35
+ public function dashboardAction()
36
+ {
37
+ $this->loadLayout()->_setActiveMenu('virtooal_magicmirror_tab')->_title($this->__('Magic Mirror Admin'));
38
+ $langcode = Mage::getStoreConfig('magicmirror_options/magicmirror_settings/magicmirror_language');
39
+ $html = '<iframe src="http://setup.virtooal.com/'.$langcode.'/auth/index?url='.
40
+ rawurlencode(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)).
41
+ '&platform=magento" frameborder="0" width="100%" style="min-height: 1000px"></iframe>';
42
+ $block = $this->getLayout()
43
+ ->createBlock('core/text', 'magicmirror-admin-block')
44
+ ->setText($html);
45
+ $this->_addContent($block);
46
+
47
+ $this->renderLayout();
48
+ }
49
+
50
+ public function helpAction()
51
+ {
52
+ $this->loadLayout()->_setActiveMenu('virtooal_magicmirror_tab')->_title($this->__('Magic Mirror Help'));
53
+
54
+ $html = '
55
+ <div style="width: 900px; margin: 0 auto;">
56
+ <h1>'.$this->__('What is Magic Mirror?').'</h1>
57
+ <div style="clear: both;">
58
+ <div style="float: left; width: 680px;">
59
+ <p>The Magic Mirror add-ons from Virtooal allow your
60
+ customers to try products using their own photo. Your
61
+ conversions will grow and the number of complaints and
62
+ returns will be effectively reduced.</p>
63
+ <br />
64
+ <h2>'.$this->__('How it works').'</h2>
65
+
66
+ <p><strong>Setup:</strong></p>
67
+ <ol style="list-style-type: decimal; margin-left: 30px;">
68
+ <li>Go to Magic Mirror > Dashboard</li>
69
+ <li>Click on "Register & Subscribe" button</li>
70
+ <li>Choose the modules you want to use, choose payment type and fill in the registration form.</li>
71
+ <li>After subscribing and registering log in to your Magic Mirror Admin.</li>
72
+ <li>Setup your widget\'s colors, size and language.</li>
73
+ </ol>
74
+ <br />
75
+ <p><strong>Products integration:</strong></p>
76
+ <ol style="list-style-type: decimal; margin-left: 30px;">
77
+ <li>Go to Catalog > Manage Products and choose one of your products</li>
78
+ <li>On the left side navigation click on "Add Magic Mirror"</li>
79
+ <li>Login to your Magic Mirror Admin if you not logged in yet.</li>
80
+ <li>Choose from your active moduls and setup the product.</li>
81
+
82
+ </ol>
83
+
84
+ </div>
85
+ <div style="float: right; width: 200px;">
86
+ <img src="//setup.virtooal.com/assets/img/logo.png" alt="" />
87
+ </div>
88
+ </div>
89
+ </div>
90
+ ';
91
+ $block = $this->getLayout()
92
+ ->createBlock('core/text', 'magicmirror-help-block')
93
+ ->setText($html);
94
+ $this->_addContent($block);
95
+
96
+ $this->renderLayout();
97
+ }
98
+
99
+ }
app/code/community/Virtooal/MagicMirror/etc/adminhtml.xml ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <menu>
4
+ <virtooal_magicmirror_tab module="virtooal_magicmirror" translate="title">
5
+ <title>Magic Mirror</title>
6
+ <sort_order>10000</sort_order>
7
+ <children>
8
+ <index module="virtooal_magicmirror" translate="title">
9
+ <title>Configuration</title>
10
+ <sort_order>2</sort_order>
11
+ <action>adminhtml/magicmirror</action>
12
+ </index>
13
+ <help module="virtooal_magicmirror" translate="title">
14
+ <title>Help</title>
15
+ <sort_order>3</sort_order>
16
+ <action>adminhtml/magicmirror/help</action>
17
+ </help>
18
+ <dashboard module="virtooal_magicmirror" translate="title">
19
+ <title>Dashboard</title>
20
+ <sort_order>1</sort_order>
21
+ <action>adminhtml/magicmirror/dashboard</action>
22
+ </dashboard>
23
+ </children>
24
+ </virtooal_magicmirror_tab>
25
+ </menu>
26
+ <acl>
27
+ <resources>
28
+ <admin>
29
+ <children>
30
+ <custom translate="title" module="virtooal_magicmirror">
31
+ <title>Magic Mirror Controller</title>
32
+ <sort_order>-100</sort_order>
33
+ <children>
34
+ <index translate="title">
35
+ <title>Index Action</title>
36
+ <sort_order>2</sort_order>
37
+ </index>
38
+ <help translate="title">
39
+ <title>Help Action</title>
40
+ <sort_order>3</sort_order>
41
+ </help>
42
+ <dashboard translate="title">
43
+ <title>Dashboard Action</title>
44
+ <sort_order>1</sort_order>
45
+ </dashboard>
46
+ </children>
47
+ </custom>
48
+ </children>
49
+ </admin>
50
+ </resources>
51
+ </acl>
52
+ </config>
app/code/community/Virtooal/MagicMirror/etc/config.xml ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Virtooal_MagicMirror>
5
+ <version>1.0.0</version>
6
+ </Virtooal_MagicMirror>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <virtooal_magicmirror>
11
+ <class>Virtooal_MagicMirror_Model</class>
12
+ </virtooal_magicmirror>
13
+ </models>
14
+ <helpers>
15
+ <virtooal_magicmirror>
16
+ <class>Virtooal_MagicMirror_Helper</class>
17
+ </virtooal_magicmirror>
18
+ </helpers>
19
+ <blocks>
20
+ <magicmirror>
21
+ <class>Virtooal_MagicMirror_Block</class>
22
+ </magicmirror>
23
+ </blocks>
24
+ </global>
25
+ <frontend>
26
+ <layout>
27
+ <updates>
28
+ <magicmirror>
29
+ <file>magicmirror.xml</file>
30
+ </magicmirror>
31
+ </updates>
32
+ </layout>
33
+ <events>
34
+ <core_block_abstract_to_html_before>
35
+ <observers>
36
+ <virtooal_magicmirror>
37
+ <type>model</type>
38
+ <class>virtooal_magicmirror/observer</class>
39
+ <method>insertBlock</method>
40
+ </virtooal_magicmirror>
41
+ </observers>
42
+ </core_block_abstract_to_html_before>
43
+ </events>
44
+ </frontend>
45
+ <adminhtml>
46
+ <layout>
47
+ <updates>
48
+ <magicmirror>
49
+ <file>magicmirror.xml</file>
50
+ </magicmirror>
51
+ </updates>
52
+ </layout>
53
+ <acl>
54
+ <resources>
55
+ <admin>
56
+ <children>
57
+ <system>
58
+ <children>
59
+ <config>
60
+ <children>
61
+ <magicmirror_options>
62
+ <title>Store Magic Mirror Module Section</title>
63
+ </magicmirror_options>
64
+ </children>
65
+ </config>
66
+ </children>
67
+ </system>
68
+ </children>
69
+ </admin>
70
+ </resources>
71
+ </acl>
72
+ </adminhtml>
73
+ <admin>
74
+ <routers>
75
+ <adminhtml>
76
+ <use>admin</use>
77
+ <args>
78
+ <modules>
79
+ <virtooal_magicmirror before="Mage_Adminhtml">Virtooal_MagicMirror_Adminhtml</virtooal_magicmirror>
80
+ </modules>
81
+ </args>
82
+ </adminhtml>
83
+ </routers>
84
+ </admin>
85
+ </config>
app/code/community/Virtooal/MagicMirror/etc/system.xml ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <magicmirrorconfig translate="label" module="virtooal_magicmirror">
5
+ <label>Virtooal</label>
6
+ <sort_order>1</sort_order>
7
+ </magicmirrorconfig>
8
+ </tabs>
9
+ <sections>
10
+ <magicmirror_options translate="label" module="virtooal_magicmirror">
11
+ <label>Magic Mirror Configuration</label>
12
+ <tab>magicmirrorconfig</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>1000</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <magicmirror_settings translate="label">
20
+ <label>Magic Mirror Widget Settings</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>1</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <magicmirror_enable translate="label">
28
+ <label>Enable extension</label>
29
+ <frontend_type>select</frontend_type>
30
+ <sort_order>10</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ <source_model>adminhtml/system_config_source_yesno</source_model>
35
+ </magicmirror_enable>
36
+ <magicmirror_apikey translate="label">
37
+ <label>Virtooal API key</label>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>20</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ </magicmirror_apikey>
44
+ <magicmirror_username translate="label">
45
+ <label>Virtooal user name</label>
46
+ <frontend_type>text</frontend_type>
47
+ <sort_order>30</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ </magicmirror_username>
52
+ <magicmirror_position translate="label">
53
+ <label>Widget position</label>
54
+ <frontend_type>select</frontend_type>
55
+ <source_model>virtooal_magicmirror/position</source_model>
56
+ <sort_order>40</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ </magicmirror_position>
61
+ <magicmirror_language translate="label">
62
+ <label>Admin language</label>
63
+ <frontend_type>select</frontend_type>
64
+ <source_model>virtooal_magicmirror/language</source_model>
65
+ <sort_order>50</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
+ </magicmirror_language>
70
+ </fields>
71
+ </magicmirror_settings>
72
+ </groups>
73
+ </magicmirror_options>
74
+ </sections>
75
+ </config>
app/design/adminhtml/default/default/layout/magicmirror.xml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <adminhtml_catalog_product_edit>
4
+ <reference name="product_tabs">
5
+ <action method="addTab">
6
+ <name>add_magic_mirror</name>
7
+ <block>magicmirror/adminhtml_catalog_product_tab</block>
8
+ </action>
9
+ </reference>
10
+ </adminhtml_catalog_product_edit>
11
+ </layout>
app/design/adminhtml/default/default/template/catalog/product/tab/magicmirror.phtml ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $_product = $this->getProduct();
3
+ $has_real_image_set = ($_product->getSmallImage() != null && $_product->getSmallImage() != "no_selection");
4
+
5
+ $api_key = Mage::getStoreConfig('magicmirror_options/magicmirror_settings/magicmirror_apikey');
6
+ $langcode = Mage::getStoreConfig('magicmirror_options/magicmirror_settings/magicmirror_language');
7
+ ?>
8
+
9
+ <script>
10
+ /* JSON-P implementation for Prototype.js somewhat by Dan Dean (http://www.dandean.com)
11
+ *
12
+ * *HEAVILY* based on Tobie Langel's version: http://gist.github.com/145466.
13
+ * Might as well just call this an iteration.
14
+ *
15
+ * This version introduces:
16
+ * - Support for predefined callbacks (Necessary for OAuth signed requests, by @rboyce)
17
+ * - Partial integration with Ajax.Responders (Thanks to @sr3d for the kick in this direction)
18
+ * - Compatibility with Prototype 1.7 (Thanks to @soung3 for the bug report)
19
+ * - Will not break if page lacks a <head> element
20
+ *
21
+ * See examples in README for usage
22
+ *
23
+ * VERSION 1.1.2
24
+ *
25
+ * new Ajax.JSONRequest(url, options);
26
+ * - url (String): JSON-P endpoint url.
27
+ * - options (Object): Configuration options for the request.
28
+ */
29
+ Ajax.JSONRequest = Class.create(Ajax.Base, (function() {
30
+ var id = 0, head = document.getElementsByTagName('head')[0] || document.body;
31
+ return {
32
+ initialize : function($super, url, options) {
33
+ $super(options);
34
+ this.options.url = url;
35
+ this.options.callbackParamName = this.options.callbackParamName || 'callback';
36
+ this.options.timeout = this.options.timeout || 10;
37
+ // Default timeout: 10 seconds
38
+ this.options.invokeImmediately = (!Object.isUndefined(this.options.invokeImmediately)) ? this.options.invokeImmediately : true;
39
+
40
+ if (!Object.isUndefined(this.options.parameters) && Object.isString(this.options.parameters)) {
41
+ this.options.parameters = this.options.parameters.toQueryParams();
42
+ }
43
+
44
+ if (this.options.invokeImmediately) {
45
+ this.request();
46
+ }
47
+ },
48
+
49
+ /**
50
+ * Ajax.JSONRequest#_cleanup() -> undefined
51
+ * Cleans up after the request
52
+ **/
53
+ _cleanup : function() {
54
+ if (this.timeout) {
55
+ clearTimeout(this.timeout);
56
+ this.timeout = null;
57
+ }
58
+ if (this.transport && Object.isElement(this.transport)) {
59
+ this.transport.remove();
60
+ this.transport = null;
61
+ }
62
+ },
63
+
64
+ /**
65
+ * Ajax.JSONRequest#request() -> undefined
66
+ * Invokes the JSON-P request lifecycle
67
+ **/
68
+ request : function() {
69
+
70
+ // Define local vars
71
+ var response = new Ajax.JSONResponse(this);
72
+ var key = this.options.callbackParamName, name = '_prototypeJSONPCallback_' + (id++), complete = function() {
73
+ if (Object.isFunction(this.options.onComplete)) {
74
+ this.options.onComplete.call(this, response);
75
+ }
76
+ Ajax.Responders.dispatch('onComplete', this, response);
77
+ }.bind(this);
78
+
79
+ // If the callback parameter is already defined, use that
80
+ if (this.options.parameters[key] !== undefined) {
81
+ name = this.options.parameters[key];
82
+ }
83
+ // Otherwise, add callback as a parameter
84
+ else {
85
+ this.options.parameters[key] = name;
86
+ }
87
+
88
+ // Build request URL
89
+ this.options.parameters[key] = name;
90
+ var url = this.options.url + ((this.options.url.include('?') ? '&' : '?') + Object.toQueryString(this.options.parameters));
91
+
92
+ // Define callback function
93
+ window[name] = function(json) {
94
+ this._cleanup();
95
+ // Garbage collection
96
+ window[name] = undefined;
97
+
98
+ response.status = 200;
99
+ response.statusText = "OK";
100
+ response.setResponseContent(json);
101
+
102
+ if (Object.isFunction(this.options.onSuccess)) {
103
+ this.options.onSuccess.call(this, response);
104
+ }
105
+ Ajax.Responders.dispatch('onSuccess', this, response);
106
+
107
+ complete();
108
+
109
+ }.bind(this);
110
+
111
+ this.transport = new Element('script', {
112
+ type : 'text/javascript',
113
+ src : url
114
+ });
115
+
116
+ if (Object.isFunction(this.options.onCreate)) {
117
+ this.options.onCreate.call(this, response);
118
+ }
119
+ Ajax.Responders.dispatch('onCreate', this);
120
+
121
+ head.appendChild(this.transport);
122
+
123
+ this.timeout = setTimeout( function() {
124
+ this._cleanup();
125
+ window[name] = Prototype.emptyFunction;
126
+ if (Object.isFunction(this.options.onFailure)) {
127
+ response.status = 504;
128
+ response.statusText = "Gateway Timeout";
129
+ this.options.onFailure.call(this, response);
130
+ }
131
+ complete();
132
+ }.bind(this), this.options.timeout * 1000);
133
+ },
134
+ toString : function() {
135
+ return "[object Ajax.JSONRequest]";
136
+ }
137
+ };
138
+ })());
139
+
140
+ Ajax.JSONResponse = Class.create({
141
+ initialize : function(request) {
142
+ this.request = request;
143
+ },
144
+ request : undefined,
145
+ status : 0,
146
+ statusText : '',
147
+ responseJSON : undefined,
148
+ responseText : undefined,
149
+ setResponseContent : function(json) {
150
+ this.responseJSON = json;
151
+ this.responseText = Object.toJSON(json);
152
+ },
153
+ getTransport : function() {
154
+ if (this.request)
155
+ return this.request.transport;
156
+ },
157
+ toString : function() {
158
+ return "[object Ajax.JSONResponse]";
159
+ }
160
+ });
161
+ new Ajax.JSONRequest('https://setup.virtooal.com/widget/ajax', {
162
+ callbackParamName: "callback",
163
+ parameters: {
164
+ img : '<?php echo $has_real_image_set?$_product->getImageUrl():''; ?>',
165
+ api_key : '<?php echo $apikey; ?>',
166
+ product_id : '<?php echo $_product->getId() ?>',
167
+ iframe : 1,
168
+ },
169
+ onSuccess: function(response) {
170
+ document.getElementById('virtooal-admin-container').innerHTML = '<iframe src="http://setup.virtooal.com/<?php echo $langcode ?>/auth/index" frameborder="0" width="100%" style="min-height: 1000px"></iframe>';
171
+ }
172
+ });
173
+
174
+ </script>
175
+ <div id="virtooal-admin-container"></div>
app/design/frontend/default/default/template/magicmirror/magicmirror.phtml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ echo $this->getChildHtml('child');
4
+
5
+ $username = Mage::getStoreConfig('magicmirror_options/magicmirror_settings/magicmirror_username');
6
+ $api_key = Mage::getStoreConfig('magicmirror_options/magicmirror_settings/magicmirror_apikey');
7
+ $product_id = Mage::registry('current_product')->getId();
8
+
9
+ $locale = substr(Mage::app()->getLocale()->getLocaleCode(),0,2);
10
+
11
+ ?>
12
+ <script charset="utf-8" id="gallery-widget" src="https://widget.virtooal.com/magicmirror.php?uname=<?php echo $username; ?>&apikey=<?php echo $api_key; ?>&lang=<?php echo $locale; ?>&pid=<?php echo $product_id; ?>"></script>
13
+
14
+ <div class="virtooal-widget">
15
+ <div class="gw-container"
16
+ data-modal_color = "#31859b"
17
+ data-plus_color = "#b7dde8"
18
+ data-modal_opacity = "0.8"
19
+ data-thumbwidth="73"></div>
20
+ </div>
app/etc/modules/Virtooal_MagicMirror.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Virtooal_MagicMirror>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Virtooal_MagicMirror>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Virtooal_MagicMirror</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>The Magic Mirror widget from Virtooal allow your customers to try products virtually using their own photos. </summary>
10
+ <description>Magic mirror is a fun and easy way to virtually try out a vast selection of accessories, apparel, make-up, glasses, contact lenses, jewelry and many more... on customer's own photo. The user-friendly HTML5 widget can be implemented and edited with no programming skills.&#xD;
11
+ Magic mirror rapidly increases conversion rates and customer satisfaction, reduces the amount of product returns and curbs the number of complaints.&#xD;
12
+ Magic mirror is an amazing shopping assistant. Just browse in the e-shop and products are instantly displayed on photos of models and users alike. Using Magic mirror means a lot of fun which attracts visitors like a magnet and they will gladly return to your site to use Magic mirror and buy your products over and over again.</description>
13
+ <notes>First Release</notes>
14
+ <authors><author><name>Ondrej Bagin</name><user>obagin</user><email>bagin@maxifashion.cz</email></author><author><name>Balazs Bosternak</name><user>bbosternak</user><email>bosternak@virtooal.com</email></author></authors>
15
+ <date>2015-08-03</date>
16
+ <time>12:41:50</time>
17
+ <contents><target name="magecommunity"><dir name="Virtooal"><dir name="MagicMirror"><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><file name="Tab.php" hash="0eb9a7e816b4e1536a025f57732bf6ec"/></dir></dir></dir><file name="Magicmirror.php" hash="5ab5fc06ad85b2f6d3b8569f9a63d237"/></dir><dir name="Helper"><file name="Data.php" hash="7e1312bd6da9025bbccc16eb29964471"/></dir><dir name="Model"><file name="Language.php" hash="1af04bab40f9f233cb447409fe7307ce"/><file name="Observer.php" hash="b39bd87085aaa4764c952ef478813178"/><file name="Position.php" hash="7ab3837dbbda98ba5c4b8d93aad3f780"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="MagicmirrorController.php" hash="db0374381a5292118d9ad7e4ddef7fd3"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="7b9b79c4450c0bfe24081733169e87db"/><file name="config.xml" hash="d683066a2e7a5a44c783ed6dd863068f"/><file name="system.xml" hash="594b86b327b8c11be87c8363c354607a"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="magicmirror.xml" hash="af6875ff48105d4b77691b25e52ac70a"/></dir><dir name="template"><dir name="catalog"><dir name="product"><dir name="tab"><file name="magicmirror.phtml" hash="2bf072a0c5eb92a0da2c017e3ab45374"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="magicmirror"><file name="magicmirror.phtml" hash="282e8dc000b6eb76040d649fbf848127"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Virtooal_MagicMirror.xml" hash="00de0598819946f446ce021d44bf70e6"/></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
20
+ </package>