Hello
i have a shopify site, and i am using a custom xml php for create a custom xml file. My problem is that the xml has only values from [login to view URL] and i would like to include a collection id from collections.json. Here is the code:
$sc = new ShopifyPrivateAppClient(getShop(), getAPIKey(), getAPIPassword());
$outdata = $sc->call('GET', '/admin/[login to view URL]');
$outObj = json_encode($outdata);
if (isset($outObj->errors)) {
//file_put_contents("[login to view URL]", $outObj, FILE_APPEND);
} else {
$outObj = json_decode($outObj);
$products = array();
foreach ($outObj as $obj) {
foreach ($obj->variants as $variant) {
$product = new stdClass();
$product->id = $obj->id;
$product->sku = $variant->sku;
$product->title = $obj->title;
$product->link = getStoreurl() . "/products/" . $obj->handle;
$product->image = "";
$product->type = $obj->product_type;
$product->price = $variant->price;
$product->instock = $variant->inventory_quantity > 0 ? 'Y' : 'N';
$product->color = $variant->option3;
$product->categoryID = "";
$product->vendor = $obj->vendor;
$product->description = $obj->body_html;
$product->weight = $variant->grams;
foreach ($obj->images as $image) {
$product->image = $image->src;
}
array_push($products, $product);
}
}
$mywebstore = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><mywebstore/>');
/* append it to the document created */
$date = date('Y/m/d H:i:s');
$mywebstore->addChild("created_at", $date);
$productsroot = $mywebstore->addChild("products");
foreach ($products as $product) {
$singleproduct = $productsroot->addChild("product");
$singleproduct->addAttribute("ID", $product->id);
$singleproduct->addChild("UniqueID", $product->sku);
$singleproduct->addChild("Title", $product->title);
$singleproduct->addChild("url", $product->link);
$singleproduct->addChild("Image", $product->image);
$cat = $singleproduct->addChild("Category", $product->type);
$cat->addAttribute("ID", $product->categoryID);
$singleproduct->addChild("Price", $product->price);
$singleproduct->addChild("Instock", $product->instock);
$singleproduct->addChild("Availability", "Σε απόθεμα");
$singleproduct->addChild("Manufacturer", $product->vendor);
$singleproduct->addChild("Description", $product->description);
$singleproduct->addChild("Weight", $product->weight);
$singleproduct->addChild("Color", $product->color);
$singleproduct->addChild("Shipping", "");
I need in categoryID Field to have the collection id from collection.json. Is something very simple so my budget is 10€