private function _displayMapping() { global $cookie; /* GET LISTS */ $db = Db::getInstance(); /* Get list features */ $query = 'SELECT fl.id_feature, fl.name FROM `' . _DB_PREFIX_ . 'feature` as f, `' . _DB_PREFIX_ . 'feature_lang` as fl WHERE f.id_feature=fl.id_feature AND fl.id_lang = "' . (int) GlobalConfig::getDefaultLangId() . '"'; $result = $db->ExecuteS($query); $this->listFeatures = $result; /* Get list Groups attributes */ $query = 'SELECT agl.id_attribute_group, agl.public_name FROM `' . _DB_PREFIX_ . 'attribute_group` as ag, `' . _DB_PREFIX_ . 'attribute_group_lang` as agl WHERE ag.id_attribute_group=agl.id_attribute_group AND agl.id_lang = "' . (int) GlobalConfig::getDefaultLangId() . '"'; $result = $db->ExecuteS($query); $this->listAttributesGp = $result; /* Get list Order states */ $query = 'SELECT osl.id_order_state, osl.name FROM `' . _DB_PREFIX_ . 'order_state` as os, `' . _DB_PREFIX_ . 'order_state_lang` as osl WHERE os.id_order_state=osl.id_order_state AND osl.id_lang = "' . (int) GlobalConfig::getDefaultLangId() . '"'; $result = $db->ExecuteS($query); $this->listOrderStates = $result; /* html */ $html = ' <fieldset> <legend><img src="' . $this->_path . 'img/liaisons.png" alt="" />' . $this->l('Attributes links') . '</legend> <p class="black"> <a href="index.php?tab=AdminFeatures&token=' . Tools::getAdminToken('AdminFeatures' . intval(Tab::getIdFromClassName('AdminFeatures')) . intval($cookie->id_employee)) . '"><img src="' . $this->_path . 'img/add.gif" alt="" />' . $this->l('Add a new feature') . '</a> <a href="index.php?tab=AdminAttributesGroups&token=' . Tools::getAdminToken('AdminAttributesGroups' . intval(Tab::getIdFromClassName('AdminAttributesGroups')) . intval($cookie->id_employee)) . '"><img src="' . $this->_path . 'img/add.gif" alt="" />' . $this->l('Add a new attribut') . '</a> </p> <label>' . $this->l('Attribute 1') . '</label> <div class="margin-form"> ' . $this->utilHtmlLinkAttribute(1) . ' </div> <label>' . $this->l('Attribute 2') . '</label> <div class="margin-form"> ' . $this->utilHtmlLinkAttribute(2) . ' </div> <label>' . $this->l('Attribute 3') . '</label> <div class="margin-form"> ' . $this->utilHtmlLinkAttribute(3) . ' </div> <label>' . $this->l('Attribute 4') . '</label> <div class="margin-form"> ' . $this->utilHtmlLinkAttribute(4) . ' </div> <label>' . $this->l('Attribute 5') . '</label> <div class="margin-form"> ' . $this->utilHtmlLinkAttribute(5) . ' </div> <label>' . $this->l('Attribute 6') . '</label> <div class="margin-form"> ' . $this->utilHtmlLinkAttribute(6) . ' </div> <label>' . $this->l('Volume') . '</label> <div class="margin-form"> ' . $this->utilHtmlLinkFeature('volume') . ' </div> </fieldset> <br /><br /> <fieldset> <legend><img src="' . $this->_path . 'img/orders.png" alt="" />' . $this->l('Orders status') . '</legend> <p class="black"> <a class="black" href="index.php?tab=AdminStatuses&token=' . Tools::getAdminToken('AdminStatuses' . intval(Tab::getIdFromClassName('AdminStatuses')) . intval($cookie->id_employee)) . '"><img src="' . $this->_path . 'img/add.gif" alt="" />' . $this->l('Add a new status') . '</a> </p> <label>' . $this->l('ID - On preparation') . ' <sup>*</sup></label> <div class="margin-form"> ' . $this->utilHtmlOrderState('on_preparation') . ' </div> <label>' . $this->l('ID - On delivery') . ' <sup>*</sup></label> <div class="margin-form"> ' . $this->utilHtmlOrderState('on_delivery') . ' </div> <label>' . $this->l('ID - Canceled') . ' <sup>*</sup></label> <div class="margin-form"> ' . $this->utilHtmlOrderState('canceled') . ' </div> </fieldset> <br /><br /> <fieldset> <legend><img src="' . $this->_path . 'img/price.png" alt="" />' . $this->l('Price to use') . '</legend> <i class="mini">' . $this->l('You can manage up to 5 different prices for the same item in OpenSi. Select the price you want to use below...') . '</i><br /> <i class="mini brown">' . $this->l('We advise you to get closer to the editor module before changing this parameter.') . '</i><br /><br /> <label>' . $this->l('Price used for this website') . ' <sup>*</sup></label> <div class="margin-form"> ' . $this->utilHtmlDefaultPrice() . ' </div> </fieldset> '; return $html; }
function updateMainProduct($product) { global $dao, $postOSIReq, $CONF_LastrequestLbl, $isOkResponses, $nbChildrenProducts, $nbResponse200, $nbResponseError, $nbResponse409, $nbNoReference; $attributes = $dao->getAttributesProduct($product['id_product'], GlobalConfig::getDefaultLangId()); $features = $dao->getCategoriesProduct($product['id_product'], GlobalConfig::getDefaultLangId()); $featuresMap = generateFeaturesMap($features); /* * Do not send price for update * Firstly, save creation informations if needed */ $createPrice = $product['price']; $createRate = $product['rate']; $createQuantity = $product['quantity']; /* Secondly, do not send price, rate for update */ $product['price'] = null; $product['rate'] = null; /* Determine if this main product as child (attributes) */ $product['has_child'] = $attributes != null && is_array($attributes) ? true : false; /* Only if the reference is not empty */ if ($product['reference'] != "") { /* Set product (original product without attributes) */ $xmlProduct = XML::createProductXml($product, true, "", $featuresMap, ""); Log::write("Send request for updating reference = " . $product['reference'] . " - ", "info"); $response = $postOSIReq->wso_p006($xmlProduct, $product['reference']); if ($response->getCode() == 200) { $nbResponse200++; } else { if ($response->getCode() == 404) { /* * Create product */ if (Configuration::get('OSI_ACTIVE_WSO-P005') == 1) { Log::write("Update not possible, the product was not found => Send request for creation of the product " . $product['reference'] . " (Id " . $product['id_product'] . ") - ", "info"); $product['price'] = $createPrice; $product['rate'] = $createRate; $product['quantity'] = $createQuantity; createMainProduct($product, false, false); } else { Log::write("Update not possible, the product was not found => No creation made (webservice disabled) - ", "info"); } } else { if ($response->getCode() == 409) { $nbResponse409++; } else { $nbResponseError++; } } } $xmlPublicationProduct = XML::createPublicationProductXml($product); $response = $postOSIReq->wso_p034($xmlPublicationProduct, $product['reference']); //set state (activated/not activated) if (!isOkPostResult($response->getCode())) { $isOkResponses = false; } } else { Log::write("No reference found for product ID " . $product['id_product'], "error"); $nbNoReference++; } // Set the prices, TVA if needed $product['price'] = $createPrice; $product['rate'] = $createRate; $product['quantity'] = $createQuantity; /* Update child product */ updateChildProduct($product, $attributes, $featuresMap); }