Example #1
0
 /**
  * Save all offer dynamic properties values to database.
  * @param Offer $offer
  * @param bool $isNew
  */
 protected static function SaveProperties(Offer $offer, $isNew)
 {
     $lst = array();
     if (!$isNew) {
         $query = "SELECT id, properties_id, value FROM #S#offers_properties WHERE offers_id=? AND offers_id_lng=?";
         $result = DataBase::GetDbInstance()->ExecuteQueryWithParams($query, array((int) $offer->GetId(), (int) $offer->GetIdLng()));
         while ($row = DataBase::GetDbInstance()->FetchArray($result)) {
             $lst[$row['properties_id']][] = array("id" => $row['id'], "value" => $row['value']);
         }
     }
     foreach ($offer->data as $key => $value) {
         $prop = Properties::GetWithAddProperty($key);
         Properties::SavePropertyValue($prop, $offer, $value, $isNew, $lst);
     }
 }