/**
  * Exclude object from result
  *
  * @param   SellListing $sellListing Object to remove from the list of results
  *
  * @return SellListingQuery The current query, for fluid interface
  */
 public function prune($sellListing = null)
 {
     if ($sellListing) {
         $this->addUsingAlias(SellListingPeer::ID, $sellListing->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Exemple #2
0
 /**
  * @param	SellListing $sellListing The sellListing object to add.
  */
 protected function doAddSellListing($sellListing)
 {
     $this->collSellListings[] = $sellListing;
     $sellListing->setItem($this);
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      SellListing $obj A SellListing object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         SellListingPeer::$instances[$key] = $obj;
     }
 }
Exemple #4
0
 /**
  * Filter the query by a related SellListing object
  *
  * @param   SellListing|PropelObjectCollection $sellListing  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return   ItemQuery The current query, for fluid interface
  * @throws   PropelException - if the provided filter is invalid.
  */
 public function filterBySellListing($sellListing, $comparison = null)
 {
     if ($sellListing instanceof SellListing) {
         return $this->addUsingAlias(ItemPeer::DATA_ID, $sellListing->getItemId(), $comparison);
     } elseif ($sellListing instanceof PropelObjectCollection) {
         return $this->useSellListingQuery()->filterByPrimaryKeys($sellListing->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterBySellListing() only accepts arguments of type SellListing or PropelCollection');
     }
 }
 protected function updateListings($listings)
 {
     $now = new DateTime();
     $item = ItemQuery::create()->findOneByDataId($listings['id']);
     $item->setLastUpdated($now);
     $sell = $listings['sells'];
     $buy = $listings['buys'];
     $lowestSell = null;
     $maxBuy = null;
     $sellQuantityAmount = 0;
     $sellListingsAmount = 0;
     if (count($sell)) {
         $lowestSell = min(array_map(function ($row) {
             return $row['unit_price'];
         }, $sell));
         foreach ($sell as $s) {
             $sellQuantityAmount += $s['quantity'];
             $sellListingsAmount += $s['listings'];
         }
     }
     $sellListing = new SellListing();
     $sellListing->setItem($item);
     $sellListing->setListingDatetime($now);
     $sellListing->setQuantity($sellQuantityAmount);
     $sellListing->setListings($sellListingsAmount);
     if ($lowestSell) {
         $sellListing->setUnitPrice($lowestSell);
         $item->setMinSaleUnitPrice($lowestSell);
     } else {
         $sellListing->setUnitPrice($item->getMinSaleUnitPrice());
     }
     $item->setSaleAvailability($sellQuantityAmount);
     $sellListing->save();
     $buyQuantityAmount = 0;
     $buyListingsAmount = 0;
     if (count($buy)) {
         $maxBuy = max(array_map(function ($row) {
             return $row['unit_price'];
         }, $buy));
         foreach ($buy as $b) {
             $buyQuantityAmount += $b['quantity'];
             $buyListingsAmount += $b['listings'];
         }
     }
     $buyListing = new BuyListing();
     $buyListing->setItem($item);
     $buyListing->setListingDatetime($now);
     $buyListing->setQuantity($buyQuantityAmount);
     $buyListing->setListings($buyListingsAmount);
     if ($maxBuy) {
         $buyListing->setUnitPrice($maxBuy);
         $item->setMaxOfferUnitPrice($maxBuy);
     } else {
         $buyListing->setUnitPrice($item->getMaxOfferUnitPrice());
     }
     $item->setOfferAvailability($buyQuantityAmount);
     $buyListing->save();
     $item->save();
 }