/** * @param Supplier $supplier * @return void */ public function saveSupplier($supplier) { $this->getDb()->query("\n\t\t UPDATE supplier\n\t\t SET\n supplier_group_id = ?,\n\t\t name = ?,\n internal_model = ?,\n shipping_cost = ?,\n free_shipping_threshold = ?\n WHERE supplier_id = ?\n ", array('i:' . $supplier->getGroupId(), 's:' . $supplier->getName(), 's:' . $supplier->getInternalModel(), 'd:' . $supplier->getShippingCost(), 'd:' . $supplier->getFreeShippingThreshold(), 'i:' . $supplier->getId())); if (is_null($supplier->getRelatedManufacturer())) { $this->getDb()->query("\n DELETE FROM supplier_to_manufacturer\n WHERE supplier_id = ?\n ", array('i:' . $supplier->getId())); } else { $this->getDb()->query("\n INSERT INTO supplier_to_manufacturer\n SET\n supplier_id = ?,\n manufacturer_id = ?\n ON DUPLICATE KEY UPDATE\n manufacturer_id = ?\n ", array("i:" . $supplier->getId(), 'i:' . $supplier->getRelatedManufacturer()->getId(), 'i:' . $supplier->getRelatedManufacturer()->getId())); } $this->getCache()->deleteAll('/^suppliers\\./'); }
/** * @param Supplier $supplier * @throws Exception */ private function getForm($supplier) { $this->data['text_amount'] = $this->language->get('text_amount'); $this->data['text_enabled'] = $this->language->get('text_enabled'); $this->data['text_disabled'] = $this->language->get('text_disabled'); $this->data['text_default'] = $this->language->get('text_default'); $this->data['text_image_manager'] = $this->language->get('text_image_manager'); $this->data['text_browse'] = $this->language->get('text_browse'); $this->data['text_clear'] = $this->language->get('text_clear'); $this->data['text_none'] = $this->language->get('text_none'); $this->data['text_percent'] = $this->language->get('text_percent'); $this->data['textFreeShippingThreshold'] = $this->language->get('FREE_SHIPPING_THRESHOLD'); $this->data['textRelatedManufacturer'] = $this->language->get('MANUFACTURER'); $this->data['textShippingCost'] = $this->language->get('textShippingCost'); $this->data['entry_name'] = $this->language->get('field_name') . ':'; $this->data['entry_supplier_group'] = $this->language->get('field_supplier_group') . ':'; $this->data['entry_internal_model'] = $this->language->get('field_internal_model') . ':'; $this->data['button_save'] = $this->language->get('button_save'); $this->data['button_cancel'] = $this->language->get('button_cancel'); $this->data['tab_general'] = $this->language->get('tab_general'); if (isset($this->error['warning'])) { $this->data['error_warning'] = $this->error['warning']; } else { $this->data['error_warning'] = ''; } foreach ($this->error as $key => $value) { $this->data["error_{$key}"] = $value; } $url = ''; if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } $this->data['breadcrumbs'] = array(); $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => false); $this->data['breadcrumbs'][] = array('text' => $this->language->get('heading_title'), 'href' => $this->url->link('catalog/supplier', 'token=' . $this->session->data['token'] . $url, 'SSL'), 'separator' => ' :: '); if (!$supplier->getId()) { $this->data['action'] = $this->url->link('catalog/supplier/insert', 'token=' . $this->session->data['token'] . $url, 'SSL'); } else { $this->data['action'] = $this->url->link('catalog/supplier/update', 'token=' . $this->session->data['token'] . '&supplierId=' . $supplier->getId() . $url, 'SSL'); } $this->data['cancel'] = $this->url->link('catalog/supplier', 'token=' . $this->session->data['token'] . $url, 'SSL'); $this->data['token'] = $this->session->data['token']; // if (isset($this->request->get['supplierId']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) { // $supplier = SupplierDAO::getInstance()->getSupplier($this->request->get['supplierId']); // } else { // $supplier = null; // } $this->load->model('localisation/language'); $this->data['languages'] = $this->model_localisation_language->getLanguages(); $this->data['supplier_groups'] = SupplierGroupDAO::getInstance()->getSupplierGroups(); $this->data['manufacturers'] = ManufacturerDAO::getInstance()->getManufacturers(); $this->data = array_merge($this->data, $this->parameters); $this->data['freeShippingThreshold'] = $supplier->getFreeShippingThreshold(); $this->data['internalModel'] = $supplier->getInternalModel(); $this->data['name'] = $supplier->getName(); $this->data['relatedManufacturerId'] = $supplier->getRelatedManufacturer()->getId(); $this->data['supplierGroupId'] = $supplier->getGroupId(); $this->data['shippingCost'] = $supplier->getShippingCost(); $this->template = 'catalog/supplierForm.tpl.php'; $this->children = array('common/header', 'common/footer'); $this->getResponse()->setOutput($this->render()); }