NowInStore_CatalogBuilder - Version 1.3.1

Version Notes

Fix issue with rounded prices
Added wholesale price

Download this release

Release Info

Developer Kwaku
Extension NowInStore_CatalogBuilder
Version 1.3.1
Comparing to
See all releases


Code changes from version 1.1.1 to 1.3.1

app/code/community/NowInStore/CatalogBuilder/controllers/AuthController.php CHANGED
@@ -3,16 +3,30 @@ class NowInStore_CatalogBuilder_AuthController extends Mage_Core_Controller_Fron
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");
9
- $hostname = Mage::app()->getFrontController()->getRequest()->getHttpHost();
10
- $address = str_replace("\r\n", "<br/>", Mage::getStoreConfig('general/store_information/address'));
11
- $email = Mage::getStoreConfig('trans_email/ident_general/email');
12
- $businessName = Mage::getStoreConfig('general/store_information/name');
13
- $name = Mage::getStoreConfig('trans_email/ident_general/name');
14
- $phone = Mage::getStoreConfig('general/store_information/phone');
15
- $version = Mage::getVersion();
16
- $this->getResponse()->setRedirect("https://www.nowinstore.com/auth/magento/callback?baseUrl=$baseUrl&hostname=$hostname&address=$address&email=$email&businessName=$businessName&name=$name&phone=$phone&version=$version");
17
  }
18
  }
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
  $baseUrl = urlencode(Mage::getBaseUrl());
22
+ $hostname = urlencode(Mage::app()->getFrontController()->getRequest()->getHttpHost());
23
+ $address = urlencode(str_replace("\r\n", "<br/>", Mage::getStoreConfig('general/store_information/address')));
24
+ $email = urlencode(Mage::getStoreConfig('trans_email/ident_general/email'));
25
+ $businessName = urlencode(Mage::getStoreConfig('general/store_information/name'));
26
+ $name = urlencode(Mage::getStoreConfig('trans_email/ident_general/name'));
27
+ $phone = urlencode(Mage::getStoreConfig('general/store_information/phone'));
28
+ $version = urlencode(Mage::getVersion());
29
+ $destinationUrl = "https://www.nowinstore.com/auth/magento/callback?baseUrl=$baseUrl&hostname=$hostname&address=$address&email=$email&businessName=$businessName&name=$name&phone=$phone&version=$version";
30
+ $this->getResponse()->setRedirect($destinationUrl);
31
  }
