Last active
January 23, 2019 21:39
-
-
Save dubrod/6451d4cc0029ec56242aa27d0f5b368a to your computer and use it in GitHub Desktop.
MODX ID to JSON
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 | |
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