Hola, estoy haciendo una tienda basada en dropshipping. Mi proveedor me facilito un script en php que debe ir en la raiz del ftp, una vez lo pongo me devuelve error500 y lógicamente no puedo ponerlo en CRON porque no funciona. ¿Que puede estar fallando?
Aquí os dejo el código:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
include('config/config.inc.php');
$db = new PDO("mysql:host=localhost;port=3306;dbname="._DB_NAME_."", _DB_USER_, _DB_PASSWD_);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$jsonData = json_decode(file_get_contents('http://webproveedor.com/pedidosjson.php'));
foreach($jsonData->data as $rowjson){
$quantity = $rowjson->Existencias-$rowjson->Reservas;
$res4 = $db->prepare("SELECT id_product, id_product_attribute from vs_product_attribute WHERE reference = :reference");
$res4->execute(array(':reference'=> $rowjson->Articulo));
echo '[' . $rowjson->Articulo . ']' . $rowjson->Descripcion . ' => ' . $quantity . '<br/>';
if ($res4->rowCount() > 0) {
$row4 = $res4->fetch();
$res = $db->prepare("update vs_stock_available set quantity = :q where id_product_attribute = :id_product_attribute");
$res->execute(array(':q'=>$quantity, ':id_product_attribute'=>$row4['id_product_attribute']));
$res = $db->prepare("update vs_product_attribute set quantity = :q where id_product_attribute = :id_product_attribute");
$res->execute(array(':q'=>$quantity, ':id_product_attribute'=>$row4['id_product_attribute']));
$res = $db->prepare("update vs_product_attribute set wholesale_price = :q where id_product_attribute = :id_product_attribute");
$res->execute(array(':q'=>$rowjson->cost, ':id_product_attribute'=>$row4['id_product_attribute']));
$res = $db->prepare("update vs_stock_available set quantity = quantity + :q where id_product = :id_product and id_product_attribute = 0");
$res->execute(array(':q'=>$quantity, ':id_product'=>$row4['id_product']));
$res = $db->prepare("update vs_product set quantity = quantity + :q where id_product = :id_product");
$res->execute(array(':q'=>$quantity, ':id_product'=>$row4['id_product']));
$res = $db->prepare("update vs_product set wholesale_price = :q where id_product = :id_product");
$res->execute(array(':q'=>$rowjson->cost, ':id_product'=>$row4['id_product']));
} else {
$res4 = $db->prepare("SELECT id_product from vs_product WHERE reference = :reference");
$res4->execute(array(':reference'=>$rowjson->Articulo));
if ($res4->rowCount() > 0) {
$row4 = $res4->fetch();
$res = $db->prepare("update vs_stock_available set quantity = :q where id_product = :id_product and id_product_attribute = 0");
$res->execute(array(':q'=>$quantity, ':id_product'=>$row4['id_product']));
$res = $db->prepare("update vs_product set quantity = :q where id_product = :id_product");
$res->execute(array(':q'=>$quantity, ':id_product'=>$row4['id_product']));
}
}
}
Db::getInstance()->Execute("UPDATE vs_product_shop SET cache_default_attribute = NULL");
Db::getInstance()->Execute("UPDATE vs_product SET cache_default_attribute = NULL");
die();
?>