Beispiel #1
0
 public function update(array $data, $isAtomic = true)
 {
     parent::update($data, $isAtomic);
     // Set the groups.
     if (!empty($data['groups'])) {
         $this->groups = array();
         foreach ($data['groups'] as $key => $group) {
             if (!$group instanceof ProductGroup) {
                 $productGroup = ProductGroups::getInstance()->getEntity($group['id']);
                 if (!$productGroup) {
                     $productGroup = new ProductGroup(array('id' => $group['id'], 'name' => $group['name']));
                 }
                 $group = $productGroup;
             }
             // Keep the new entity.
             $this->groups[$group->id] = $group;
         }
     }
     // Invalidate calculated fields.
     $this->pricePerKg = null;
 }
Beispiel #2
0
 public function getFieldsData()
 {
     $fieldsData = parent::getFieldsData();
     // Add the last status ID in its own field, for convenience.
     $lastStatus = end($fieldsData['statusHistory']);
     $fieldsData['status'] = $lastStatus['id'];
     return $fieldsData;
 }
Beispiel #3
0
 public function store()
 {
     parent::store();
     // Set the new location.
     $this->location = $this->getDataSource()->getAssetLocation($this->id);
     // Once stored, the image is no longer temporary.
     $this->isLocationTemporary = FALSE;
 }