minewhat - Version 1.0.15

Version Notes

MineWhat magento plugin

Download this release

Release Info

Developer MineWhat Inc.
Extension minewhat
Version 1.0.15
Comparing to
See all releases


Code changes from version 1.0.14 to 1.0.15

app/code/community/MineWhat/Insights/controllers/ApiController.php CHANGED
@@ -211,6 +211,50 @@ class MineWhat_Insights_ApiController extends Mage_Core_Controller_Front_Action
211
 
212
  }
213
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  private function getFormatedProduct($product, $extras, $allAttrs) {
215
 
216
  $formatedProduct = null;
@@ -228,13 +272,24 @@ class MineWhat_Insights_ApiController extends Mage_Core_Controller_Front_Action
228
  'image' => $product->getImageUrl(),
229
  'url' => $product->getProductUrl(),
230
  'info' => $product->getShortDescription(),
231
- 'status' => $product->getStatus()
 
232
  );
233
  if(!$formatedProduct['manufacturer'] || strlen($formatedProduct['manufacturer']) === 0) {
234
  $product = Mage::getModel('catalog/product')->load($product->getId());
235
  $formatedProduct['manufacturer'] = $product->getAttributeText('manufacturer');
236
  }
237
 
 
 
 
 
 
 
 
 
 
 
