/
update_variant.php
59 lines (30 loc) · 1.19 KB
/
update_variant.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
session_start();
require __DIR__.'/vendor/autoload.php';
use phpish\shopify;
require __DIR__.'/conf.php';
require __DIR__.'/includes/functions.php';
require __DIR__.'/spreadsheet-reader/php-excel-reader/excel_reader2.php';
require __DIR__.'/spreadsheet-reader/SpreadsheetReader.php';
echo "<pre>";
$PricePlanReader = new SpreadsheetReader('price_plan.xls');
$pricePlans = getPricePlans($PricePlanReader);
$shopify = shopify\client(SHOPIFY_SHOP, SHOPIFY_APP_API_KEY, SHOPIFY_APP_PASSWORD, true);
$products = getShopifyProducts($shopify);
$response = getVariants($products, $pricePlans);
$updatedVariantsCnt=0;
foreach ($response as $variantData) {
$variantId = $variantData['id'];
$values = getProductBySku($variantData['sku']);
$basicVariants = getbasicVariants($values);
$priceVariant = array('price' => $variantData['price']);
$variant = array_merge( $priceVariant, $basicVariants );
$data = array('variant' => $variant);
updateVariants($shopify, $data, $variantId);
usleep(500000);
$updatedVariantsCnt++;
}
echo "</pre>";
?>
Updated <?php echo $updatedVariantsCnt; ?> Products Variants.<br />
<a href="<?php echo SITE_URL; ?>/index.php">Home</a>