當前位置: 首頁>>代碼示例>>PHP>>正文


PHP eZProductCollectionItem::create方法代碼示例

本文整理匯總了PHP中eZProductCollectionItem::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP eZProductCollectionItem::create方法的具體用法?PHP eZProductCollectionItem::create怎麽用?PHP eZProductCollectionItem::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在eZProductCollectionItem的用法示例。


在下文中一共展示了eZProductCollectionItem::create方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: addToBasket


//.........這裏部分代碼省略.........
         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();
         } else {
             $item = eZProductCollectionItem::create($basket->attribute("productcollection_id"));
             $item->setAttribute('name', $object->attribute('name'));
             $item->setAttribute("contentobject_id", $objectID);
             $item->setAttribute("item_count", $quantity);
             $item->setAttribute("price", $price);
             if ($priceObj->attribute('is_vat_included')) {
                 $item->setAttribute("is_vat_inc", '1');
             } else {
                 $item->setAttribute("is_vat_inc", '0');
             }
             $item->setAttribute("vat_value", $priceObj->attribute('vat_percent'));
             $item->setAttribute("discount", $priceObj->attribute('discount_percent'));
             $item->store();
             $priceWithoutOptions = $price;
             $optionIDList = array();
             foreach (array_keys($optionList) as $key) {
                 $attributeID = $key;
                 $optionString = $optionList[$key];
                 if (is_array($optionString)) {
                     foreach ($optionString as $optionID) {
                         $optionIDList[] = array('attribute_id' => $attributeID, 'option_string' => $optionID);
                     }
                 } else {
                     $optionIDList[] = array('attribute_id' => $attributeID, 'option_string' => $optionString);
                 }
             }
             $db = eZDB::instance();
             $db->begin();
             foreach ($optionIDList as $optionIDItem) {
                 $attributeID = $optionIDItem['attribute_id'];
                 $optionString = $optionIDItem['option_string'];
                 $attribute = eZContentObjectAttribute::fetch($attributeID, $object->attribute('current_version'));
                 $dataType = $attribute->dataType();
                 $optionData = $dataType->productOptionInformation($attribute, $optionString, $item);
                 if ($optionData) {
                     $optionData['additional_price'] = eZShopFunctions::convertAdditionalPrice($currency, $optionData['additional_price']);
                     $optionItem = eZProductCollectionItemOption::create($item->attribute('id'), $optionData['id'], $optionData['name'], $optionData['value'], $optionData['additional_price'], $attributeID);
                     $optionItem->store();
                     $price += $optionData['additional_price'];
                 }
             }
             if ($price != $priceWithoutOptions) {
                 $item->setAttribute("price", $price);
                 $item->store();
             }
             $db->commit();
         }
     }
     return array('status' => eZModuleOperationInfo::STATUS_CONTINUE);
 }
開發者ID:runelangseid,項目名稱:ezpublish,代碼行數:101,代碼來源:ezshopoperationcollection.php


注:本文中的eZProductCollectionItem::create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。