Version Notes
-
Download this release
Release Info
Developer | John Weissberg |
Extension | Print_Science_Designer_Web_to_Print |
Version | 1.0.4 |
Comparing to | |
See all releases |
Code changes from version 1.0.3 to 1.0.4
- app/code/local/PrintScience/Personalization/Block/Checkout/Cart/Item/Renderer.php +18 -0
- app/code/local/PrintScience/Personalization/Model/ApiGateway.php +29 -0
- app/code/local/PrintScience/Personalization/Model/Observer.php +7 -0
- app/code/local/PrintScience/Personalization/controllers/IndexController.php +118 -0
- app/design/frontend/base/default/template/printscience_personalization/checkout/cart/item/default.phtml +1 -1
- package.xml +4 -4
app/code/local/PrintScience/Personalization/Block/Checkout/Cart/Item/Renderer.php
CHANGED
@@ -37,6 +37,24 @@ class PrintScience_Personalization_Block_Checkout_Cart_Item_Renderer extends Mag
|
|
37 |
return $url;
|
38 |
}
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
/**
|
41 |
* Get URLs of personalization preview images
|
42 |
*
|
37 |
return $url;
|
38 |
}
|
39 |
|
40 |
+
/**
|
41 |
+
* Get resume personalization URL for cart item in checkout page
|
42 |
+
*
|
43 |
+
* @return string | false
|
44 |
+
*/
|
45 |
+
public function getResumePersonalizationUrl($productId)
|
46 |
+
{
|
47 |
+
$apiSessionKey = $this->getPersonalizationApiSessionKey();
|
48 |
+
if (!$apiSessionKey) {
|
49 |
+
return false;
|
50 |
+
}
|
51 |
+
$url = Mage::getUrl('personalization/index/resumeShoppingCart', array(
|
52 |
+
'api_session_key' => $apiSessionKey,
|
53 |
+
'product' => $productId
|
54 |
+
));
|
55 |
+
return $url;
|
56 |
+
}
|
57 |
+
|
58 |
/**
|
59 |
* Get URLs of personalization preview images
|
60 |
*
|
app/code/local/PrintScience/Personalization/Model/ApiGateway.php
CHANGED
@@ -69,4 +69,33 @@ class PrintScience_Personalization_Model_ApiGateway
|
|
69 |
|
70 |
$client->send($function);
|
71 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
}
|
69 |
|
70 |
$client->send($function);
|
71 |
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Calls resumePersonalization API function and returns response.
|
75 |
+
*
|
76 |
+
* @param int $templateId
|
77 |
+
* @param string $successUrl
|
78 |
+
* @param string $failUrl
|
79 |
+
* @param string $cancelUrl
|
80 |
+
* @return PrintScience_Personalization_Model_ApiGateway_Response_Begin
|
81 |
+
*/
|
82 |
+
public function resumePersonalization($sessionKey, $templateId, $successUrl, $failUrl, $cancelUrl)
|
83 |
+
{
|
84 |
+
$client = new xmlrpc_client(Mage::getStoreConfig('catalog/personalization/api_url'));
|
85 |
+
|
86 |
+
$function = new xmlrpcmsg('resumePersonalization', array(
|
87 |
+
php_xmlrpc_encode(Mage::getStoreConfig('catalog/personalization/api_username')),
|
88 |
+
php_xmlrpc_encode(Mage::getStoreConfig('catalog/personalization/api_password')),
|
89 |
+
php_xmlrpc_encode($sessionKey),
|
90 |
+
php_xmlrpc_encode($templateId),
|
91 |
+
php_xmlrpc_encode($successUrl),
|
92 |
+
php_xmlrpc_encode($failUrl),
|
93 |
+
php_xmlrpc_encode($cancelUrl),
|
94 |
+
php_xmlrpc_encode('')
|
95 |
+
));
|
96 |
+
|
97 |
+
$response = $client->send($function);
|
98 |
+
|
99 |
+
return new PrintScience_Personalization_Model_ApiGateway_Response_Begin($response);
|
100 |
+
}
|
101 |
}
|
app/code/local/PrintScience/Personalization/Model/Observer.php
CHANGED
@@ -22,9 +22,16 @@ class PrintScience_Personalization_Model_Observer
|
|
22 |
$this->_observer = $observer;
|
23 |
|
24 |
$controller = $observer->getControllerAction();
|
|
|
|
|
|
|
|
|
|
|
25 |
if (($controller->getFullActionName() == 'checkout_cart_add')
|
26 |
&& (!Mage::registry('PrintScience_Personalization_calledFromSuccessAction'))) {
|
27 |
$this->startPersonalization();
|
|
|
|
|
28 |
}
|
29 |
}
|
30 |
|
22 |
$this->_observer = $observer;
|
23 |
|
24 |
$controller = $observer->getControllerAction();
|
25 |
+
$sessionHelper = Mage::helper('printscience_personalization/session');
|
26 |
+
$request = Mage::app()->getRequest();
|
27 |
+
|
28 |
+
$sessionKey = $request->getParam('api_session_key');
|
29 |
+
|
30 |
if (($controller->getFullActionName() == 'checkout_cart_add')
|
31 |
&& (!Mage::registry('PrintScience_Personalization_calledFromSuccessAction'))) {
|
32 |
$this->startPersonalization();
|
33 |
+
}elseif($sessionKey !='' && strcasecmp($controller->getFullActionName(), 'printscience_personalization_index_resumeShoppingCart') === 0){
|
34 |
+
//$this->startPersonalization();
|
35 |
}
|
36 |
}
|
37 |
|
app/code/local/PrintScience/Personalization/controllers/IndexController.php
CHANGED
@@ -40,6 +40,124 @@ class PrintScience_Personalization_IndexController extends Mage_Core_Controller_
|
|
40 |
$this->_redirectUrl($cartItemData['appUrl']);
|
41 |
}
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
/**
|
44 |
* Personalization success action handler.
|
45 |
*
|
40 |
$this->_redirectUrl($cartItemData['appUrl']);
|
41 |
}
|
42 |
|
43 |
+
/**
|
44 |
+
* Personalization startShoppingCart action handler
|
45 |
+
*
|
46 |
+
* @return boolean
|
47 |
+
*/
|
48 |
+
public function resumeShoppingCartAction()
|
49 |
+
{
|
50 |
+
$session = Mage::getSingleton('core/session');
|
51 |
+
$sessionHelper = Mage::helper('printscience_personalization/session');
|
52 |
+
$quoteHelper = Mage::helper('printscience_personalization/quote');
|
53 |
+
$request = $this->getRequest();
|
54 |
+
$errorUrl = 'checkout/cart';
|
55 |
+
|
56 |
+
$apiSessionKey = $request->getParam('api_session_key');
|
57 |
+
$productId = intval($request->getParam('product'));
|
58 |
+
$product = Mage::getModel('catalog/product')
|
59 |
+
->setStoreId(Mage::app()->getStore()->getId())
|
60 |
+
->load($productId);
|
61 |
+
if (!$product->getId()) {
|
62 |
+
$session->addError($this->__('Invalid request.'));
|
63 |
+
$this->_redirect($errorUrl);
|
64 |
+
return false;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Check if personalization is enabled for this product.
|
69 |
+
* If this is simple product then we need to check its 'personalization_enabled' attribute.
|
70 |
+
* If this is configurable product then we need to check 'personalization_enabled' attribute of its subproduct.
|
71 |
+
* No other product types are supported.
|
72 |
+
*/
|
73 |
+
$isValidProduct = true;
|
74 |
+
|
75 |
+
$productTypeId = $product->getTypeId();
|
76 |
+
if ($productTypeId == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
|
77 |
+
if (!$product->getPersonalizationEnabled()) {
|
78 |
+
$isValidProduct = false;
|
79 |
+
}
|
80 |
+
} elseif ($productTypeId == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
|
81 |
+
$attributes = $request->getParam('super_attribute');
|
82 |
+
$product = $product->getTypeInstance()->getProductByAttributes($attributes);
|
83 |
+
if ((!$product) || (!$product->getPersonalizationEnabled())) {
|
84 |
+
$isValidProduct = false;
|
85 |
+
}
|
86 |
+
} else {
|
87 |
+
$isValidProduct = false;
|
88 |
+
}
|
89 |
+
|
90 |
+
if (!$isValidProduct) {
|
91 |
+
$session->addError($this->__('Invalid Product.'));
|
92 |
+
$this->_redirect($errorUrl);
|
93 |
+
return false;
|
94 |
+
}
|
95 |
+
// check if template ID is valid
|
96 |
+
$templateId = $product->getPersonalizationTemplateId();
|
97 |
+
if (!$templateId) {
|
98 |
+
$session->addError($controller->__('Unable to start personalization: template ID is empty.'));
|
99 |
+
$this->_redirect($errorUrl);
|
100 |
+
return false;
|
101 |
+
}
|
102 |
+
|
103 |
+
$isValidRequest = false;
|
104 |
+
if ($apiSessionKey) {
|
105 |
+
$cartItem = $quoteHelper->getCartItemByApiSessionKey($apiSessionKey);
|
106 |
+
if ($cartItem) {
|
107 |
+
$isValidRequest = true;
|
108 |
+
}
|
109 |
+
}
|
110 |
+
if (!$isValidRequest) {
|
111 |
+
$session->addError($this->__('Invalid request.'));
|
112 |
+
$this->_redirect($errorUrl);
|
113 |
+
return false;
|
114 |
+
}
|
115 |
+
|
116 |
+
$cartItemData = $quoteHelper->getItemData($cartItem);
|
117 |
+
|
118 |
+
$sessionHelper->addData($cartItemData['sessionKey'], array(
|
119 |
+
'apiSessionKey' => $cartItemData['apiSessionKey'],
|
120 |
+
));
|
121 |
+
$sessionKey = $cartItemData['sessionKey'];
|
122 |
+
$sessionKey = $sessionHelper->generateKey();
|
123 |
+
|
124 |
+
$buyRequestParams = $request->getParams();
|
125 |
+
if (isset($buyRequestParams['uenc'])) {
|
126 |
+
unset($buyRequestParams['uenc']);
|
127 |
+
}
|
128 |
+
$returnUrlParams['_query'] = $buyRequestParams;
|
129 |
+
$returnUrlParams['personalization_session_key'] = $apiSessionKey;
|
130 |
+
|
131 |
+
$successUrl = Mage::getUrl('personalization/index/success', $returnUrlParams);
|
132 |
+
$failUrl = Mage::getUrl('personalization/index/fail', $returnUrlParams);
|
133 |
+
$cancelUrl = Mage::getUrl('personalization/index/cancel', $returnUrlParams);
|
134 |
+
|
135 |
+
// begin personalization
|
136 |
+
$apiGateway = Mage::getModel('printscience_personalization/apiGateway');
|
137 |
+
$apiResponse = $apiGateway->resumePersonalization($apiSessionKey, $templateId, $successUrl, $failUrl, $cancelUrl);
|
138 |
+
if (!$apiResponse) {
|
139 |
+
$session->addError($this->__('Unable to start personalization: API response was empty.'));
|
140 |
+
$this->_redirect($errorUrl);
|
141 |
+
return false;
|
142 |
+
}
|
143 |
+
if ($apiResponse->getFaultCode()) {
|
144 |
+
$session->addError($this->__('Unable to start personalization: ' . $apiResponse->getFaultString()));
|
145 |
+
$this->_redirect($errorUrl);
|
146 |
+
return false;
|
147 |
+
}
|
148 |
+
$apiSessionKey = $apiResponse->getSessionKey();
|
149 |
+
$appUrl = $apiResponse->getAppUrl();
|
150 |
+
|
151 |
+
$sessionHelper->addData($apiSessionKey, array(
|
152 |
+
'apiSessionKey' => $apiSessionKey,
|
153 |
+
'appUrl' => $appUrl,
|
154 |
+
'buyRequest' => serialize($buyRequestParams)
|
155 |
+
));
|
156 |
+
|
157 |
+
$this->_redirectUrl($appUrl);
|
158 |
+
return false;
|
159 |
+
}
|
160 |
+
|
161 |
/**
|
162 |
* Personalization success action handler.
|
163 |
*
|
app/design/frontend/base/default/template/printscience_personalization/checkout/cart/item/default.phtml
CHANGED
@@ -15,7 +15,7 @@ $isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility();
|
|
15 |
<?php endforeach; ?>
|
16 |
</div>
|
17 |
<div>
|
18 |
-
<button type="button" title="<?php echo $this->__('
|
19 |
</div>
|
20 |
<?php else: ?>
|
21 |
<?php if ($this->hasProductUrl()):?><a href="<?php echo $this->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getProductName()) ?>" class="product-image"><?php endif;?><img src="<?php echo $this->getProductThumbnail()->resize(75); ?>" width="75" height="75" alt="<?php echo $this->htmlEscape($this->getProductName()) ?>" /><?php if ($this->hasProductUrl()):?></a><?php endif;?>
|
15 |
<?php endforeach; ?>
|
16 |
</div>
|
17 |
<div>
|
18 |
+
<button type="button" title="<?php echo $this->__('Re-edit') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getResumePersonalizationUrl($_item->getProduct()->getId()) ?>')"><span><span><?php echo $this->__('Re-edit') ?></span></span></button>
|
19 |
</div>
|
20 |
<?php else: ?>
|
21 |
<?php if ($this->hasProductUrl()):?><a href="<?php echo $this->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getProductName()) ?>" class="product-image"><?php endif;?><img src="<?php echo $this->getProductThumbnail()->resize(75); ?>" width="75" height="75" alt="<?php echo $this->htmlEscape($this->getProductName()) ?>" /><?php if ($this->hasProductUrl()):?></a><?php endif;?>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Print_Science_Designer_Web_to_Print</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL v3.0</license>
|
7 |
<channel>community</channel>
|
@@ -10,9 +10,9 @@
|
|
10 |
<description>Print Science designer component</description>
|
11 |
<notes>-</notes>
|
12 |
<authors><author><name>John Weissberg</name><user>johnwwweissberg</user><email>jw@print-science.com</email></author></authors>
|
13 |
-
<date>
|
14 |
-
<time>
|
15 |
-
<contents><target name="magelocal"><dir name="PrintScience"><dir
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Print_Science_Designer_Web_to_Print</name>
|
4 |
+
<version>1.0.4</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL v3.0</license>
|
7 |
<channel>community</channel>
|
10 |
<description>Print Science designer component</description>
|
11 |
<notes>-</notes>
|
12 |
<authors><author><name>John Weissberg</name><user>johnwwweissberg</user><email>jw@print-science.com</email></author></authors>
|
13 |
+
<date>2012-02-27</date>
|
14 |
+
<time>04:04:37</time>
|
15 |
+
<contents><target name="magelocal"><dir name="PrintScience"><dir name="Personalization"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="View"><dir name="Items"><file name="Renderer.php" hash="e9a0dcb549311ea6f4e3992bbc9a4b5c"/></dir></dir></dir></dir></dir><dir name="Checkout"><dir name="Cart"><dir name="Item"><file name="Renderer.php" hash="bc381f400a32aef7a05898b3a2ba2854"/></dir></dir></dir></dir><dir name="Helper"><file name="Order.php" hash="ba50cbfb5f647cbca2deae91153db9b7"/><file name="Output.php" hash="850a4a708a2dd67a5f3f71ee93087740"/><file name="Quote.php" hash="bce0cb9608c7fdb8f128286198472bd5"/><file name="Session.php" hash="0236f26208780df75ca780d40edbe351"/></dir><dir name="Model"><dir name="ApiGateway"><dir name="Response"><file name="Abstract.php" hash="66667fce4c92782faf1d1a92f4c3e339"/><file name="Begin.php" hash="451d64c86ef6aa542ae7cf5949b1b627"/><file name="GetPreview.php" hash="bbf2885274837015a49787f7685a2bd6"/></dir></dir><file name="ApiGateway.php" hash="9a3477755c09d271ca5deabae66efed8"/><file name="Observer.php" hash="a1c8c3583ac44629e024c55327fc356c"/><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="0b1f152cf26c58a92efe4165dc9b3803"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="ApiUrl.php" hash="34eb488ef178104966397f425625534d"/></dir></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="99a61366b957002731bb6948c2956839"/></dir><dir name="etc"><file name="config.xml" hash="cfb09cb9464bbc3f289d492e8a09e0ab"/><file name="system.xml" hash="9808dd3a40e7a7c24e210b5d95f78507"/></dir><dir name="sql"><dir name="printscience_personalization_setup"><file name="Mysql4-install-1.0.3.php" hash="7895f0369177cb6dab9911d7820647b4"/></dir></dir></dir></dir></target><target name="magelib"><dir name="xmlrpc"><file name="xmlrpc.inc" hash="55ecb2a9f7fc20d53a7b4da9d885e26b"/></dir></target><target name="mage"><dir name="js"><dir name="printscience_personalization"><file name="gallery.css" hash="eccacd49a35d68ef25bc1bf8e292fe98"/><file name="gallery.js" hash="2157199d26c64a051f3b62530e068401"/><dir name="jquery"><dir name="fancybox"><file name="blank.gif" hash="325472601571f31e1bf00674c368d335"/><file name="fancy_close.png" hash="6e2879a324a76e9972ebc98201aae1d8"/><file name="fancy_loading.png" hash="b1d54c240cf06e7f41e372d56919b738"/><file name="fancy_nav_left.png" hash="3f3e406102152cd8236383568a40ba35"/><file name="fancy_nav_right.png" hash="216e4bde5bddeeaa60dc3d692890a68e"/><file name="fancy_shadow_e.png" hash="fd4f491080d29fade5080877f1ba4c8b"/><file name="fancy_shadow_n.png" hash="18cde16379b2ceadef714d9b346d09ec"/><file name="fancy_shadow_ne.png" hash="63adf788acf193d4e4f3642d7d793125"/><file name="fancy_shadow_nw.png" hash="c820c878aedb7a7f9ebd7135a58e7c65"/><file name="fancy_shadow_s.png" hash="9b9e5c888028aaef40fe5b6a363f1e29"/><file name="fancy_shadow_se.png" hash="a8afd5a008884380ee712d177105268f"/><file name="fancy_shadow_sw.png" hash="f81cc0fee5581d76ad3cebe47e7e791b"/><file name="fancy_shadow_w.png" hash="59b0e63eb059e58d932cfd53da4d87e6"/><file name="fancy_title_left.png" hash="1582ac2d3bef6a6445bf02ceca2741cd"/><file name="fancy_title_main.png" hash="38dad6c1ed4bdc81c0bec721b2deb8c2"/><file name="fancy_title_over.png" hash="b886fd165d4b7ac77d41fb52d87ffc60"/><file name="fancy_title_right.png" hash="6cbe0c935511e7f9a2555ccb6a7324c4"/><file name="fancybox-x.png" hash="168696d8a694214090ef90e029cdf393"/><file name="fancybox-y.png" hash="36a58859beb9a6b19322a37466b9f78e"/><file name="fancybox.png" hash="11e57e492ee0311540967cc7a1e6e3e2"/><file name="jquery.easing-1.3.pack.js" hash="def257dbb0ab805c4996fd8abb1a6b49"/><file name="jquery.fancybox-1.3.4.css" hash="4638ce99ef00cf62bfb22d230f9924b8"/><file name="jquery.fancybox-1.3.4.pack.js" hash="8bc36a08c46719377528d962966ce37c"/><file name="jquery.mousewheel-3.0.4.pack.js" hash="3b0a821567b463e70bcc1e90ed2bc9b6"/></dir><file name="jquery-1.4.2.min.js" hash="b80a2154ce061c8242031d9a4892c5a6"/><dir name="jquery.cycle"><file name="jquery.cycle.lite.min.js" hash="0c4a7571c05a6ada90b93e826e7f9f6e"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="printscience_personalization.xml" hash="02bbc420d579eceee5b83b3fb41a73af"/></dir><dir name="template"><dir name="printscience_personalization"><dir name="sales"><dir name="order"><dir name="view"><dir name="items"><dir name="renderer"><file name="default.phtml" hash="5b6bcdd9bd94afda867429707dd786d3"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="printscience_personalization.xml" hash="6dbb5084dc5bce33ee476dae547795f4"/></dir><dir name="template"><dir name="printscience_personalization"><dir name="catalog"><dir name="product"><file name="list.phtml" hash="ed9facdc48754e923c89b206003abe8a"/><dir name="view"><file name="addtocart.phtml" hash="c46ece2a25fa12658938f3f2be6a6790"/></dir></dir></dir><dir name="checkout"><dir name="cart"><dir name="item"><file name="default.phtml" hash="70a0ff8a6397dce80e4615469f847531"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="PrintScience_Personalization.xml" hash="5f5c39c5b01e828137125d057d04a655"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|