本文整理汇总了PHP中eZProductCollectionItem::cleanupList方法的典型用法代码示例。如果您正苦于以下问题:PHP eZProductCollectionItem::cleanupList方法的具体用法?PHP eZProductCollectionItem::cleanupList怎么用?PHP eZProductCollectionItem::cleanupList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZProductCollectionItem
的用法示例。
在下文中一共展示了eZProductCollectionItem::cleanupList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCleanupList
/**
* Unit test for eZProductCollectionItem::cleanupList()
*
* Outline:
* 1) Create 40 eZProductCollectionItem objects with a product_collection_id
* from 1 to 4
* 2) Call cleanupList with (1, 2) as a parameter
* 4) Check that the 20 matching items have been removed
* 5) Check that the 20 other, non-matching items haven't been removed
**/
public function testCleanupList()
{
// Create a few collections
$row = array('product_collection_id' => 0, 'contentobject_id' => 1, 'item_count' => 1, 'price' => 50, 'is_vat_inc' => 1, 'vat_value' => 19.6, 'discount' => 0, 'name' => __FUNCTION__);
$deleteIDArray = $keepIDArray = array();
for ($i = 1; $i < 40; $i++) {
$row['productcollection_id'] = ceil($i / 10);
$row['name'] = __FUNCTION__ . ":" . $row['productcollection_id'] . "-{$i}";
$item = new eZProductCollectionItem($row);
$item->store();
if ($row['productcollection_id'] <= 2) {
$deleteIDArray[] = $item->attribute('id');
} else {
$keepIDArray[] = $item->attribute('id');
}
}
eZProductCollectionItem::cleanupList(array(1, 2));
// Check that each item of deleteIDArray has been removed
foreach ($deleteIDArray as $id) {
$this->assertNull(eZProductCollectionItem::fetch($id));
}
// And check that each item of remainingIDArray hasn't been deleted
foreach ($keepIDArray as $id) {
$this->assertType('eZProductCollectionItem', eZProductCollectionItem::fetch($id));
}
}
示例2: cleanupList
/**
* Removes all product collections based on a product collection ID list
* Will also remove the product collection items.
*
* @param array $productCollectionIDList array of eZProductCollection IDs
*
* @return void
*/
static function cleanupList($productCollectionIDList)
{
$db = eZDB::instance();
$db->begin();
// Purge shipping information associated with product collections being removed.
foreach ($productCollectionIDList as $productCollectionID) {
eZShippingManager::purgeShippingInfo($productCollectionID);
}
eZProductCollectionItem::cleanupList($productCollectionIDList);
$where = $db->generateSQLINStatement($productCollectionIDList, 'id', false, false, 'int');
$db->query("DELETE FROM ezproductcollection WHERE {$where}");
$db->commit();
}
示例3: collectProductCollections
function collectProductCollections($maxTime = false, $sleepTime = false, $limit = false)
{
$db = eZDB::instance();
// Create a temporary table for filling in collection ids
// that are in use
if ($db->databaseName() == 'mysql') {
$db->query("DROP TABLE IF EXISTS ezproductcollection_used");
}
$db->query("CREATE TABLE ezproductcollection_used ( id int )");
// Fill in collections used by orders
$db->query("INSERT INTO ezproductcollection_used (id) SELECT productcollection_id FROM ezorder");
// Fill in collections used by wish lists
$db->query("INSERT INTO ezproductcollection_used (id) SELECT productcollection_id FROM ezwishlist");
// Fill in collections used by baskets
$db->query("INSERT INTO ezproductcollection_used (id) SELECT productcollection_id FROM ezbasket");
// Create the index for faster selects
$db->query("CREATE INDEX ezproductcollection_used_id on ezproductcollection_used( id )");
if ($maxTime === false and $db->hasRequiredServerVersion('4.0', 'mysql')) {
// Delete entries which are not in ezproductcollection_used
$db->query("DELETE FROM ezproductcollection, ezproductcollection_item, ezproductcollection_item_opt\nUSING ezproductcollection_used\n RIGHT JOIN ezproductcollection\n ON ezproductcollection_used.id = ezproductcollection.id\n LEFT JOIN ezproductcollection_item\n ON ezproductcollection.id = ezproductcollection_item.productcollection_id\n LEFT JOIN ezproductcollection_item_opt\n ON ezproductcollection_item.id = ezproductcollection_item_opt.item_id\nWHERE ezproductcollection_used.id IS NULL");
$db->query($sql);
// Remove the temporary table
$db->query("DROP TABLE ezproductcollection_used");
return;
}
// Find all product collections which are not in use
if ($db->hasRequiredServerVersion('8', 'oracle')) {
$sql = "SELECT ezproductcollection.id\nFROM ezproductcollection_used, ezproductcollection\nWHERE ezproductcollection_used.id = ezproductcollection.id (+) AND\n ezproductcollection_used.id IS NULL";
} else {
$sql = "SELECT ezproductcollection.id\nFROM ezproductcollection_used\n RIGHT JOIN ezproductcollection\n ON ezproductcollection_used.id = ezproductcollection.id\nWHERE ezproductcollection_used.id IS NULL";
}
if ($limit === false) {
$limit = eZDBGarbageCollector::ITEM_LIMIT;
}
$end = false;
if (is_numeric($maxTime)) {
$end = time() + $maxTime;
}
do {
$rows = $db->arrayQuery($sql, array('offset' => 0, 'limit' => $limit));
if (count($rows) == 0) {
break;
}
$idList = array();
foreach ($rows as $row) {
$idList[] = (int) $row['id'];
}
eZProductCollectionItem::cleanupList($idList);
$ids = implode(', ', $idList);
$db->query("DELETE FROM ezproductcollection WHERE id IN ( {$ids} )");
$db->query("DELETE FROM ezproductcollection_used WHERE id IN ( {$ids} )");
// Stop when we used up our time
if ($end !== false and time() > $end) {
break;
}
// Sleep a little if required, reduces load on server
if ($sleepTime !== false) {
sleep($sleepTime);
}
} while (true);
// Remove the temporary table
$db->query("DROP TABLE ezproductcollection_used");
}