Problem synchro sell with API Rest

  • philatelie-lmi77

    19 messaggi

    Francia

    Hello, I encounter difficulties with API rest when I sell a product and the stock is zero, I would like to know how the API treats it because the API does not update my stock on Prestashop! Can you tell me how the API treats a product whose stock goes from 1 to 0 after a sale, and especially if this task is done in real time or if this task is in a queue and s' run later. Thank you
  • Account eliminato
    Account eliminato

    0 messaggi

    Belgio

    Le informazioni non sono più disponibili perché l'account di questo utente è stato eliminato (Regolamento RGPD).
  • philatelie-lmi77

    19 messaggi

    Francia

    Le informazioni non sono più disponibili perché l'account di questo utente è stato eliminato (Regolamento RGPD).
    • Creato 25 giu 2018 a 04:34
    • #877429
    Yes, it works well for the release of new products, updating quantities, prices ... But this does not seem to work for the notification of sales that are closed following a sale.
  • Account eliminato
    Account eliminato

    0 messaggi

    Belgio

    Le informazioni non sono più disponibili perché l'account di questo utente è stato eliminato (Regolamento RGPD).
  • philatelie-lmi77

    19 messaggi

    Francia

    Le informazioni non sono più disponibili perché l'account di questo utente è stato eliminato (Regolamento RGPD).
    • Creato 25 giu 2018 a 05:02
    • #877444
    Here is the piece of code written to handle these notifications :

    $delcampesynchro = new DelcampeSynchro();
    $context = Context::getContext();

    if(isset($_POST['delcampeNotification'])) {
    $delcampe_notification_obj = new SimpleXMLElement($_POST['delcampeNotification']);
    $delcampe_item_id = $delcampe_notification_obj->Notification_Data->id_item;
    $delcampe_personnal_ref = $delcampe_notification_obj->Notification_Data->personal_reference;
    $prestashop_item_id = str_replace('PLMI77-', '', $delcampe_personnal_ref);
    $quantity_to_decrement = $delcampe_notification_obj->Notification_Data->qty;
    $quantity_product = StockAvailable::getQuantityAvailableByProduct($prestashop_item_id, null, 1);
    $final_quantity = $quantity_product - $quantity_to_decrement;
    $product = new Product($prestashop_item_id);

    if($final_quantity == 0) {
    $delcampesynchro->closeItemOnDelcampe($delcampe_item_id);
    }

    $q = "UPDATE ps_stock_available SET quantity = ".$final_quantity." WHERE id_product = ".$prestashop_item_id;
    Db::getInstance()->execute($q);

    Hook::exec('actionProductUpdate', array(
    'id_product' => $prestashop_item_id,
    'product' => $product,
    'delcampe_no_synchro' => true
    )
    );
    }

    Associé au hook « itemSold »
  • philatelie-lmi77

    19 messaggi

    Francia

    Le informazioni non sono più disponibili perché l'account di questo utente è stato eliminato (Regolamento RGPD).
    • Creato 25 giu 2018 a 05:02
    • #877444
    One question, when selling a product and the stock is zero, the notification sent by delcampe is ItemSold or ItemUpdate?
  • Account eliminato
    Account eliminato

    0 messaggi

    Belgio

    One question, when selling a product and the stock is zero, the notification sent by delcampe is ItemSold or ItemUpdate?
    • Creato 25 giu 2018 a 05:14
    • #877450
    Le informazioni non sono più disponibili perché l'account di questo utente è stato eliminato (Regolamento RGPD).
  • Account eliminato
    Account eliminato

    0 messaggi

    Belgio

    Le informazioni non sono più disponibili perché l'account di questo utente è stato eliminato (Regolamento RGPD).
    • Creato 25 giu 2018 a 08:04
    • #877492
    Le informazioni non sono più disponibili perché l'account di questo utente è stato eliminato (Regolamento RGPD).
  • philatelie-lmi77

    19 messaggi

    Francia

    OK, that's what we use. Can you indicate to me if the notification of closing of a product following a sale intervenes immediately or not (queue)? do you have an example of how we should use Seller_Item_Close_Sold: Link (https)
    Thanks
  • Account eliminato
    Account eliminato

    0 messaggi

    Belgio

    OK, that's what we use. Can you indicate to me if the notification of closing of a product following a sale intervenes immediately or not (queue)? do you have an example of how we should use Seller_Item_Close_Sold: Link (https)
    Thanks
    • Creato 25 giu 2018 a 09:38
    • #877522
    Le informazioni non sono più disponibili perché l'account di questo utente è stato eliminato (Regolamento RGPD).
  • Account eliminato
    Account eliminato

    0 messaggi

    Belgio

    Le informazioni non sono più disponibili perché l'account di questo utente è stato eliminato (Regolamento RGPD).
  • philatelie-lmi77

    19 messaggi

    Francia

    no, the problem persists and my developer will be able to look at it only in 15 days because it is on leave.

Unisciti alla community di collezionisti!

Registrati Login