Ejemplo n.º 1
0
 /**
  * @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\\./');
 }
Ejemplo n.º 2
0
 /**
  * @param Supplier $supplier
  * @return bool
  */
 private function validateSupplierData($supplier)
 {
     if (!$this->user->hasPermission('modify', 'catalog/supplier')) {
         $this->error['warning'] = $this->language->get('error_permission');
     }
     if (!is_numeric($supplier->getFreeShippingThreshold())) {
         $this->error['freeShippingThreshold'] = $this->language->get('error_freeShippingThreshold');
     }
     if (utf8_strlen($supplier->getInternalModel()) > 45) {
         $this->error['internalModel'] = $this->language->get('error_internalModel');
     }
     if (utf8_strlen($supplier->getName()) < 3 || utf8_strlen($supplier->getName()) > 128) {
         $this->error['name'] = $this->language->get('error_name');
     }
     if (!is_numeric($supplier->getShippingCost())) {
         $this->error['shippingCost'] = $this->language->get('error_shippingCost');
     }
     return empty($this->error);
 }