Example #1
0
 protected function savePrices(EntityInterface $entity)
 {
     if ($entity->getPrice() <= 0 || !$entity->getPriceDate()) {
         return;
     }
     $rel = new Table\BrandsPricesRel();
     $row = $rel->fetchRow(array('brandId = ?' => $entity->getId(), 'price = ?' => $entity->getPrice(), 'date = ?' => $entity->getPriceDate()));
     try {
         if ($row === \null) {
             $row = $rel->createRow(array('brandId' => $entity->getId(), 'price' => $entity->getPrice(), 'date' => $entity->getPriceDate()));
         }
         $row->comment = $entity->getPriceComment();
         $row->save();
     } catch (\Exception $e) {
     }
 }
Example #2
0
 public function getPriceHistory()
 {
     if ($this->priceHistory === null) {
         $rel = new BrandsPricesRel();
         $this->priceHistory = $rel->getAdapter()->fetchAll($rel->select(true)->setIntegrityCheck(false)->where('brandId = ?', $this->getId())->order('date DESC'));
     }
     return $this->priceHistory;
 }