/** * Getting the price object via product or type * * @param Product $product * @param ProductPriceType $type * @param string $startS * @param string $startE * @param string $endS * @param string $endE * @param int $pageNo * @param int $pageSize * @param array $orderBy * @throws EntityException * @return Ambigous <multitype:, multitype:BaseEntityAbstract > */ public static function getPrices(Product $product = null, ProductPriceType $type = null, $startS = '', $startE = '', $endS = '', $endE = '', $pageNo = null, $pageSize = DaoQuery::DEFAUTL_PAGE_SIZE, $orderBy = array(), &$stats = array()) { $class = __CLASS__; if (!$product instanceof Product && !$type instanceof ProductPriceType) { throw new EntityException('At least one of them is required for getting the prices: Product or PriceType'); } $where = array('active = 1'); $params = array(); if ($product instanceof Product) { $where[] = 'productId = ?'; $params[] = $product->getId(); } if ($type instanceof ProductPriceType) { $where[] = 'typeId = ?'; $params[] = $type->getId(); } if (($startS = trim($startS)) !== '') { $where[] = 'start >= ?'; $params[] = $startS; } if (($startE = trim($startE)) !== '') { $where[] = 'start <= ?'; $params[] = $startE; } if (($endS = trim($endS)) !== '') { $where[] = 'end >= ?'; $params[] = $endS; } if (($endE = trim($endE)) !== '') { $where[] = 'end <= ?'; $params[] = $endE; } return self::getAllByCriteria(implode(' AND ', $where), $params, true, $pageNo, $pageSize, $orderBy, $stats); }
/** * removing the price * * @param ProductPriceType $type * * @return Product */ public function removePrice(ProductPriceType $type) { ProductPrice::updateByCriteria('active = 0', 'productId = ? and typeId = ?', array($this->getId(), $type->getId())); return $this; }