private function _setSupplierCodes(Product &$product, $param)
 {
     if (isset($param->CallbackParameter->supplierCodes) && count($supplierCodes = $param->CallbackParameter->supplierCodes) > 0) {
         foreach ($supplierCodes as $code) {
             if (!($supplier = Supplier::get(trim($code->typeId))) instanceof Supplier) {
                 continue;
             }
             if (!isset($code->id) || ($id = trim($code->id)) === '') {
                 if (trim($code->active) === '1') {
                     SupplierCode::create($product, $supplier, trim($code->value));
                 }
                 //if it's deactivated one, ignore
             } else {
                 if (($supplierCode = SupplierCode::get($id)) instanceof SupplierCode) {
                     $supplierCode->setActive(trim($code->active) === '1')->setCode(trim($code->value))->setSupplier($supplier)->setProduct($product)->save();
                 }
             }
         }
     }
     return $this;
 }
Exemple #2
0
 /**
  * Adding a supplier
  *
  * @param Supplier $supplier
  * @param string   $supplierCode
  *
  * @return Product
  */
 public function addSupplier(Supplier $supplier, $supplierCode = 'NA', $canSupplyQty = 0)
 {
     SupplierCode::create($this, $supplier, $supplierCode, $canSupplyQty);
     return $this;
 }