NowInStore_CatalogBuilder - Version 1.0.0

Version Notes

First release

Download this release

Release Info

Developer Kwaku Zigah
Extension NowInStore_CatalogBuilder
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/NowInStore/CatalogBuilder/controllers/AuthController.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
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");
9
+ }
10
+ }
app/code/community/NowInStore/CatalogBuilder/controllers/CategoriesController.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class NowInStore_CatalogBuilder_CategoriesController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ $category_collection = Mage::getModel('catalog/category')
7
+ ->getCollection()
8
+ ->addAttributeToSelect('*')
9
+ ->addIsActiveFilter();
10
+ $categories = [];
11
+ foreach($category_collection as $category) {
12
+ $children = $category->getChildrenCategories()->toArray();
13
+ if (count($children) == 0) {
14
+ array_push($categories, [
15
+ "id" => $category->getId(),
16
+ "name" => $category->getName()
17
+ ]);
18
+ }
19
+ }
20
+ $jsonData = json_encode($categories);
21
+ $this->getResponse()->setHeader('Content-type', 'application/json');
22
+ $this->getResponse()->setBody($jsonData);
23
+ }
24
+ }
app/code/community/NowInStore/CatalogBuilder/controllers/ProductsController.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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(['id', 'name', 'sku', 'price', 'image']);
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 = [];
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
+ $attributeOptions[$productAttribute['label']][$attribute['value_index']] = $attribute['store_label'];
40
+ }
41
+ }
42
+ array_push($products, [
43
+ "id" => $product->getId(),
44
+ "title" => $product->getName(),
45
+ "sku" => $product->getSku(),
46
+ "price" => intval($product->getPrice()),
47
+ "main_image" => $product->getImageUrl(),
48
+ "thumbnail_image" => (string)Mage::helper('catalog/image')->init($product, 'image')->resize(75),
49
+ "iso_currency_code" => $currency,
50
+ "url" => $product->getProductUrl(),
51
+ "variations" => $attributeOptions
52
+ ]);
53
+ }
54
+ $jsonData = json_encode($products);
55
+ $this->getResponse()->setHeader('Content-type', 'application/json');
56
+ $this->getResponse()->setBody($jsonData);
57
+ }
58
+ public function countAction()
59
+ {
60
+ $product_collection = Mage::getModel('catalog/product')
61
+ ->getCollection()
62
+ // ->addAttributeToFilter('is_active', 1)
63
+ ->addExpressionAttributeToSelect('lower_name', 'LOWER({{name}})', array('name'))
64
+ ->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
65
+ ->addAttributeToSelect(['id', 'name', 'sku', 'price', 'image']);
66
+
67
+ $query = $_GET['query'];
68
+ if (!empty ($query)) {
69
+ $product_collection = $product_collection->addAttributeToFilter('lower_name', array('like' => '%'.strtolower($query).'%'));
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
+ $jsonData = json_encode(["count" => $product_collection->count()]);
79
+ $this->getResponse()->setHeader('Content-type', 'application/json');
80
+ $this->getResponse()->setBody($jsonData);
81
+ }
82
+ }
app/code/community/NowInStore/CatalogBuilder/controllers/ProfileController.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class NowInStore_CatalogBuilder_ProfileController extends Mage_Core_Controller_Front_Action
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([
9
+ "business_name" => Mage::getStoreConfig('general/store_information/name'),
10
+ "name" => Mage::getStoreConfig('trans_email/ident_general/name'),
11
+ "email" => Mage::getStoreConfig('trans_email/ident_general/email'),
12
+ "baseUrl" => Mage::getBaseUrl(),
13
+ "phone" => Mage::getStoreConfig('general/store_information/phone'),
14
+ "address" => $address
15
+ ]);
16
+ $this->getResponse()->setHeader('Content-type', 'application/json');
17
+ $this->getResponse()->setBody($jsonData);
18
+ }
19
+ }
app/code/community/NowInStore/CatalogBuilder/etc/adminhtml.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <catalogbuilder>
5
+ <title>Now In Store</title>
6
+ <sort_order>300</sort_order>
7
+ <children>
8
+ <example>
9
+ <title>Automatic Catalog Builder</title>
10
+ <action>catalogbuilder/auth/</action>
11
+ </example>
12
+ </children>
13
+ </catalogbuilder>
14
+ </menu>
15
+ </config>
app/code/community/NowInStore/CatalogBuilder/etc/config.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <NowInStore_CatalogBuilder>
5
+ <version>1.0.0</version> <!-- Version number of your module -->
6
+ </NowInStore_CatalogBuilder>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <catalogbuilder>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>NowInStore_CatalogBuilder</module>
14
+ <frontName>catalogbuilder</frontName>
15
+ </args>
16
+ </catalogbuilder>
17
+ </routers>
18
+ </frontend>
19
+ </config>
app/code/community/NowInStore/CatalogBuilder/etc/config.xml~ ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Chiragdodia_Mymodule>
5
+ <version>0.0.1</version> <!-- Version number of your module -->
6
+ </Chiragdodia_Mymodule>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <mymodule>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>NowInStore_CatalogBuilder</module>
14
+ <frontName>catalogbuilder</frontName>
15
+ </args>
16
+ </mymodule>
17
+ </routers>
18
+ </frontend>
19
+ </config>
package.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>NowInStore_CatalogBuilder</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.gnu.org/licenses/gpl-3.0.en.html">GNU General Public License (GPL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Users can create beautiful customized catalogs and flyers to sell online or offline.</summary>
10
+ <description>Now In Store will guide you in your process as you create and use catalogs and flyers and help you gain control over your sales.&#xD;
11
+ &#xD;
12
+ Our catalog and flyer builder automatically creates professional and customizable catalogs and flyers for your Magento listings in under 30 seconds. 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
+ &#xD;
15
+ 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.&#xD;
16
+ </description>
17
+ <notes>First release</notes>
18
+ <authors><author><name>Kwaku Zigah</name><user>kwaku</user><email>kwaku.zigah@nowinstore.com</email></author></authors>
19
+ <date>2015-07-29</date>
20
+ <time>15:37:56</time>
21
+ <contents><target name="magecommunity"><dir name="NowInStore"><dir name="CatalogBuilder"><dir name="controllers"><file name="AuthController.php" hash="d64acfc32d9db86b3bb89ac537e2ea91"/><file name="CategoriesController.php" hash="8ac0b1276609c3498926ffe9632a4977"/><file name="ProductsController.php" hash="36dfdb8cd9ff135b3538251aa899bafd"/><file name="ProfileController.php" hash="05679442c999971bad022b2f580331d9"/></dir><dir name="etc"><file name="adminhtml.xml" hash="3d7e6a6f47a3a37945603d5620a49c22"/><file name="config.xml" hash="b99c8b2e611beeb92689696b77cdb917"/><file name="config.xml~" hash="fa9eaa937860779735ddee5bc4ec7f5f"/></dir></dir></dir></target></contents>
22
+ <compatible/>
23
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.5.0</min><max>1.9</max></package></required></dependencies>
24
+ </package>