<?php

require_once('database.php');

$productString='[
  {
    "SrNo": 1,
    "ProductName": "3 stages pre-treatment filters DCII - 1303 (PV : 3500)",
    "Category": "Water Ionizer",
    "Title": "Purchase",
    "ProductID": 1463090577523,
    "VariantID": 14699081302131,
    "ProductPrice": 6136,
    "ProductPV": 3500
  },
  {
    "SrNo": 2,
    "ProductName": "3 stages pre-treatment filters DCII - 1303 (PV : 3500)",
    "Category": "Water Ionizer",
    "Title": "Repurchase",
    "ProductID": 1463090577523,
    "VariantID": 16027306983539,
    "ProductPrice": 5830,
    "ProductPV": 3500
  },
  {
    "SrNo": 3,
    "ProductName": "Activated Carbon Filter Cartridge For HI-TAQ7/HI-TA817 (PV : 7000)",
    "Category": "Water Ionizer",
    "Title": "Purchase",
    "ProductID": 1463004004467,
    "VariantID": 14698536927347,
    "ProductPrice": 11799,
    "ProductPV": 7000
  },
  {
    "SrNo": 4,
    "ProductName": "Activated Carbon Filter Cartridge For HI-TAQ7/HI-TA817 (PV : 7000)",
    "Category": "Water Ionizer",
    "Title": "Repurchase",
    "ProductID": 1463004004467,
    "VariantID": 16038181175411,
    "ProductPrice": 11208,
    "ProductPV": 7000
  },
  {
    "SrNo": 5,
    "ProductName": "Aloe Vera Soap (PV : 81)",
    "Category": "Personal Care",
    "Title": "Default Title",
    "ProductID": 1654345334899,
    "VariantID": 16482520924275,
    "ProductPrice": 125,
    "ProductPV": 81
  },
  {
    "SrNo": 6,
    "ProductName": "Anti-Oxidant Lightening Cleanser (50 ml) (PV : 3850)",
    "Category": "Skinceuticals",
    "Title": "Purchase",
    "ProductID": 1034902700147,
    "VariantID": 10898674352243,
    "ProductPrice": 7840,
    "ProductPV": 3850
  },
  {
    "SrNo": 7,
    "ProductName": "Anti-Oxidant Lightening Cleanser (50 ml) (PV : 3850)",
    "Category": "Skinceuticals",
    "Title": "Repurchase",
    "ProductID": 1034902700147,
    "VariantID": 14588763504755,
    "ProductPrice": 7448,
    "ProductPV": 3850
  },
  {
    "SrNo": 8,
    "ProductName": "Astaxanthin (180 Capsules) (PV : 1800)",
    "Category": "Nutraceuticals",
    "Title": "Purchase",
    "ProductID": 1466748993651,
    "VariantID": 14729072017523,
    "ProductPrice": 3835,
    "ProductPV": 1800
  },
  {
    "SrNo": 9,
    "ProductName": "Astaxanthin (180 Capsules) (PV : 1800)",
    "Category": "Nutraceuticals",
    "Title": "Repurchase",
    "ProductID": 1466748993651,
    "VariantID": 16021300052083,
    "ProductPrice": 3459,
    "ProductPV": 1800
  },
  {
    "SrNo": 11,
    "ProductName": "Buder Alkaline Water Ionizer (Type - Under Sink) (TAQ-7) (PV : 170000)",
    "Category": "Water Ionizer",
    "Title": "Purchase",
    "ProductID": 1112508334195,
    "VariantID": 11498288414835,
    "ProductPrice": 365800,
    "ProductPV": 170000
  },
  {
    "SrNo": 12,
    "ProductName": "Buder Alkaline Water Ionizer (Type - Under Sink) (TAQ-7) (PV : 170000)",
    "Category": "Water Ionizer",
    "Title": "Repurchase",
    "ProductID": 1112508334195,
    "VariantID": 14650504773747,
    "ProductPrice": 347510,
    "ProductPV": 170000
  },
  {
    "SrNo": 13,
    "ProductName": "Buder Alkaline Water Ionizer - 7 Plates (HI-TA 817) (Type - Counter Top) (PV :150000)",
    "Category": "Water Ionizer",
    "Title": "Purchase",
    "ProductID": 1035245813875,
    "VariantID": 16020321206387,
    "ProductPrice": 238950,
    "ProductPV": 150000
  },
  {
    "SrNo": 14,
    "ProductName": "Buder Alkaline Water Ionizer - 7 Plates (HI-TA 817) (Type - Counter Top) (PV :150000)",
    "Category": "Water Ionizer",
    "Title": "Repurchase",
    "ProductID": 1035245813875,
    "VariantID": 16020332609651,
    "ProductPrice": 227002,
    "ProductPV": 150000
  },
  {
    "SrNo": 16,
    "ProductName": "BUDER Alkaline Water Ionizer- (HI-TA-817) (On EMI) - 7 plates (PV : 185000)",
    "Category": "Water Ionizer",
    "Title": "Purchase",
    "ProductID": 1738948935795,
    "VariantID": 17130638671987,
    "ProductPrice": 100000,
    "ProductPV": 185000
  },
  {
    "SrNo": 17,
    "ProductName": "BUDER Alkaline Water Ionizer- (HI-TA-817) (On EMI) - 7 plates (PV : 185000)",
    "Category": "Water Ionizer",
    "Title": "Repurchase",
    "ProductID": 1738948935795,
    "VariantID": 17130638704755,
    "ProductPrice": 95000,
    "ProductPV": 185000
  },
  {
    "SrNo": 27,
    "ProductName": "Energize Shower Gel (PV : 107)",
    "Category": "Personal Care",
    "Title": "Pre-Order",
    "ProductID": 1654099542131,
    "VariantID": 16481000292467,
    "ProductPrice": 165,
    "ProductPV": 107
  },
  {
    "SrNo": 28,
    "ProductName": "Energy Spray (13.5 ml) (Buy1Get1)(PV : 1950)",
    "Category": "Nano Supplements",
    "Title": "Purchase",
    "ProductID": 1469229138035,
    "VariantID": 16020833566835,
    "ProductPrice": 4130,
    "ProductPV": 1950
  },
  {
    "SrNo": 29,
    "ProductName": "Energy Spray (13.5 ml) (Buy1Get1)(PV : 1950)",
    "Category": "Nano Supplements",
    "Title": "Repurchase",
    "ProductID": 1469229138035,
    "VariantID": 16020854767731,
    "ProductPrice": 3924,
    "ProductPV": 1950
  },
  {
    "SrNo": 30,
    "ProductName": "Enrich Conditioner (PV : 257)",
    "Category": "Personal Care",
    "Title": "Purchase",
    "ProductID": 1654289301619,
    "VariantID": 16482176794739,
    "ProductPrice": 467,
    "ProductPV": 257
  },
  {
    "SrNo": 31,
    "ProductName": "Enrich Conditioner (PV : 257)",
    "Category": "Personal Care",
    "Title": "Repurchase",
    "ProductID": 1654289301619,
    "VariantID": 17657393381491,
    "ProductPrice": 443,
    "ProductPV": 257
  },
  {
    "SrNo": 33,
    "ProductName": "Freestanding Ionizer Water Dispenser (TA-819) (PV : 170000)",
    "Category": "Water Ionizer",
    "Title": "Purchase",
    "ProductID": 1112515346547,
    "VariantID": 16020386513011,
    "ProductPrice": 310000,
    "ProductPV": 170000
  },
  {
    "SrNo": 34,
    "ProductName": "Freestanding Ionizer Water Dispenser (TA-819) (PV : 170000)",
    "Category": "Water Ionizer",
    "Title": "Repurchase",
    "ProductID": 1112515346547,
    "VariantID": 16020398211187,
    "ProductPrice": 294500,
    "ProductPV": 170000
  },
  {
    "SrNo": 35,
    "ProductName": "Glimmer Face wash (PV :114)",
    "Category": "Personal Care",
    "Title": "Purchase",
    "ProductID": 1654249521267,
    "VariantID": 16481921663091,
    "ProductPrice": 207,
    "ProductPV": 114
  },
  {
    "SrNo": 36,
    "ProductName": "Glimmer Face wash (PV :114)",
    "Category": "Personal Care",
    "Title": "Repurchase",
    "ProductID": 1654249521267,
    "VariantID": 17657419104371,
    "ProductPrice": 197,
    "ProductPV": 114
  },
  {
    "SrNo": 38,
    "ProductName": "Hairfluence - Vitamins for hair (60 capsules) (PV : 1650)",
    "Category": "Nutraceuticals",
    "Title": "Purchase",
    "ProductID": 1463462527091,
    "VariantID": 14702149435507,
    "ProductPrice": 3540,
    "ProductPV": 1650
  },
  {
    "SrNo": 39,
    "ProductName": "Hairfluence - Vitamins for hair (60 capsules) (PV : 1650)",
    "Category": "Nutraceuticals",
    "Title": "Repurchase",
    "ProductID": 1463462527091,
    "VariantID": 16021219278963,
    "ProductPrice": 3363,
    "ProductPV": 1650
  },
  {
    "SrNo": 40,
    "ProductName": "Handmade Classic Bathing Bar Collection (Buy 2 Get 1) (PV : 335)",
    "Category": "Personal Care",
    "Title": "Purchase",
    "ProductID": 1751546724467,
    "VariantID": 17355305746547,
    "ProductPrice": 620,
    "ProductPV": 335
  },
  {
    "SrNo": 41,
    "ProductName": "Handmade Classic Bathing Bar Collection (Buy 2 Get 1) (PV : 335)",
    "Category": "Personal Care",
    "Title": "Repurchase",
    "ProductID": 1751546724467,
    "VariantID": 17657444663411,
    "ProductPrice": 589,
    "ProductPV": 335
  },
  {
    "SrNo": 46,
    "ProductName": "High-Concentration Hydrogen Water Generator (HS-72) (PV : 60000)",
    "Category": "Hydrogen Water Generator",
    "Title": "Purchase",
    "ProductID": 1112027299955,
    "VariantID": 16020432846963,
    "ProductPrice": 123900,
    "ProductPV": 60000
  },
  {
    "SrNo": 47,
    "ProductName": "High-Concentration Hydrogen Water Generator (HS-72) (PV : 60000)",
    "Category": "Hydrogen Water Generator",
    "Title": "Repurchase",
    "ProductID": 1112027299955,
    "VariantID": 16020439597171,
    "ProductPrice": 117705,
    "ProductPV": 60000
  },
  {
    "SrNo": 51,
    "ProductName": "Hydrogen Water Generator Bottle (HI-TA 13) (PV : 18000 )",
    "Category": "Hydrogen Water Generator",
    "Title": "Purchase",
    "ProductID": 1711548170355,
    "VariantID": 17654930899059,
    "ProductPrice": 42480,
    "ProductPV": 18000
  },
  {
    "SrNo": 52,
    "ProductName": "Hydrogen Water Generator Bottle (HI-TA 13) (PV : 18000 )",
    "Category": "Hydrogen Water Generator",
    "Title": "Repurchase",
    "ProductID": 1711548170355,
    "VariantID": 17654966419571,
    "ProductPrice": 40356,
    "ProductPV": 18000
  },
  {
    "SrNo": 53,
    "ProductName": "Jivi Booster - Touch and Type Smartphone (PV : 2000)",
    "Category": "Electronics",
    "Title": "pre-order",
    "ProductID": 1631480119411,
    "VariantID": 16292838506611,
    "ProductPrice": 4499,
    "ProductPV": 2000
  },
  {
    "SrNo": 55,
    "ProductName": "LaLuna Melatonin Oral Spray (13.5 ml) (PV : 1950)",
    "Category": "Nano Supplements",
    "Title": "Left",
    "ProductID": 1112498634867,
    "VariantID": 14649980878963,
    "ProductPrice": 3500,
    "ProductPV": 1950
  },
  {
    "SrNo": 56,
    "ProductName": "LaLuna Melatonin Oral Spray (13.5 ml) (PV : 1950)",
    "Category": "Nano Supplements",
    "Title": "Right",
    "ProductID": 1112498634867,
    "VariantID": 11498166354035,
    "ProductPrice": 3500,
    "ProductPV": 1950
  },
  {
    "SrNo": 57,
    "ProductName": "MultiVitamin - Easy Stay Healthy (13.5 ml) (Buy 1 Get 1) (1950 PV)",
    "Category": "Nano Supplements",
    "Title": "Purchase",
    "ProductID": 1461851619443,
    "VariantID": 14690357444723,
    "ProductPrice": 4130,
    "ProductPV": 1950
  },
  {
    "SrNo": 58,
    "ProductName": "MultiVitamin - Easy Stay Healthy (13.5 ml) (Buy 1 Get 1) (1950 PV)",
    "Category": "Nano Supplements",
    "Title": "Repurchase",
    "ProductID": 1461851619443,
    "VariantID": 16020943241331,
    "ProductPrice": 3924,
    "ProductPV": 1950
  },
  {
    "SrNo": 62,
    "ProductName": "MyBooster Printed Diary and Pen (PV : 200)",
    "Category": "",
    "Title": "Purchase",
    "ProductID": 1736204714099,
    "VariantID": 17110029336691,
    "ProductPrice": 504,
    "ProductPV": 200
  },
  {
    "SrNo": 63,
    "ProductName": "MyBooster Printed Diary and Pen (PV : 200)",
    "Category": "",
    "Title": "Repurchase",
    "ProductID": 1736204714099,
    "VariantID": 17657496731763,
    "ProductPrice": 479,
    "ProductPV": 200
  },
  {
    "SrNo": 64,
    "ProductName": "MyBooster Printed Water Bottle (PV : 250)",
    "Category": "",
    "Title": "Purchase",
    "ProductID": 1736209465459,
    "VariantID": 17110107652211,
    "ProductPrice": 585,
    "ProductPV": 250
  },
  {
    "SrNo": 65,
    "ProductName": "MyBooster Printed Water Bottle (PV : 250)",
    "Category": "",
    "Title": "Repurchase",
    "ProductID": 1736209465459,
    "VariantID": 17657809666163,
    "ProductPrice": 555,
    "ProductPV": 250
  },
  {
    "SrNo": 66,
    "ProductName": "Nano Freedom - Sanitary Pads (PV : 150)",
    "Category": "NANOTECH",
    "Title": "Left",
    "ProductID": 1110783393907,
    "VariantID": 14649998606451,
    "ProductPrice": 270,
    "ProductPV": 150
  },
  {
    "SrNo": 67,
    "ProductName": "Nano Freedom - Sanitary Pads (PV : 150)",
    "Category": "NANOTECH",
    "Title": "Right",
    "ProductID": 1110783393907,
    "VariantID": 11476264157299,
    "ProductPrice": 270,
    "ProductPV": 150
  },
  {
    "SrNo": 68,
    "ProductName": "Nanoenergizer - Universal & Aio -Engine Platinum-Ceramic Coating (PV : 1500)",
    "Category": "NANOTECH",
    "Title": "Left",
    "ProductID": 1110749937779,
    "VariantID": 14650012565619,
    "ProductPrice": 2700,
    "ProductPV": 1500
  },
  {
    "SrNo": 69,
    "ProductName": "Nanoenergizer - Universal & Aio -Engine Platinum-Ceramic Coating (PV : 1500)",
    "Category": "NANOTECH",
    "Title": "Right",
    "ProductID": 1110749937779,
    "VariantID": 11475798458483,
    "ProductPrice": 2700,
    "ProductPV": 1500
  },
  {
    "SrNo": 70,
    "ProductName": "Nanomaxx - Radiator Coolant Additive (PV : 1500)",
    "Category": "NANOTECH",
    "Title": "Left",
    "ProductID": 1110768058483,
    "VariantID": 14650037698675,
    "ProductPrice": 2700,
    "ProductPV": 1500
  },
  {
    "SrNo": 71,
    "ProductName": "Nanomaxx - Radiator Coolant Additive (PV : 1500)",
    "Category": "NANOTECH",
    "Title": "Right",
    "ProductID": 1110768058483,
    "VariantID": 11476063846515,
    "ProductPrice": 2700,
    "ProductPV": 1500
  },
  {
    "SrNo": 72,
    "ProductName": "Nurture Body Lotion (PV : 150)",
    "Category": "Personal Care",
    "Title": "Purchase",
    "ProductID": 1654311977075,
    "VariantID": 16482316320883,
    "ProductPrice": 272,
    "ProductPV": 150
  },
  {
    "SrNo": 73,
    "ProductName": "Nurture Body Lotion (PV : 150)",
    "Category": "Personal Care",
    "Title": "Repurchase",
    "ProductID": 1654311977075,
    "VariantID": 17657839779955,
    "ProductPrice": 258,
    "ProductPV": 150
  },
  {
    "SrNo": 75,
    "ProductName": "Nutravita High Strength Biotin Supplements (365 soft gels) (PV : 3050)",
    "Category": "Nutraceuticals",
    "Title": "Purchase",
    "ProductID": 1035214454899,
    "VariantID": 16021261516915,
    "ProductPrice": 5605,
    "ProductPV": 3050
  },
  {
    "SrNo": 76,
    "ProductName": "Nutravita High Strength Biotin Supplements (365 soft gels) (PV : 3050)",
    "Category": "Nutraceuticals",
    "Title": "Repurchase",
    "ProductID": 1035214454899,
    "VariantID": 16021267972211,
    "ProductPrice": 5326,
    "ProductPV": 3050
  },
  {
    "SrNo": 77,
    "ProductName": "Nutravita Purebiotic - Probiotic Pearls (180 count) (PV : 3100)",
    "Category": "Nutraceuticals",
    "Title": "Purchase",
    "ProductID": 1035187454067,
    "VariantID": 16021188083827,
    "ProductPrice": 5605,
    "ProductPV": 3100
  },
  {
    "SrNo": 78,
    "ProductName": "Nutravita Purebiotic - Probiotic Pearls (180 count) (PV : 3100)",
    "Category": "Nutraceuticals",
    "Title": "Repurchase",
    "ProductID": 1035187454067,
    "VariantID": 16021196996723,
    "ProductPrice": 5326,
    "ProductPV": 3100
  },
  {
    "SrNo": 79,
    "ProductName": "Nutravita Vitamin B12 Pearls (180 count) (PV : 1900)",
    "Category": "Nutraceuticals",
    "Title": "Left",
    "ProductID": 1035229757555,
    "VariantID": 14650052870259,
    "ProductPrice": 3250,
    "ProductPV": 1900
  },
  {
    "SrNo": 80,
    "ProductName": "Nutravita Vitamin B12 Pearls (180 count) (PV : 1900)",
    "Category": "Nutraceuticals",
    "Title": "Right",
    "ProductID": 1035229757555,
    "VariantID": 10903757619315,
    "ProductPrice": 3250,
    "ProductPV": 1900
  },
  {
    "SrNo": 81,
    "ProductName": "Omega 3, 1000mg (180 soft gels) (PV : 1800)",
    "Category": "Nutraceuticals",
    "Title": "Purchase",
    "ProductID": 1035206361203,
    "VariantID": 16021235466355,
    "ProductPrice": 3835,
    "ProductPV": 1800
  },
  {
    "SrNo": 82,
    "ProductName": "Omega 3, 1000mg (180 soft gels) (PV : 1800)",
    "Category": "Nutraceuticals",
    "Title": "Repurchase",
    "ProductID": 1035206361203,
    "VariantID": 16021239922803,
    "ProductPrice": 3644,
    "ProductPV": 1800
  }
]';



$productArray = json_decode($productString);
//$memberIDArray = $memberIDString;

$conn = new Database;
$db = $conn->getConnection();
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);


foreach($productArray as $row)
{
	$data = array();
	$data['ProductName'] = $row->ProductName;
	$data['Category'] = $row->Category;
	$data['ProductID'] = $row->ProductID;
	$data['VariantID'] = $row->VariantID;
    $data['ProductPrice'] = $row->ProductPrice;
	$data['ProductPV'] = $row->ProductPV;

    addProductInfo($data, $db);

}



function addProductInfo($data, $db)
	{
		try{

			$sql = "INSERT INTO my_product(id, product_id, name, title, category, price, pricevalue, status) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";

			$stmt = $db->prepare($sql);
			
			$stmt->execute(array($data['VariantID'], $data['ProductID'], $data['ProductName'], $data['ProductName'], $data['Category'], $data['ProductPrice'], $data['ProductPV'], '1'));

			return true;
	
		}


		catch(Exception $e)
		{
			$e->getMessage();
			return false;

		}

	}











?>