当前位置: 首页>>代码示例>>PHP>>正文


PHP eZProductCollectionItem::fetchList方法代码示例

本文整理汇总了PHP中eZProductCollectionItem::fetchList方法的典型用法代码示例。如果您正苦于以下问题:PHP eZProductCollectionItem::fetchList方法的具体用法?PHP eZProductCollectionItem::fetchList怎么用?PHP eZProductCollectionItem::fetchList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZProductCollectionItem的用法示例。


在下文中一共展示了eZProductCollectionItem::fetchList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

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

示例2: handleUserCountry

 function handleUserCountry($orderID)
 {
     // If user country is not required to calculate VAT then do nothing.
     if (!eZVATManager::isDynamicVatChargingEnabled() || !eZVATManager::isUserCountryRequired()) {
         return array('status' => eZModuleOperationInfo::STATUS_CONTINUE);
     }
     $user = eZUser::currentUser();
     // Get order's account information and extract user country from it.
     $order = eZOrder::fetch($orderID);
     if (!$order) {
         eZDebug::writeError("No such order: {$orderID}");
         return array('status' => eZModuleOperationInfo::STATUS_CANCELLED);
     }
     if ($user->attribute('is_logged_in')) {
         $userCountry = eZVATManager::getUserCountry($user, false);
     }
     $acctInfo = $order->attribute('account_information');
     if (isset($acctInfo['country'])) {
         $country = $acctInfo['country'];
         // If user is registered and logged in
         // and country is not yet specified for the user
         // then save entered country to the user information.
         if (!isset($userCountry) || !$userCountry) {
             eZVATManager::setUserCountry($user, $country);
         }
     } elseif (isset($userCountry) && $userCountry) {
         // If country is not set in shop account handler, we get it from logged user's information.
         $country = $userCountry;
     } else {
         $header = ezpI18n::tr('kernel/shop', 'Error checking out');
         $msg = ezpI18n::tr('kernel/shop', 'Unable to calculate VAT percentage because your country is unknown. ' . 'You can either fill country manually in your account information (if you are a registered user) ' . 'or contact site administrator.');
         $tpl = eZTemplate::factory();
         $tpl->setVariable("error_header", $header);
         $tpl->setVariable("error_list", array($msg));
         $operationResult = array('status' => eZModuleOperationInfo::STATUS_CANCELLED, 'result' => array('content' => $tpl->fetch("design:shop/cancelconfirmorder.tpl")));
         return $operationResult;
     }
     // Recalculate VAT for order's product collection items
     // according to the specified user country.
     $productCollection = $order->attribute('productcollection');
     if (!$productCollection) {
         eZDebug::writeError("Cannot find product collection for order " . $order->attribute('id'), "eZShopOperationCollection::handleUserCountry");
         return array('status' => eZModuleOperationInfo::STATUS_CONTINUE);
     }
     $items = eZProductCollectionItem::fetchList(array('productcollection_id' => $productCollection->attribute('id')));
     $vatIsKnown = true;
     $db = eZDB::instance();
     $db->begin();
     foreach ($items as $item) {
         $productContentObject = $item->attribute('contentobject');
         // Look up price object.
         $priceObj = null;
         $attributes = $productContentObject->contentObjectAttributes();
         foreach ($attributes as $attribute) {
             $dataType = $attribute->dataType();
             if (eZShopFunctions::isProductDatatype($dataType->isA())) {
                 $priceObj = $attribute->content();
                 break;
             }
         }
         if (!is_object($priceObj)) {
             continue;
         }
         // If the product is assigned a fixed VAT type then skip the product.
         $vatType = $priceObj->VATType();
         if (!$vatType->attribute('is_dynamic')) {
             continue;
         }
         // Update item's VAT percentage.
         $vatValue = $priceObj->VATPercent($productContentObject, $country);
         eZDebug::writeNotice("Updating product item collection item ('" . $productContentObject->attribute('name') . "'): " . "setting VAT {$vatValue}% according to order's country '{$country}'.");
         $item->setAttribute("vat_value", $vatValue);
         $item->store();
     }
     $db->commit();
     return array('status' => eZModuleOperationInfo::STATUS_CONTINUE);
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:77,代码来源:ezshopoperationcollection.php


注:本文中的eZProductCollectionItem::fetchList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。