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


PHP CustomerQuery::useCustomerTitleQuery方法代码示例

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


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

示例1: getData

 protected function getData()
 {
     $locale = $this->language->getLocale();
     /**
      * This first query get each customer info and addresses.
      */
     $newsletterJoin = new Join(CustomerTableMap::EMAIL, NewsletterTableMap::EMAIL, Criteria::LEFT_JOIN);
     $query = new CustomerQuery();
     $results = $query->useCustomerTitleQuery('customer_title_')->useCustomerTitleI18nQuery('customer_title_i18n_')->filterByLocale($locale)->addAsColumn('title_TITLE', 'customer_title_i18n_.SHORT')->endUse()->endUse()->useAddressQuery()->useCountryQuery()->useCountryI18nQuery()->filterByLocale($locale)->addAsColumn('address_COUNTRY', CountryI18nTableMap::TITLE)->endUse()->endUse()->useCustomerTitleQuery('address_title')->useCustomerTitleI18nQuery('address_title_i18n')->filterByLocale($locale)->addAsColumn('address_TITLE', 'address_title_i18n.SHORT')->endUse()->endUse()->filterByIsDefault(true)->addAsColumn('address_LABEL', AddressTableMap::LABEL)->addAsColumn('address_FIRST_NAME', AddressTableMap::FIRSTNAME)->addAsColumn('address_LAST_NAME', AddressTableMap::LASTNAME)->addAsColumn('address_COMPANY', AddressTableMap::COMPANY)->addAsColumn('address_ADDRESS1', AddressTableMap::ADDRESS1)->addAsColumn('address_ADDRESS2', AddressTableMap::ADDRESS2)->addAsColumn('address_ADDRESS3', AddressTableMap::ADDRESS3)->addAsColumn('address_ZIPCODE', AddressTableMap::ZIPCODE)->addAsColumn('address_CITY', AddressTableMap::CITY)->addAsColumn('address_PHONE', AddressTableMap::PHONE)->addAsColumn('address_CELLPHONE', AddressTableMap::CELLPHONE)->endUse()->addJoinObject($newsletterJoin)->addAsColumn('newsletter_IS_REGISTRED', 'IF(NOT ISNULL(' . NewsletterTableMap::EMAIL . '),1,0)')->select([CustomerTableMap::ID, CustomerTableMap::REF, CustomerTableMap::LASTNAME, CustomerTableMap::FIRSTNAME, CustomerTableMap::EMAIL, CustomerTableMap::DISCOUNT, CustomerTableMap::CREATED_AT, 'title_TITLE', 'address_TITLE', 'address_LABEL', 'address_COMPANY', 'address_FIRST_NAME', 'address_LAST_NAME', 'address_ADDRESS1', 'address_ADDRESS2', 'address_ADDRESS3', 'address_ZIPCODE', 'address_CITY', 'address_COUNTRY', 'address_PHONE', 'address_CELLPHONE', 'newsletter_IS_REGISTRED'])->orderById()->find()->toArray();
     /**
      * Then get the orders
      */
     $orders = OrderQuery::create()->useCustomerQuery()->orderById()->endUse()->find();
     /**
      * And add them info the array
      */
     $orders->rewind();
     $arrayLength = count($results);
     $previousCustomerId = null;
     for ($i = 0; $i < $arrayLength; ++$i) {
         $currentCustomer =& $results[$i];
         $currentCustomerId = $currentCustomer[CustomerTableMap::ID];
         unset($currentCustomer[CustomerTableMap::ID]);
         if ($currentCustomerId === $previousCustomerId) {
             $currentCustomer["title_TITLE"] = "";
             $currentCustomer[CustomerTableMap::LASTNAME] = "";
             $currentCustomer[CustomerTableMap::FIRSTNAME] = "";
             $currentCustomer[CustomerTableMap::EMAIL] = "";
             $currentCustomer["address_COMPANY"] = "";
             $currentCustomer["newsletter_IS_REGISTRED"] = "";
             $currentCustomer[CustomerTableMap::CREATED_AT] = "";
             $currentCustomer[CustomerTableMap::DISCOUNT] = "";
             $currentCustomer += ["order_TOTAL" => "", "last_order_AMOUNT" => "", "last_order_DATE" => ""];
         } else {
             /**
              * Reformat created_at date
              */
             $date = $currentCustomer[CustomerTableMap::CREATED_AT];
             $dateTime = new \DateTime($date);
             $currentCustomer[CustomerTableMap::CREATED_AT] = $dateTime->format($this->language->getDatetimeFormat());
             /**
              * Then compute everything about the orders
              */
             $total = 0;
             $lastOrderAmount = 0;
             $lastOrderDate = null;
             $lastOrder = null;
             $lastOrderCurrencyCode = null;
             $lastOrderId = 0;
             $defaultCurrency = Currency::getDefaultCurrency();
             $defaultCurrencyCode = $defaultCurrency->getCode();
             if (empty($defaultCurrencyCode)) {
                 $defaultCurrencyCode = $defaultCurrency->getCode();
             }
             $formattedDate = null;
             /** @var \Thelia\Model\Order $currentOrder */
             while (false !== ($currentOrder = $orders->current())) {
                 if ($currentCustomerId != $currentOrder->getCustomerId()) {
                     break;
                 }
                 $amount = $currentOrder->getTotalAmount($tax);
                 if (0 < ($rate = $currentOrder->getCurrencyRate())) {
                     $amount = round($amount / $rate, 2);
                 }
                 $total += $amount;
                 /** @var \DateTime $date */
                 $date = $currentOrder->getCreatedAt();
                 if (null === $lastOrderDate || $date >= $lastOrderDate && $lastOrderId < $currentOrder->getId()) {
                     $lastOrder = $currentOrder;
                     $lastOrderDate = $date;
                     $lastOrderId = $currentOrder->getId();
                 }
                 $orders->next();
             }
             if ($lastOrderDate !== null) {
                 $formattedDate = $lastOrderDate->format($this->language->getDatetimeFormat());
                 $orderCurrency = $lastOrder->getCurrency();
                 $lastOrderCurrencyCode = $orderCurrency->getCode();
                 if (empty($lastOrderCurrencyCode)) {
                     $lastOrderCurrencyCode = $orderCurrency->getCode();
                 }
                 $lastOrderAmount = $lastOrder->getTotalAmount($tax_);
             }
             $currentCustomer += ["order_TOTAL" => $total . " " . $defaultCurrencyCode, "last_order_AMOUNT" => $lastOrderAmount === 0 ? "" : $lastOrderAmount . " " . $lastOrderCurrencyCode, "last_order_DATE" => $formattedDate];
         }
         $previousCustomerId = $currentCustomerId;
     }
     return $results;
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:89,代码来源:CustomerExport.php


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