/** * @param $userSID * @param $productSID * @param $limitCheckoutedListingsToDelete */ public function deleteCheckoutedListingsByProduct($userSID, $productSID, $limitCheckoutedListingsToDelete) { $serializedProductSID = SJB_ProductsManager::generateQueryBySID($productSID); $listingsToDelete = SJB_DB::query("SELECT `sid` FROM `listings` WHERE `checkouted` = 0 AND `complete` = 1 AND `contract_id` = 0 AND `user_sid` = ?n AND `product_info` REGEXP '({$serializedProductSID})' ORDER BY `sid` DESC LIMIT ?n", $userSID, $limitCheckoutedListingsToDelete); $criteriaSaver = new SJB_ListingCriteriaSaver('MyListings'); $foundListingsSIDs = $criteriaSaver->getObjectSIDs(); foreach ($listingsToDelete as $listing) { SJB_ListingManager::deleteListingBySID($listing['sid']); if ($foundListingsSIDs != null) { $key = array_search($listing['sid'], $foundListingsSIDs); unset($foundListingsSIDs[$key]); } } if ($foundListingsSIDs != null) { $criteriaSaver->setSessionForObjectSIDs($foundListingsSIDs); } }