32
  }
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,168 @@
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
+ private function count() {
6
+
 
 
 
 
7
  $product_collection = Mage::getModel('catalog/product')
8
+ ->getCollection()
9
+ ->addExpressionAttributeToSelect('lower_name', 'LOWER({{name}})', array('name'))
10
+ ->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
11
+ ->addAttributeToSelect(array('id', 'name', 'sku', 'price', 'group_price', 'image', 'description', 'short_description'));
 
 
 
12
 
13
+ $keywords = $_GET['keywords'];
14
  if (!empty ($keywords)) {
15
+ $product_collection = $product_collection->addAttributeToFilter('lower_name', array('like' => '%' . strtolower($keywords) . '%'));
16
  }
17
 
18
+ $category_id = $_GET['category_id'];
19
  if (!empty ($category_id)) {
20
  $product_collection = $product_collection
21
+ ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id=entity_id', null, 'left')
22
  ->addAttributeToFilter('category_id', array('in' => $category_id));
23
  }
24
+
25
+ return $product_collection->getSize();
26
+ }
27
+
28
+ public function indexAction()
29
+ {
30
+ $debug = $_GET['debug'];
31
+ if ($debug) {
32
+ Mage::setIsDeveloperMode(true);
33
+ ini_set('display_errors', 1);
34
+ ini_set('display_startup_errors', 1);
35
+ if ($debug == 'all')
36
+ error_reporting(E_ALL);
37
+ if ($debug == 'info')
38
+ error_reporting(E_ERROR | E_WARNING | E_PARSE);
39
+ if ($debug == 'warning')
40
+ error_reporting(E_ERROR | E_WARNING);
41
+ if ($debug == 'error')
42
+ error_reporting(E_ERROR);
43
+ }
44
+
45
+ $page = $_GET['page'];
46
+ if (empty($page)) {
47
+ $page = 1;
48
+ }
49
+
50
+ $limit = $_GET['limit'];
51
+ if (empty($limit)) {
52
+ $limit = 50;
53
+ }
54
+
55
  $products = array();
56
+ $productsCount = $this->count();
57
+ if ($productsCount > ($page-1)*$limit) {
58
+ $product_collection = Mage::getModel('catalog/product')
59
+ ->getCollection()
60
+ // ->addAttributeToFilter('is_active', 1)
61
+ ->addExpressionAttributeToSelect('lower_name', 'LOWER({{name}})', array('name'))
62
+ ->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
63
+ ->setPageSize($limit)
64
+ ->setCurPage($page)
65
+ ->addAttributeToSelect(array('id', 'name', 'sku', 'price', 'group_price', 'image', 'description', 'short_description'));
66
+
67
+ $keywords = $_GET['keywords'];
68
+ if (!empty ($keywords)) {
69
+ $product_collection = $product_collection->addAttributeToFilter('lower_name', array('like' => '%' . strtolower($keywords) . '%'));
70
+ }
71
+
72
+ $category_id = $_GET['category_id'];
73
+ if (!empty ($category_id)) {
74
+ $product_collection = $product_collection
75
+ ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id=entity_id', null, 'left')
76
+ ->addAttributeToFilter('category_id', array('in' => $category_id));
77
  }
78
+ $currency = Mage::app()->getStore()->getCurrentCurrencyCode();
79
+ $group_collection = Mage::getModel('customer/group')->getCollection();
80
+ $wholesaleGroup = null;
81
+ foreach ($group_collection as $group) {
82
+ if ($group->getCode() === 'Wholesale') {
83
+ $wholesaleGroup = $group;
84
  }
85
  }
86
+ foreach ($product_collection as $product) {
87
+ $attributeOptions = array();
88
+ if ($product->isConfigurable()) {
89
+ $productAttributeOptions = $product->getTypeInstance()->getConfigurableAttributesAsArray($product);
90
+ foreach ($productAttributeOptions as $productAttribute) {
91
+ foreach ($productAttribute['values'] as $attribute) {
92
+ $label = $productAttribute['label'];
93
+ $valueIndex = $attribute['value_index'];
94
+ $attributeOptions[$label][$valueIndex] = $attribute['store_label'];
95
+ }
96
+ }
97
+ }
98
+ $mainImage = $product->getImageUrl();
99
+ $product->load('media_gallery');
100
+ $mediaGallery = $product->getMediaGalleryImages();
101
+ $images = array();
102
+ foreach ($mediaGallery as $image) {
103
+ array_push($images, $image->getUrl());
104
+ }
105
+
106
+ if (is_null($product->getImage()) || $product->getImage() == 'no_selection' && count($images) > 0) {
107
+ $mainImage = $images[0];
108
+ }
109
+ $price = floatval($product->getPrice());
110
+ $wholesalePrice = 0;
111
+ if (!is_null($wholesaleGroup)) {
112
+ $product->setCustomerGroupId($wholesaleGroup->getId());
113
+ }
114
+ $groupPrices = $product->getGroupPrice();
115
+ if (is_null($groupPrices)) {
116
+ $attribute = $product->getResource()->getAttribute('group_price');
117
+ if ($attribute) {
118
+ $attribute->getBackend()->afterLoad($product);
119
+ $groupPrices = $product->getData('group_price');
120
+ }
121
+ }
122
+ if (!is_null($groupPrices) || is_array($groupPrices)) {
123
+ $wholesalePrice = $groupPrices;
124
+ }
125
+
126
+ array_push($products, array(
127
  "id" => $product->getId(),
128
  "title" => $product->getName(),
129
  "sku" => $product->getSku(),
130
+ "price" => $price,
131
+ "wholesale_price" => floatval($wholesalePrice),
132
+ "main_image" => $mainImage,
133
+ "images" => $images,
134
  "description" => $product->getDescription(),
135
+ "short_description" => $product->getShortDescription(),
136
  "thumbnail_image" => (string)Mage::helper('catalog/image')->init($product, 'image')->resize(75),
137
  "iso_currency_code" => $currency,
138
  "url" => $product->getProductUrl(),
139
  "variations" => $attributeOptions
140
+ ));
141
+ }
142
  }
143
  $jsonData = json_encode($products);
144
  $this->getResponse()->setHeader('Content-type', 'application/json');
145
  $this->getResponse()->setBody($jsonData);
146
  }
147
+
148
  public function countAction()
149
  {
150
  $product_collection = Mage::getModel('catalog/product')
151
+ ->getCollection()
152
  // ->addAttributeToFilter('is_active', 1)
153
+ ->addExpressionAttributeToSelect('lower_name', 'LOWER({{name}})', array('name'))
154
+ ->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
155
+ ->addAttributeToSelect(array('id', 'name', 'sku', 'price', 'image'));
156
 
157
+ $query = $_GET['query'];
158
  if (!empty ($query)) {
159
+ $product_collection = $product_collection->addAttributeToFilter('lower_name', array('like' => '%' . strtolower($query) . '%'));
160
  }
161
 
162
+ $category_id = $_GET['category_id'];
163
  if (!empty ($category_id)) {
164
  $product_collection = $product_collection
165
+ ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id=entity_id', null, 'left')
166
  ->addAttributeToFilter('category_id', array('in' => $category_id));
167
  }
168
  $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.3.1</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.3.1</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>