Skip to content

Instantly share code, notes, and snippets.

@dubrod dubrod/MODX ID to JSON
Last active Jan 23, 2019

Embed
What would you like to do?
MODX ID to JSON
<?php
header("Content-Type:application/json");
$id = $_GET["id"];
if(empty($id)){ die(); }
$obj = $modx->getObject('modResource', $id);
$output = [];
$output = array(
"name" => $obj->get('longtitle'),
"sku" => $obj->getTVValue('sku'),
"img" => $obj->getTVValue('product_img'),
"barrel_length" => $obj->getTVValue('barrel-length')
);
return $modx->toJson($output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.