238
  if($allAttrs) {
239
  $attributes = $product->getAttributes();
240
  foreach($attributes as $key => $value) {
211
 
212
  }
213
 
214
+
215
+ public function stockAction() {
216
+
217
+ try {
218
+
219
+ if(!$this->_authorise()) {
220
+ return $this;
221
+ }
222
+
223
+ $productId = $this->getRequest()->getParam('pid');
224
+
225
+
226
+ if(!$productId || strlen($productId) <= 0) {
227
+
228
+ $this->getResponse()
229
+ ->setBody(json_encode(array('status' => 'error', 'message' => 'product id required')))
230
+ ->setHttpResponseCode(500)
231
+ ->setHeader('Content-type', 'application/json', true);
232
+
233
+ } else {
234
+
235
+ // get stock info
236
+ $stockObj = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
237
+ $stock = $stockObj->getQty();
238
+
239
+ $this->getResponse()
240
+ ->setBody(json_encode(array('id' => $productId, 'stock' => $stock)))
241
+ ->setHttpResponseCode(200)
242
+ ->setHeader('Content-type', 'application/json', true);
243
+
244
+ }
245
+
246
+ } catch(Exception $e) {
247
+ $this->getResponse()
248
+ ->setBody(json_encode(array('status' => 'error', 'message' => 'Internal server error')))
249
+ ->setHttpResponseCode(500)
250
+ ->setHeader('Content-type', 'application/json', true);
251
+ }
252
+
253
+ return $this;
254
+
255
+ }
256
+
257
+
258
  private function getFormatedProduct($product, $extras, $allAttrs) {
259
 
260
  $formatedProduct = null;
272
  'image' => $product->getImageUrl(),
273
  'url' => $product->getProductUrl(),
274
  'info' => $product->getShortDescription(),
275
+ 'status' => $product->getStatus(),
276
+ 'type' => $product->getTypeId()
277
  );
278
  if(!$formatedProduct['manufacturer'] || strlen($formatedProduct['manufacturer']) === 0) {
279
  $product = Mage::getModel('catalog/product')->load($product->getId());
280
  $formatedProduct['manufacturer'] = $product->getAttributeText('manufacturer');
281
  }
282
 
283
+ if($formatedProduct['type'] == "configurable") {
284
+ // get associated product ids
285
+ $associatedProducts = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($formatedProduct['id']);
286
+ $formatedProduct['associated_products'] = $associatedProducts;
287
+ }
288
+
289
+ // get stock info
290
+ $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
291
+ $formatedProduct['stock'] = $stock->getQty();
292
+
293
  if($allAttrs) {
294
  $attributes = $product->getAttributes();
295
  foreach($attributes as $key => $value) {
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>minewhat</name>
4
- <version>1.0.14</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">osl</license>
7
  <channel>community</channel>
@@ -10,8 +10,8 @@
10
  <description>MineWhat Insights</description>
11
  <notes>MineWhat magento plugin</notes>
12
  <authors><author><name>MineWhat Inc.</name><user>MineWhat</user><email>plugins@minewhat.com</email></author></authors>
13
- <date>2014-10-02</date>
14
- <time>13:33:03</time>
15
  <contents><target name="magecommunity"><dir name="MineWhat"><dir name="Insights"><dir name="Block"><dir name="Base"><file name="Script.php" hash="dd44e43a5954e82cfa5cf47921642624"/></dir><dir name="Event"><dir name="Catalog"><dir name="Product"><file name="View.php" hash="41eb512f4f77a8e127253cf246587f0c"/></dir></dir><dir name="Checkout"><dir name="Cart"><file name="Index.php" hash="fafaf6953262ea2b0bc3092d538c30d1"/></dir><dir name="Onepage"><file name="Success.php" hash="3113839e3b8e2a3f9b75e21f26e7909f"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="c9284d372a18c6db27dec077c04296ff"/></dir><dir name="Model"><file name="Observer.php" hash="8f8ffe64147205aebc15670bc819ccb5"/></dir><dir name="controllers"><file name="ApiController.php" hash="486db1b0ab4919ccbc1b8c10c730adc4"/><file name=".DS_Store" hash="bd846b4e5462712bd0f45cffeb689332"/></dir><dir name="etc"><file name="adminhtml.xml" hash="f1fb655aac4dc7f71cadb6c7a7e816f8"/><file name="config.xml" hash="b4443479201149d5ee72c95ca6ffaae5"/><file name="system.xml" hash="d35bf488b0be559ca5cba14633d40b77"/></dir><file name=".DS_Store" hash="3036b74de2dd23100e10bef959e8151e"/></dir><file name=".DS_Store" hash="abac802fc3edbab84baea3833903cfd2"/></dir></target><target name="mageetc"><dir name="modules"><file name="MineWhat_Insights.xml" hash="8d2f076cbfcc14688ed800f622869d4b"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="minewhat"><dir name="insights"><dir name="base"><file name="script.phtml" hash="fe16e289984308941fb830bc97e7cad2"/></dir><dir name="event"><dir name="catalog"><dir name="product"><file name="view.phtml" hash="f4a801140203b524d44a23ac83e5873a"/></dir></dir><dir name="checkout"><dir name="cart"><file name="index.phtml" hash="16cf404c9684e5839270fb0931e8fb3b"/></dir><dir name="onepage"><file name="success.phtml" hash="2e57c97e161ae46db821daba8f421aa5"/></dir></dir></dir></dir></dir></dir><dir name="layout"><file name="minewhat_insights.xml" hash="42a313f2e0ee3792f814abec37227ee0"/></dir></dir></dir><dir name="base"><dir name="default"><dir name="template"><dir name="minewhat"><dir name="insights"><dir name="base"><file name="script.phtml" hash="fe16e289984308941fb830bc97e7cad2"/></dir><dir name="event"><dir name="catalog"><dir name="product"><file name="view.phtml" hash="f4a801140203b524d44a23ac83e5873a"/></dir></dir><dir name="checkout"><dir name="cart"><file name="index.phtml" hash="16cf404c9684e5839270fb0931e8fb3b"/></dir><dir name="onepage"><file name="success.phtml" hash="d65f509768987584e0ea8e85745c1ffe"/></dir></dir></dir></dir></dir></dir><dir name="layout"><file name="minewhat_insights.xml" hash="42a313f2e0ee3792f814abec37227ee0"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.5</min><max>6.0.0</max></php></required></dependencies>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>minewhat</name>
4
+ <version>1.0.15</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">osl</license>
7
  <channel>community</channel>
10
  <description>MineWhat Insights</description>
11
  <notes>MineWhat magento plugin</notes>
12
  <authors><author><name>MineWhat Inc.</name><user>MineWhat</user><email>plugins@minewhat.com</email></author></authors>
13
+ <date>2014-10-13</date>
14
+ <time>12:33:03</time>
15
  <contents><target name="magecommunity"><dir name="MineWhat"><dir name="Insights"><dir name="Block"><dir name="Base"><file name="Script.php" hash="dd44e43a5954e82cfa5cf47921642624"/></dir><dir name="Event"><dir name="Catalog"><dir name="Product"><file name="View.php" hash="41eb512f4f77a8e127253cf246587f0c"/></dir></dir><dir name="Checkout"><dir name="Cart"><file name="Index.php" hash="fafaf6953262ea2b0bc3092d538c30d1"/></dir><dir name="Onepage"><file name="Success.php" hash="3113839e3b8e2a3f9b75e21f26e7909f"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="c9284d372a18c6db27dec077c04296ff"/></dir><dir name="Model"><file name="Observer.php" hash="8f8ffe64147205aebc15670bc819ccb5"/></dir><dir name="controllers"><file name="ApiController.php" hash="486db1b0ab4919ccbc1b8c10c730adc4"/><file name=".DS_Store" hash="bd846b4e5462712bd0f45cffeb689332"/></dir><dir name="etc"><file name="adminhtml.xml" hash="f1fb655aac4dc7f71cadb6c7a7e816f8"/><file name="config.xml" hash="b4443479201149d5ee72c95ca6ffaae5"/><file name="system.xml" hash="d35bf488b0be559ca5cba14633d40b77"/></dir><file name=".DS_Store" hash="3036b74de2dd23100e10bef959e8151e"/></dir><file name=".DS_Store" hash="abac802fc3edbab84baea3833903cfd2"/></dir></target><target name="mageetc"><dir name="modules"><file name="MineWhat_Insights.xml" hash="8d2f076cbfcc14688ed800f622869d4b"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="minewhat"><dir name="insights"><dir name="base"><file name="script.phtml" hash="fe16e289984308941fb830bc97e7cad2"/></dir><dir name="event"><dir name="catalog"><dir name="product"><file name="view.phtml" hash="f4a801140203b524d44a23ac83e5873a"/></dir></dir><dir name="checkout"><dir name="cart"><file name="index.phtml" hash="16cf404c9684e5839270fb0931e8fb3b"/></dir><dir name="onepage"><file name="success.phtml" hash="2e57c97e161ae46db821daba8f421aa5"/></dir></dir></dir></dir></dir></dir><dir name="layout"><file name="minewhat_insights.xml" hash="42a313f2e0ee3792f814abec37227ee0"/></dir></dir></dir><dir name="base"><dir name="default"><dir name="template"><dir name="minewhat"><dir name="insights"><dir name="base"><file name="script.phtml" hash="fe16e289984308941fb830bc97e7cad2"/></dir><dir name="event"><dir name="catalog"><dir name="product"><file name="view.phtml" hash="f4a801140203b524d44a23ac83e5873a"/></dir></dir><dir name="checkout"><dir name="cart"><file name="index.phtml" hash="16cf404c9684e5839270fb0931e8fb3b"/></dir><dir name="onepage"><file name="success.phtml" hash="d65f509768987584e0ea8e85745c1ffe"/></dir></dir></dir></dir></dir></dir><dir name="layout"><file name="minewhat_insights.xml" hash="42a313f2e0ee3792f814abec37227ee0"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.5</min><max>6.0.0</max></php></required></dependencies>