Skip to content

Instantly share code, notes, and snippets.

@epicbagel
Last active August 16, 2017 02:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epicbagel/a8c20e81aeeb0c7412c5d75a8e3aa7b3 to your computer and use it in GitHub Desktop.
Save epicbagel/a8c20e81aeeb0c7412c5d75a8e3aa7b3 to your computer and use it in GitHub Desktop.
<?php
/*
Place this file in the following file (you'll need to create this file if it doesn't yet exist).
/public_html/catalog/controller/api/jetti.php
To check it is working, you can then load the following URL. You should see your list of products:
https://<your domain here>/index.php?route=api/jetti/products
*/
class ControllerApiJetti extends Controller {
public function products() {
$this->load->language('api/custom');
$json = array();
$this->load->model('catalog/product');
// Get all products
$products = $this->model_catalog_product->getProducts();
foreach ($products as $product) {
// Add the images for this product to the response
$json['success']['images'][$product['product_id']] = $this->model_catalog_product->getProductImages($product['product_id']);
}
$json['success']['products'] = $products;
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment