本文整理汇总了PHP中eZProductCollectionItem类的典型用法代码示例。如果您正苦于以下问题:PHP eZProductCollectionItem类的具体用法?PHP eZProductCollectionItem怎么用?PHP eZProductCollectionItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZProductCollectionItem类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
}
开发者ID:runelangseid,项目名称:ezpublish,代码行数:36,代码来源:ezproductcollectionitem_test.php
示例2: fetchList
static function fetchList($conditions = null, $asObjects = true, $offset = false, $limit = false)
{
$limitation = null;
if ($offset !== false or $limit !== false) {
$limitation = array('offset' => $offset, 'length' => $limit);
}
return eZPersistentObject::fetchObjectList(eZProductCollectionItem::definition(), null, $conditions, null, $limitation, $asObjects);
}
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:8,代码来源:ezproductcollectionitem.php
示例3: type
function type()
{
$type = false;
// get first product
$productCollectionItemList = eZProductCollectionItem::fetchList(array('productcollection_id' => $this->attribute('productcollection_id')), true, 0, 1);
if (is_array($productCollectionItemList) && count($productCollectionItemList) === 1) {
$product = $productCollectionItemList[0]->attribute('contentobject');
if (is_object($product)) {
$type = eZShopFunctions::productTypeByObject($product);
}
}
return $type;
}
开发者ID:rmiguel,项目名称:ezpublish,代码行数:13,代码来源:ezbasket.php
示例4: 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();
}
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:21,代码来源:ezproductcollection.php
示例5: 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");
}
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:63,代码来源:ezdbgarbagecollector.php
示例6: removeItem
static function removeItem($itemID)
{
$item = eZProductCollectionItem::fetch($itemID);
$item->remove();
}
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:5,代码来源:ezorder.php
示例7: purge
/**
* Deletes the current object, all versions and translations, and corresponding tree nodes from the database
*
* Transaction unsafe. If you call several transaction unsafe methods you must enclose
* the calls within a db transaction; thus within db->begin and db->commit.
*/
function purge()
{
$delID = $this->ID;
// Who deletes which content should be logged.
eZAudit::writeAudit( 'content-delete', array( 'Object ID' => $delID, 'Content Name' => $this->attribute( 'name' ),
'Comment' => 'Purged the current object: eZContentObject::purge()' ) );
$db = eZDB::instance();
$db->begin();
$attrOffset = 0;
$attrLimit = 20;
while (
$contentobjectAttributes = $this->allContentObjectAttributes(
$delID, true, array( 'limit' => $attrLimit, 'offset' => $attrOffset )
)
)
{
foreach ( $contentobjectAttributes as $contentobjectAttribute )
{
$dataType = $contentobjectAttribute->dataType();
if ( !$dataType )
continue;
$dataType->deleteStoredObjectAttribute( $contentobjectAttribute );
}
$attrOffset += $attrLimit;
}
eZInformationCollection::removeContentObject( $delID );
eZContentObjectTrashNode::purgeForObject( $delID );
$db->query( "DELETE FROM ezcontentobject_tree
WHERE contentobject_id='$delID'" );
$db->query( "DELETE FROM ezcontentobject_attribute
WHERE contentobject_id='$delID'" );
$db->query( "DELETE FROM ezcontentobject_version
WHERE contentobject_id='$delID'" );
$db->query( "DELETE FROM ezcontentobject_name
WHERE contentobject_id='$delID'" );
$db->query( "DELETE FROM ezcobj_state_link WHERE contentobject_id=$delID" );
$db->query( "DELETE FROM ezcontentobject
WHERE id='$delID'" );
$db->query( "DELETE FROM eznode_assignment
WHERE contentobject_id = '$delID'" );
$db->query( "DELETE FROM ezuser_role
WHERE contentobject_id = '$delID'" );
$db->query( "DELETE FROM ezuser_discountrule
WHERE contentobject_id = '$delID'" );
eZContentObject::fixReverseRelations( $delID, 'remove' );
eZSearch::removeObjectById( $delID );
// Check if deleted object is in basket/wishlist
$sql = 'SELECT DISTINCT ezproductcollection_item.productcollection_id
FROM ezbasket, ezwishlist, ezproductcollection_item
WHERE ( ezproductcollection_item.productcollection_id=ezbasket.productcollection_id OR
ezproductcollection_item.productcollection_id=ezwishlist.productcollection_id ) AND
ezproductcollection_item.contentobject_id=' . $delID;
$rows = $db->arrayQuery( $sql );
if ( count( $rows ) > 0 )
{
$countElements = 50;
$deletedArray = array();
// Create array of productCollectionID will be removed from ezwishlist and ezproductcollection_item
foreach ( $rows as $row )
{
$deletedArray[] = $row['productcollection_id'];
}
// Split $deletedArray into several arrays with $countElements values
$splitted = array_chunk( $deletedArray, $countElements );
// Remove eZProductCollectionItem and eZWishList
foreach ( $splitted as $value )
{
eZPersistentObject::removeObject( eZProductCollectionItem::definition(), array( 'productcollection_id' => array( $value, '' ) ) );
eZPersistentObject::removeObject( eZWishList::definition(), array( 'productcollection_id' => array( $value, '' ) ) );
}
}
$db->query( 'UPDATE ezproductcollection_item
SET contentobject_id = 0
WHERE contentobject_id = ' . $delID );
// Cleanup relations in two steps to avoid locking table for to long
$db->query( "DELETE FROM ezcontentobject_link
//.........这里部分代码省略.........
开发者ID:ezsystemstraining,项目名称:ez54training,代码行数:101,代码来源:ezcontentobject.php
示例8: foreach
foreach ($options as $option) {
/* If any option differs, go away: */
if (is_array($optionList[$option['object_attribute_id']]) && !in_array($option['option_item_id'], $optionList[$option['object_attribute_id']]) || !is_array($optionList[$option['object_attribute_id']]) && $option['option_item_id'] != $optionList[$option['object_attribute_id']]) {
$theSame = false;
break;
}
}
if ($theSame) {
$itemID = $item['id'];
break;
}
}
}
}
if ($itemID == false) {
$item = eZProductCollectionItem::create($wishList->attribute("productcollection_id"));
$item->setAttribute('name', $object->attribute('name'));
$item->setAttribute("contentobject_id", $objectID);
$item->setAttribute("item_count", 1);
//$item->setAttribute( "price", $price );
$db = eZDB::instance();
$db->begin();
$item->store();
//if ( $priceObj->attribute( 'is_vat_included' ) )
//{
// $item->setAttribute( "is_vat_inc", '1' );
//}
//else
//{
// $item->setAttribute( "is_vat_inc", '0' );
//}
开发者ID:legende91,项目名称:ez,代码行数:31,代码来源:wishlist.php
示例9: addToBasket
function addToBasket($objectID, $optionList, $quantity)
{
$object = eZContentObject::fetch($objectID);
$nodeID = $object->attribute('main_node_id');
$price = 0.0;
$isVATIncluded = true;
$attributes = $object->contentObjectAttributes();
$priceFound = false;
foreach ($attributes as $attribute) {
$dataType = $attribute->dataType();
if (eZShopFunctions::isProductDatatype($dataType->isA())) {
$priceObj = $attribute->content();
$price += $priceObj->attribute('price');
$priceFound = true;
}
}
if (!$priceFound) {
eZDebug::writeError('Attempted to add object without price to basket.');
return array('status' => eZModuleOperationInfo::STATUS_CANCELLED);
}
$currency = $priceObj->attribute('currency');
// Check for 'option sets' in option list.
// If found each 'option set' will be added as a separate product purchase.
$hasOptionSet = false;
foreach (array_keys($optionList) as $optionKey) {
if (substr($optionKey, 0, 4) == 'set_') {
$returnStatus = eZShopOperationCollection::addToBasket($objectID, $optionList[$optionKey]);
// If adding one 'option set' fails we should stop immediately
if ($returnStatus['status'] == eZModuleOperationInfo::STATUS_CANCELLED) {
return $returnStatus;
}
$hasOptionSet = true;
}
}
if ($hasOptionSet) {
return $returnStatus;
}
$unvalidatedAttributes = array();
foreach ($attributes as $attribute) {
$dataType = $attribute->dataType();
if ($dataType->isAddToBasketValidationRequired()) {
$errors = array();
if ($attribute->validateAddToBasket($optionList[$attribute->attribute('id')], $errors) !== eZInputValidator::STATE_ACCEPTED) {
$description = $errors;
$contentClassAttribute = $attribute->contentClassAttribute();
$attributeName = $contentClassAttribute->attribute('name');
$unvalidatedAttributes[] = array("name" => $attributeName, "description" => $description);
}
}
}
if (count($unvalidatedAttributes) > 0) {
return array('status' => eZModuleOperationInfo::STATUS_CANCELLED, 'reason' => 'validation', 'error_data' => $unvalidatedAttributes);
}
$basket = eZBasket::currentBasket();
/* Check if the item with the same options is not already in the basket: */
$itemID = false;
$collection = $basket->attribute('productcollection');
if (!$collection) {
eZDebug::writeError('Unable to find product collection.');
return array('status' => eZModuleOperationInfo::STATUS_CANCELLED);
} else {
$collection->setAttribute('currency_code', $currency);
$collection->store();
$count = 0;
/* Calculate number of options passed via the HTTP variable: */
foreach (array_keys($optionList) as $key) {
if (is_array($optionList[$key])) {
$count += count($optionList[$key]);
} else {
$count++;
}
}
$collectionItems = $collection->itemList(false);
foreach ($collectionItems as $item) {
/* For all items in the basket which have the same object_id: */
if ($item['contentobject_id'] == $objectID) {
$options = eZProductCollectionItemOption::fetchList($item['id'], false);
/* If the number of option for this item is not the same as in the HTTP variable: */
if (count($options) != $count) {
break;
}
$theSame = true;
foreach ($options as $option) {
/* If any option differs, go away: */
if (is_array($optionList[$option['object_attribute_id']]) && !in_array($option['option_item_id'], $optionList[$option['object_attribute_id']]) || !is_array($optionList[$option['object_attribute_id']]) && $option['option_item_id'] != $optionList[$option['object_attribute_id']]) {
$theSame = false;
break;
}
}
if ($theSame) {
$itemID = $item['id'];
break;
}
}
}
if ($itemID) {
/* If found in the basket, just increment number of that items: */
$item = eZProductCollectionItem::fetch($itemID);
$item->setAttribute('item_count', $quantity + $item->attribute('item_count'));
$item->store();
//.........这里部分代码省略.........
开发者ID:runelangseid,项目名称:ezpublish,代码行数:101,代码来源:ezshopoperationcollection.php
示例10:
if ($counteditems == 0) {
$zeroproduct = true;
return $module->redirectTo($module->functionURI("basket"));
}
$itemIDList = $http->postVariable("ProductItemIDList");
if (is_array($itemCountList) && is_array($itemIDList) && count($itemCountList) == count($itemIDList) && is_object($basket)) {
$productCollectionID = $basket->attribute('productcollection_id');
$db = eZDB::instance();
$db->begin();
for ($i = 0, $itemCountError = false; $i < count($itemIDList); ++$i) {
// If item count of product <= 0 we should show the error
if (!is_numeric($itemCountList[$i]) or $itemCountList[$i] <= 0) {
$itemCountError = true;
continue;
}
$item = eZProductCollectionItem::fetch($itemIDList[$i]);
if (is_object($item) && $item->attribute('productcollection_id') == $productCollectionID) {
$item->setAttribute("item_count", $itemCountList[$i]);
$item->store();
}
}
$db->commit();
if ($itemCountError) {
// Redirect to basket
$module->redirectTo($module->functionURI("basket") . "/(error)/invaliditemcount");
return;
}
}
}
// Fetch the shop account handler
$accountHandler = eZShopAccountHandler::instance();
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:31,代码来源:basket.php
注:本文中的eZProductCollectionItem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论