当前位置: 首页>>代码示例>>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;未经允许,请勿转载。