Created
October 22, 2017 23:46
-
-
Save reginaldojunior/0c7627e32f3e35ad8172b4eeae98da09 to your computer and use it in GitHub Desktop.
opencart-products-actives.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ini_set('memory_limit', '-1'); | |
error_reporting(0); | |
class ControllerApiCiawn extends Controller | |
{ | |
/** | |
* @example http://domain.com/index.php?route=api/ciawn/getProductsActives | |
* @param @name | |
**/ | |
public function getProductsActives() | |
{ | |
$this->load->model('catalog/product'); | |
$name = $this->request->get['name']; | |
$data = array( | |
'filter_status' => 1 | |
); | |
if (isset($name) && !empty($name)) { | |
$data['filter_name'] = $name; | |
} | |
$response = $this->model_catalog_product->getProducts($data); | |
if (isset($this->request->server['HTTP_ORIGIN'])) { | |
$this->response->addHeader( | |
'Access-Control-Allow-Origin: ' . $this->request->server['HTTP_ORIGIN'] | |
); | |
$this->response->addHeader( | |
'Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS' | |
); | |
$this->response->addHeader( | |
'Access-Control-Max-Age: 1000' | |
); | |
$this->response->addHeader( | |
'Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With' | |
); | |
} | |
$this->response->addHeader('Content-Type: application/json'); | |
$this->response->setOutput(json_encode($response)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment