/** * Create Metafield for a product */ public function getCreateProductMetaField() { $metafield = new \erdiko\shopify\models\Metafield(); $productID = $_GET['product_id']; $args = array("metafield" => array("namespace" => "inventory", "key" => $_GET['key'], "value" => $_GET['value'], "value_type" => $_GET['value_type'])); $metafield->setProductMetaField($productID, $args); }
/** * Create Metafield for a product */ public function getCreateProductMetaField() { $metafield = new \erdiko\shopify\models\Metafield(); $productID = $_GET['product_id']; $args = array("metafield" => array("namespace" => $metafields->getNamespace(), "key" => $_GET['key'], "value" => $_GET['value'], "value_type" => $_GET['value_type'])); $message = "successfully processed the request"; try { $metafield->setProductMetaField($productID, $args); } catch (ShopifyApiException $e) { $response_headers = $e->getResponseHeaders(); $message = "Error in adding Product Metafield :: " . $response_headers['http_status_code'] . ":" . $response_headers['http_status_message']; } catch (ShopifyCurlException $e) { $message = "Error :: Shopify Curl Exception"; } catch (\Exception $e) { $message = $e->getMessage(); } $this->setContent($this->getLayout('message', $message, dirname(__DIR__))); }