Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
feature/evr-299-magento - Created special route to allow to allow for…
Browse files Browse the repository at this point in the history
… access to contacts and addresses with one API call.
  • Loading branch information
ade committed Jun 29, 2020
1 parent 3af61ad commit 8a233af
Show file tree
Hide file tree
Showing 12 changed files with 198 additions and 34 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Everlytic Magento 1.9 Extension
Ev Magento 1.9 Extension
=====================
![Maintenance](https://img.shields.io/maintenance/yes/2019)
----------
This repo contains the Magento Extension that allows connection to the Everlytic App .
This repo contains the Magento Extension that allows connection to the Ev App .

###### Features:
- Custom route to allow Everlytic to read product data from a Magento 1.9 installation.
- Custom route to allow Ev to read product data from a Magento 1.9 installation.

#### Installation

Expand All @@ -14,7 +14,7 @@ This repo contains the Magento Extension that allows connection to the Everlytic

###### Post Installation:
- Clear your cache, see the menu System > Cache Management
- Visit, System > Web Services > Rest Roles > Role API Resources to give access to the role to be used. Click on the Resource access drop-down and give access to Everlytic
- Visit, System > Web Services > Rest Roles > Role API Resources to give access to the role to be used. Click on the Resource access drop-down and give access to Ev
- Visit, System > Web Services > Rest Attributes. Choose the User Type, advisably Admin and choose the attributes to give access to.

##### Compatibility
Expand All @@ -30,4 +30,4 @@ TBD

Copyright
---------
(c) 2019 Everlytic
(c) 2019 Ev
37 changes: 37 additions & 0 deletions app/code/local/Everlytic/Customerapi/Model/Api2/Customer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* @category Mage
* @package Mage_Customer
* @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/**
* API2 class for customer
*
* @category Mage
* @package Mage_Customer
* @author Magento Core Team <[email protected]>
*/
class Everlytic_Customerapi_Model_Api2_Customer extends Mage_Api2_Model_Resource
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* @category Mage
* @package Mage_Catalog
* @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/**
* API2 for catalog_product (Admin)
*
* @category Mage
* @package Mage_Catalog
* @author Magento Core Team <[email protected]>
*/
class Everlytic_Customerapi_Model_Api2_Customer_Rest_Admin_V1 extends Mage_Customer_Model_Api2_Customer_Rest
{
/**
* Get customers list
*
* @return array
*/
protected function _retrieveCollection()
{
$data = Mage::getResourceModel('customer/customer_collection')
->addNameToSelect()
->addAttributeToSelect('gender')
->joinAttribute('street', 'customer_address/street', 'default_billing', null, 'left')
->joinAttribute('region', 'customer_address/region', 'default_billing', null, 'left')
->joinAttribute('city', 'customer_address/city', 'default_billing', null, 'left')
->joinAttribute('postcode', 'customer_address/postcode', 'default_billing', null, 'left')
->joinAttribute('country_id', 'customer_address/country_id', 'default_billing', null, 'left')
->joinAttribute('telephone', 'customer_address/telephone', 'default_billing', null, 'left')
->load();
$data = $data->toArray();
return isset($data['items']) ? $data['items'] : $data;
}
}
48 changes: 48 additions & 0 deletions app/code/local/Everlytic/Customerapi/etc/api2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0"?>
<config>
<api2>
<resource_groups>
<everlytic_customerapi translate="title" module="everlytic_customerapi">
<title>Everlytic</title>
<sort_order>10</sort_order>
</everlytic_customerapi>
</resource_groups>
<resources>
<everlytic_customerapi translate="title" module="everlytic_customerapi">
<group>everlytic_customerapi</group>
<model>everlytic_customerapi/api2_customer</model>
<working_model>customer/customer</working_model>
<title>Everlytic Customers</title>
<sort_order>10</sort_order>
<privileges>
<guest>
<retrieve>1</retrieve>
</guest>
<admin>
<retrieve>1</retrieve>
</admin>
</privileges>
<attributes translate="" module="everlytic_customerapi">
<entity_id>Customer ID</entity_id>
<firstname>First Name</firstname>
<lastname>Last Name</lastname>
<email>Email</email>
<gender>Gender</gender>
<postcode>Post Code</postcode>
<street>Street</street>
<region>Region</region>
<telephone>Telephone</telephone>
<city>City</city>
<country_id>Country</country_id>
</attributes>
<routes>
<route_collection>
<route>/everlytic/v1/customers</route>
<action_type>collection</action_type>
</route_collection>
</routes>
<versions>1</versions>
</everlytic_customerapi>
</resources>
</api2>
</config>
15 changes: 15 additions & 0 deletions app/code/local/Everlytic/Customerapi/etc/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<config>
<modules>
<Everlytic_Customerapi>
<version>0.1.0</version>
</Everlytic_Customerapi>
</modules>
<global>
<models>
<everlytic_customerapi>
<class>Everlytic_Customerapi_Model</class>
</everlytic_customerapi>
</models>
</global>
</config>
4 changes: 2 additions & 2 deletions app/code/local/Everlytic/Productapi/Helper/Data.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
namespace Everlytic\Extension\Helper;
namespace Ev\Extension\Helper;

use Mage_Core_Helper_Abstract;

class Data extends Mage_Core_Helper_Abstract
{

}
}
2 changes: 1 addition & 1 deletion app/code/local/Everlytic/Productapi/Model/Api2/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @package Mage_Catalog
* @author Magento Core Team <[email protected]>
*/
class Everlytic_Productapi_Model_Api2_Product extends Mage_Api2_Model_Resource
class Ev_Productapi_Model_Api2_Product extends Mage_Api2_Model_Resource
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @package Mage_Catalog
* @author Magento Core Team <[email protected]>
*/
class Everlytic_Productapi_Model_Api2_Product_Rest_Admin_V1 extends Mage_Catalog_Model_Api2_Product_Rest
class Ev_Productapi_Model_Api2_Product_Rest_Admin_V1 extends Mage_Catalog_Model_Api2_Product_Rest
{
/**
* The greatest decimal value which could be stored. Corresponds to DECIMAL (12,4) SQL type
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

class Everlytic_Productapi_IndexController extends Mage_Core_Controller_Front_Action{
class Ev_Productapi_IndexController extends Mage_Core_Controller_Front_Action{
public function indexAction(){
$product = $this->getRequest()->getParam('product');
$key = Mage::getSingleton('core/session')->getFormKey();;
Expand All @@ -11,4 +11,4 @@ public function indexAction(){
$this->_redirect('checkout/cart/add', array('product'=>$product, 'form_key'=>$key));
}
}
}
}
20 changes: 10 additions & 10 deletions app/code/local/Everlytic/Productapi/etc/api2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
<config>
<api2>
<resource_groups>
<everlytic_productapi translate="title" module="everlytic_productapi">
<title>Everlytic</title>
<ev_productapi translate="title" module="ev_productapi">
<title>Ev</title>
<sort_order>10</sort_order>
</everlytic_productapi>
</ev_productapi>
</resource_groups>
<resources>
<everlytic_productapi translate="title" module="everlytic_productapi">
<group>everlytic_productapi</group>
<model>everlytic_productapi/api2_product</model>
<ev_productapi translate="title" module="ev_productapi">
<group>ev_productapi</group>
<model>ev_productapi/api2_product</model>
<working_model>catalog/product</working_model>
<title>Everlytic Products</title>
<title>Ev Products</title>
<sort_order>10</sort_order>
<privileges>
<guest>
Expand All @@ -22,7 +22,7 @@
<retrieve>1</retrieve>
</admin>
</privileges>
<attributes translate="" module="everlytic_productapi">
<attributes translate="" module="ev_productapi">
<entity_id>Product ID</entity_id>
<name>Product Name</name>
<description>Product Description</description>
Expand All @@ -41,7 +41,7 @@
</route_collection>
</routes>
<versions>1</versions>
</everlytic_productapi>
</ev_productapi>
</resources>
</api2>
</config>
</config>
24 changes: 12 additions & 12 deletions app/code/local/Everlytic/Productapi/etc/config.xml
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
<?xml version="1.0"?>
<config>
<modules>
<Everlytic_Productapi>
<Ev_Productapi>
<version>0.1.0</version>
</Everlytic_Productapi>
</Ev_Productapi>
</modules>
<global>
<helpers>
<everlytic_productapi>
<class>Everlytic_Productapi_Helper</class>
</everlytic_productapi>
<ev_productapi>
<class>Ev_Productapi_Helper</class>
</ev_productapi>
</helpers>
<models>
<everlytic_productapi>
<class>Everlytic_Productapi_Model</class>
</everlytic_productapi>
<ev_productapi>
<class>Ev_Productapi_Model</class>
</ev_productapi>
</models>
</global>
<frontend>
<routers>
<everlytic_productapi>
<ev_productapi>
<use>standard</use>
<args>
<module>Everlytic_Productapi</module>
<module>Ev_Productapi</module>
<frontName>add-to-cart</frontName>
</args>
</everlytic_productapi>
</ev_productapi>
</routers>
</frontend>
</config>
</config>
10 changes: 9 additions & 1 deletion app/etc/modules/Mage_Everlytic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,13 @@
<Mage_Checkout />
</depends>
</Everlytic_Productapi>
<Everlytic_Customerapi>
<active>true</active>
<codePool>local</codePool>
<version>0.1.0</version>
<depends>
<Mage_Checkout />
</depends>
</Everlytic_Customerapi>
</modules>
</config>
</config>

0 comments on commit 8a233af

Please sign in to comment.