NowInStore_CatalogBuilder - Version 1.2.3

Version Notes

Fix issue with rounded prices
Added wholesale price

Download this release

Release Info

Developer Kwaku
Extension NowInStore_CatalogBuilder
Version 1.2.3
Comparing to
See all releases


Code changes from version 1.1.1 to 1.2.3

app/code/community/NowInStore/CatalogBuilder/controllers/AuthController.php CHANGED
@@ -1,8 +1,26 @@
1
  <?php
 
 
 
2
  class NowInStore_CatalogBuilder_AuthController extends Mage_Core_Controller_Front_Action
3
  {
4
  public function indexAction()
5
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  $email = Mage::getStoreConfig('trans_email/ident_general/email');
7
  $baseUrl = urlencode(Mage::getBaseUrl());
8
  //$this->getResponse()->setRedirect("https://www.nowinstore.com/auth/magento/callback?baseUrl=$baseUrl");
1
  <?php
2
+ error_reporting(E_ALL);
3
+ ini_set('display_errors', 1);
4
+
5
  class NowInStore_CatalogBuilder_AuthController extends Mage_Core_Controller_Front_Action
6
  {
7
  public function indexAction()
8
  {
9
+ $debug = $_GET['debug'];
10
+ if ($debug) {
11
+ Mage::setIsDeveloperMode(true);
12
+ ini_set('display_errors', 1);
13
+ ini_set('display_startup_errors', 1);
14
+ if ($debug == 'all')
15
+ error_reporting(E_ALL);
16
+ if ($debug == 'info')
17
+ error_reporting(E_ERROR | E_WARNING | E_PARSE);
18
+ if ($debug == 'warning')
19
+ error_reporting(E_ERROR | E_WARNING);
20
+ if ($debug == 'error')
21
+ error_reporting(E_ERROR);
22
+ }
23
+
24
  $email = Mage::getStoreConfig('trans_email/ident_general/email');
25
  $baseUrl = urlencode(Mage::getBaseUrl());
26
  //$this->getResponse()->setRedirect("https://www.nowinstore.com/auth/magento/callback?baseUrl=$baseUrl");
app/code/community/NowInStore/CatalogBuilder/controllers/CategoriesController.php CHANGED
@@ -3,19 +3,31 @@ class NowInStore_CatalogBuilder_CategoriesController extends Mage_Core_Controlle
3
  {
4
  public function indexAction()
5
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  $category_collection = Mage::getModel('catalog/category')
7
  ->getCollection()
8
  ->addAttributeToSelect('*')
9
  ->addIsActiveFilter();
10
  $categories = array();
11
  foreach($category_collection as $category) {
12
- $children = $category->getChildrenCategories()->toArray();
13
- if (count($children) == 0) {
14
- array_push($categories, array(
15
- "id" => $category->getId(),
16
- "name" => $category->getName()
17
- ));
18
- }
19
  }
20
  $jsonData = json_encode($categories);
21
  $this->getResponse()->setHeader('Content-type', 'application/json');
3
  {
4
  public function indexAction()
5
  {
6
+ $debug = $_GET['debug'];
7
+ if ($debug) {
8
+ Mage::setIsDeveloperMode(true);
9
+ ini_set('display_errors', 1);
10
+ ini_set('display_startup_errors', 1);
11
+ if ($debug == 'all')
12
+ error_reporting(E_ALL);
13
+ if ($debug == 'info')
14
+ error_reporting(E_ERROR | E_WARNING | E_PARSE);
15
+ if ($debug == 'warning')
16
+ error_reporting(E_ERROR | E_WARNING);
17
+ if ($debug == 'error')
18
+ error_reporting(E_ERROR);
19
+ }
20
+
21
  $category_collection = Mage::getModel('catalog/category')
22
  ->getCollection()
23
  ->addAttributeToSelect('*')
24
  ->addIsActiveFilter();
25
  $categories = array();
26
  foreach($category_collection as $category) {
27
+ array_push($categories, array(
28
+ "id" => $category->getId(),
29
+ "name" => $category->getName()
30
+ ));
 
 
 
31
  }
32
  $jsonData = json_encode($categories);
33
  $this->getResponse()->setHeader('Content-type', 'application/json');
app/code/community/NowInStore/CatalogBuilder/controllers/ProductsController.php CHANGED
@@ -1,81 +1,122 @@
1
  <?php
 
2
  class NowInStore_CatalogBuilder_ProductsController extends Mage_Core_Controller_Front_Action
3
  {
4
  public function indexAction()
5
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  $page = $_GET['page'];
7
  if (empty($page)) {
8
  $page = 1;
9
  }
10
  $product_collection = Mage::getModel('catalog/product')
11
- ->getCollection()
12
  // ->addAttributeToFilter('is_active', 1)
13
- ->addExpressionAttributeToSelect('lower_name', 'LOWER({{name}})', array('name'))
14
- ->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
15
- ->setPageSize(50)
16
- ->setCurPage($page)
17
- ->addAttributeToSelect(array('id', 'name', 'sku', 'price', 'image', 'description'));
18
 
19
- $keywords = $_GET['keywords'];
20
  if (!empty ($keywords)) {
21
- $product_collection = $product_collection->addAttributeToFilter('lower_name', array('like' => '%'.strtolower($keywords).'%'));
22
  }
23
 
24
- $category_id = $_GET['category_id'];
25
  if (!empty ($category_id)) {
26
  $product_collection = $product_collection
27
- ->joinField('category_id','catalog/category_product','category_id','product_id=entity_id',null,'left')
28
  ->addAttributeToFilter('category_id', array('in' => $category_id));
29
  }
30
  $products = array();
31
  $currency = Mage::app()->getStore()->getCurrentCurrencyCode();
32
- foreach($product_collection as $product) {
 
 
 
 
 
 
 
 
33
  if ($product->isConfigurable()) {
34
  $productAttributeOptions = $product->getTypeInstance()->getConfigurableAttributesAsArray($product);
 
 
 
 
 
 
 
35
  }
36
- $attributeOptions = array();
37
- foreach ($productAttributeOptions as $productAttribute) {
38
- foreach ($productAttribute['values'] as $attribute) {
39
- $label = $productAttribute['label'];
40
- $valueIndex = $attribute['value_index'];
41
- $attributeOptions[$label][$valueIndex] = $attribute['store_label'];
 
 
 
 
 
42
  }
43
  }
 
 
 
44
  array_push($products, array(
45
- "id" => $product->getId(),
46
- "title" => $product->getName(),
47
- "sku" => $product->getSku(),
48
- "price" => intval($product->getPrice()),
49
- "main_image" => $product->getImageUrl(),
50
- "description" => $product->getDescription(),
51
- "thumbnail_image" => (string)Mage::helper('catalog/image')->init($product, 'image')->resize(75),
52
- "iso_currency_code" => $currency,
53
- "url" => $product->getProductUrl(),
54
- "variations" => $attributeOptions
 
55
  ));
56
  }
57
  $jsonData = json_encode($products);
58
  $this->getResponse()->setHeader('Content-type', 'application/json');
59
  $this->getResponse()->setBody($jsonData);
60
  }
 
61
  public function countAction()
62
  {
63
  $product_collection = Mage::getModel('catalog/product')
64
- ->getCollection()
65
  // ->addAttributeToFilter('is_active', 1)
66
- ->addExpressionAttributeToSelect('lower_name', 'LOWER({{name}})', array('name'))
67
- ->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
68
- ->addAttributeToSelect(array('id', 'name', 'sku', 'price', 'image'));
69
 
70
- $query = $_GET['query'];
71
  if (!empty ($query)) {
72
- $product_collection = $product_collection->addAttributeToFilter('lower_name', array('like' => '%'.strtolower($query).'%'));
73
  }
74
 
75
- $category_id = $_GET['category_id'];
76
  if (!empty ($category_id)) {
77
  $product_collection = $product_collection
78
- ->joinField('category_id','catalog/category_product','category_id','product_id=entity_id',null,'left')
79
  ->addAttributeToFilter('category_id', array('in' => $category_id));
80
  }
81
  $jsonData = json_encode(array("count" => $product_collection->count()));
1
  <?php
2
+
3
  class NowInStore_CatalogBuilder_ProductsController extends Mage_Core_Controller_Front_Action
4
  {
5
  public function indexAction()
6
  {
7
+ $debug = $_GET['debug'];
8
+ if ($debug) {
9
+ Mage::setIsDeveloperMode(true);
10
+ ini_set('display_errors', 1);
11
+ ini_set('display_startup_errors', 1);
12
+ if ($debug == 'all')
13
+ error_reporting(E_ALL);
14
+ if ($debug == 'info')
15
+ error_reporting(E_ERROR | E_WARNING | E_PARSE);
16
+ if ($debug == 'warning')
17
+ error_reporting(E_ERROR | E_WARNING);
18
+ if ($debug == 'error')
19
+ error_reporting(E_ERROR);
20
+ }
21
+
22
  $page = $_GET['page'];
23
  if (empty($page)) {
24
  $page = 1;
25
  }
26
  $product_collection = Mage::getModel('catalog/product')
27
+ ->getCollection()
28
  // ->addAttributeToFilter('is_active', 1)
29
+ ->addExpressionAttributeToSelect('lower_name', 'LOWER({{name}})', array('name'))
30
+ ->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
31
+ ->setPageSize(50)
32
+ ->setCurPage($page)
33
+ ->addAttributeToSelect(array('id', 'name', 'sku', 'price', 'group_price', 'image', 'description'));
34
 
35
+ $keywords = $_GET['keywords'];
36
  if (!empty ($keywords)) {
37
+ $product_collection = $product_collection->addAttributeToFilter('lower_name', array('like' => '%' . strtolower($keywords) . '%'));
38
  }
39
 
40
+ $category_id = $_GET['category_id'];
41
  if (!empty ($category_id)) {
42
  $product_collection = $product_collection
43
+ ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id=entity_id', null, 'left')
44
  ->addAttributeToFilter('category_id', array('in' => $category_id));
45
  }
46
  $products = array();
47
  $currency = Mage::app()->getStore()->getCurrentCurrencyCode();
48
+ $group_collection = Mage::getModel('customer/group')->getCollection();
49
+ $wholesaleGroup = null;
50
+ foreach ($group_collection as $group) {
51
+ if ($group->getCode() === 'Wholesale') {
52
+ $wholesaleGroup = $group;
53
+ }
54
+ }
55
+ foreach ($product_collection as $product) {
56
+ $attributeOptions = array();
57
  if ($product->isConfigurable()) {
58
  $productAttributeOptions = $product->getTypeInstance()->getConfigurableAttributesAsArray($product);
59
+ foreach ($productAttributeOptions as $productAttribute) {
60
+ foreach ($productAttribute['values'] as $attribute) {
61
+ $label = $productAttribute['label'];
62
+ $valueIndex = $attribute['value_index'];
63
+ $attributeOptions[$label][$valueIndex] = $attribute['store_label'];
64
+ }
65
+ }
66
  }
67
+ $price = floatval($product->getPrice());
68
+ $wholesalePrice = 0;
69
+ if (!is_null($wholesaleGroup)) {
70
+ $product->setCustomerGroupId($wholesaleGroup->getId());
71
+ }
72
+ $groupPrices = $product->getGroupPrice();
73
+ if (is_null($groupPrices)) {
74
+ $attribute = $product->getResource()->getAttribute('group_price');
75
+ if ($attribute) {
76
+ $attribute->getBackend()->afterLoad($product);
77
+ $groupPrices = $product->getData('group_price');
78
  }
79
  }
80
+ if (!is_null($groupPrices) || is_array($groupPrices)) {
81
+ $wholesalePrice = $groupPrices;
82
+ }
83
  array_push($products, array(
84
+ "id" => $product->getId(),
85
+ "title" => $product->getName(),
86
+ "sku" => $product->getSku(),
87
+ "price" => $price,
88
+ "wholesale_price" => floatval($wholesalePrice),
89
+ "main_image" => $product->getImageUrl(),
90
+ "description" => $product->getDescription(),
91
+ "thumbnail_image" => (string)Mage::helper('catalog/image')->init($product, 'image')->resize(75),
92
+ "iso_currency_code" => $currency,
93
+ "url" => $product->getProductUrl(),
94
+ "variations" => $attributeOptions
95
  ));
96
  }
97
  $jsonData = json_encode($products);
98
  $this->getResponse()->setHeader('Content-type', 'application/json');
99
  $this->getResponse()->setBody($jsonData);
100
  }
101
+
102
  public function countAction()
103
  {
104
  $product_collection = Mage::getModel('catalog/product')
105
+ ->getCollection()
106
  // ->addAttributeToFilter('is_active', 1)
107
+ ->addExpressionAttributeToSelect('lower_name', 'LOWER({{name}})', array('name'))
108
+ ->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
109
+ ->addAttributeToSelect(array('id', 'name', 'sku', 'price', 'image'));
110
 
111
+ $query = $_GET['query'];
112
  if (!empty ($query)) {
113
+ $product_collection = $product_collection->addAttributeToFilter('lower_name', array('like' => '%' . strtolower($query) . '%'));
114
  }
115
 
116
+ $category_id = $_GET['category_id'];
117
  if (!empty ($category_id)) {
118
  $product_collection = $product_collection
119
+ ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id=entity_id', null, 'left')
120
  ->addAttributeToFilter('category_id', array('in' => $category_id));
121
  }
122
  $jsonData = json_encode(array("count" => $product_collection->count()));
app/code/community/NowInStore/CatalogBuilder/controllers/ProfileController.php CHANGED
@@ -3,6 +3,21 @@ class NowInStore_CatalogBuilder_ProfileController extends Mage_Core_Controller_F
3
  {
4
  public function indexAction()
5
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  $hostname = Mage::app()->getFrontController()->getRequest()->getHttpHost();
7
  $address = str_replace("\r\n", "<br/>", Mage::getStoreConfig('general/store_information/address'));
8
  $jsonData = json_encode(array(
3
  {
4
  public function indexAction()
5
  {
6
+ $debug = $_GET['debug'];
7
+ if ($debug) {
8
+ Mage::setIsDeveloperMode(true);
9
+ ini_set('display_errors', 1);
10
+ ini_set('display_startup_errors', 1);
11
+ if ($debug == 'all')
12
+ error_reporting(E_ALL);
13
+ if ($debug == 'info')
14
+ error_reporting(E_ERROR | E_WARNING | E_PARSE);
15
+ if ($debug == 'warning')
16
+ error_reporting(E_ERROR | E_WARNING);
17
+ if ($debug == 'error')
18
+ error_reporting(E_ERROR);
19
+ }
20
+
21
  $hostname = Mage::app()->getFrontController()->getRequest()->getHttpHost();
22
  $address = str_replace("\r\n", "<br/>", Mage::getStoreConfig('general/store_information/address'));
23
  $jsonData = json_encode(array(
app/code/community/NowInStore/CatalogBuilder/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <NowInStore_CatalogBuilder>
5
- <version>1.1.1</version>
6
  </NowInStore_CatalogBuilder>
7
  </modules>
8
  <frontend>
2
  <config>
3
  <modules>
4
  <NowInStore_CatalogBuilder>
5
+ <version>1.2.3</version>
6
  </NowInStore_CatalogBuilder>
7
  </modules>
8
  <frontend>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>NowInStore_CatalogBuilder</name>
4
- <version>1.1.1</version>
5
  <stability>stable</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
@@ -12,11 +12,12 @@
12
  Our blog and online-chat experts are on hand that share tips and tricks on how you can use catalogs and flyers to grow your sales. &#xD;
13
  &#xD;
14
  With a few clicks, import all of your Magento products into a beautiful drag and drop interface. Easily choose and organize each page of your catalog or flyer, use different layouts, customize your front and back covers and add a wholesale contract and order forms.</description>
15
- <notes>Repackaging</notes>
 
16
  <authors><author><name>Kwaku</name><user>Zigah</user><email>kwaku.zigah@nowinstore.com</email></author></authors>
17
- <date>2016-05-25</date>
18
- <time>21:22:13</time>
19
- <contents><target name="magecommunity"><dir name="NowInStore"><dir name="CatalogBuilder"><dir name="controllers"><file name="AuthController.php" hash="083a894900d82e353543cd762da9e157"/><file name="CategoriesController.php" hash="abc588a995c3c8797b824e0c04c57295"/><file name="ProductsController.php" hash="c2a8b30a4f6c92bd87c25365f18b8b42"/><file name="ProfileController.php" hash="f720bea41f8a18d7296d91a81f4a4722"/></dir><dir name="etc"><file name="adminhtml.xml" hash="3d7e6a6f47a3a37945603d5620a49c22"/><file name="config.xml" hash="b10c591395a3f476f452e06885322d65"/><file name="config.xml~" hash="542bda660e3269cf774df308fd389a19"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="NowInStore_CatalogBuilder.xml" hash="a087b751cea9700fd21fa59bb3d0a666"/></dir></target></contents>
20
  <compatible/>
21
  <dependencies><required><php><min>5.2.0</min><max>5.6.21</max></php></required></dependencies>
22
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>NowInStore_CatalogBuilder</name>
4
+ <version>1.2.3</version>
5
  <stability>stable</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
12
  Our blog and online-chat experts are on hand that share tips and tricks on how you can use catalogs and flyers to grow your sales. &#xD;
13
  &#xD;
14
  With a few clicks, import all of your Magento products into a beautiful drag and drop interface. Easily choose and organize each page of your catalog or flyer, use different layouts, customize your front and back covers and add a wholesale contract and order forms.</description>
15
+ <notes>Fix issue with rounded prices&#xD;
16
+ Added wholesale price</notes>
17
  <authors><author><name>Kwaku</name><user>Zigah</user><email>kwaku.zigah@nowinstore.com</email></author></authors>
18
+ <date>2016-06-10</date>
19
+ <time>16:39:00</time>
20
+ <contents><target name="magecommunity"><dir name="NowInStore"><dir name="CatalogBuilder"><dir name="controllers"><file name="AuthController.php" hash="083a894900d82e353543cd762da9e157"/><file name="CategoriesController.php" hash="9e643060ad40ef54c13f2b72f943402b"/><file name="CategoriesController.php~" hash="abc588a995c3c8797b824e0c04c57295"/><file name="ProductsController.php" hash="0493192bbfe5bef8c3b0d312e607a1f0"/><file name="ProductsController.php~" hash="4feb53033fcc499c450917c2c645a0d4"/><file name="ProfileController.php" hash="f720bea41f8a18d7296d91a81f4a4722"/></dir><dir name="etc"><file name="adminhtml.xml" hash="3d7e6a6f47a3a37945603d5620a49c22"/><file name="config.xml" hash="b10c591395a3f476f452e06885322d65"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="NowInStore_CatalogBuilder.xml" hash="a087b751cea9700fd21fa59bb3d0a666"/></dir></target></contents>
21
  <compatible/>
22
  <dependencies><required><php><min>5.2.0</min><max>5.6.21</max></php></required></dependencies>
23
  </package>