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


PHP Provider::getProductData方法代码示例

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


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

示例1: getProductsData

 /**
  * Get products data
  *
  * @return array
  */
 public function getProductsData()
 {
     $productsData = [];
     $provider = new Provider();
     foreach ($this->_brands as $brandId => $brand) {
         $categoryUrl = $provider->getCategoryUrl(self::STORE_URL, $brandId, self::ALL_CATEGORY_PRODUCTS);
         if ($categoryUrl) {
             $productUrls[$categoryUrl] = $provider->getProductUrls($this->_addStoreUrl($categoryUrl));
             foreach ($productUrls[$categoryUrl] as $index => $productUrl) {
                 $productData = $provider->getProductData($this->_addStoreUrl($productUrl));
                 $productsData[$productUrl] = $this->_addBrandToProductData($productData, $brand);
             }
         }
     }
     return $productsData;
 }
开发者ID:VaD1ke,项目名称:letual_parse,代码行数:21,代码来源:Getter.php

示例2: loadBundleChildElements

 /**
  * @return bool
  */
 protected function loadBundleChildElements()
 {
     $bundleChildList = Provider::getSetItems($this);
     if (empty($bundleChildList)) {
         return null;
     }
     /** @var Basket $baseBasketCollection */
     $baseBasketCollection = $this->getCollection();
     /** @var Order $order */
     $order = $baseBasketCollection->getOrder();
     /** @var Basket $bundleCollection */
     $bundleCollection = BasketBundleCollection::create($baseBasketCollection->getSiteId());
     if ($order !== null) {
         $bundleCollection->setOrder($order);
     }
     foreach ($bundleChildList as $bundleBasketListDat) {
         foreach ($bundleBasketListDat["ITEMS"] as $bundleDat) {
             $bundleFields = static::clearBundleItemFields($bundleDat);
             $bundleFields['CURRENCY'] = $this->getCurrency();
             if ($this->getId() > 0) {
                 $bundleFields['SET_PARENT_ID'] = $this->getId();
             }
             /** @var BasketItem $basketItem */
             $bundleBasketItem = BasketItem::create($bundleCollection, $bundleFields['MODULE'], $bundleFields['PRODUCT_ID']);
             if (!empty($bundleDat["PROPS"]) && is_array($bundleDat["PROPS"])) {
                 /** @var BasketPropertiesCollection $property */
                 $property = $bundleBasketItem->getPropertyCollection();
                 $property->setProperty($bundleDat["PROPS"]);
             }
             $bundleFields['QUANTITY'] = $bundleFields['QUANTITY'] * $this->getQuantity();
             $bundleBasketItem->setFieldsNoDemand($bundleFields);
             $bundleBasketItem->parentBasketItem = $this;
             $bundleBasketItem->parentId = $this->getBasketCode();
             $bundleCollection->addItem($bundleBasketItem);
         }
     }
     if ($productList = Provider::getProductData($bundleCollection, array('QUANTITY', 'PRICE'))) {
         foreach ($productList as $productBasketCode => $productDat) {
             if ($bundleBasketItem = $bundleCollection->getItemByBasketCode($productBasketCode)) {
                 unset($productDat['DISCOUNT_LIST']);
                 $bundleBasketItem->setFieldsNoDemand($productDat);
             }
         }
     }
     $this->bundleCollection = $bundleCollection;
     return $bundleCollection;
 }
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:50,代码来源:basketitem.php

示例3: refreshData

 /**
  * @param array $select
  * @param BasketItem $refreshItem
  * @return Result
  * @throws Main\ArgumentNullException
  * @throws Main\NotSupportedException
  * @throws Main\ObjectNotFoundException
  */
 public function refreshData($select = array(), BasketItem $refreshItem = null)
 {
     $result = new Result();
     $isStartField = $this->isStartField();
     $discount = null;
     /** @var Order $order */
     if ($order = $this->getOrder()) {
         $discount = $order->getDiscount();
     }
     $settableFields = array_fill_keys(BasketItem::getSettableFields(), true);
     $data = Provider::getProductData($this, $select, $refreshItem);
     foreach ($data as $key => $value) {
         //$item = $this->getItemByBasketCode($key);
         if (!($item = $this->getItemByBasketCode($key))) {
             continue;
         }
         if (isset($value['DELETE']) && $value['DELETE']) {
             $item->delete();
             if ($discount !== null) {
                 $discount->clearBasketItemData($key);
             }
             continue;
         }
         $basePrice = false;
         $currency = false;
         $discountList = false;
         $value1 = array();
         $roundFields = static::getRoundFields();
         foreach ($value as $k => $v) {
             //TODO: create method for save data in discount
             if ($k == 'BASE_PRICE') {
                 $basePrice = true;
             }
             if ($k == 'CURRENCY') {
                 $currency = true;
             }
             if ($k == 'DISCOUNT_LIST' && !empty($v)) {
                 $discountList = true;
             }
             //TODO END
             if (isset($settableFields[$k])) {
                 if ($item) {
                     if ($k == "PRICE" && $item->isCustomPrice()) {
                         $v = $item->getPrice();
                     }
                     if (in_array($k, $roundFields)) {
                         $v = roundEx($v, SALE_VALUE_PRECISION);
                     }
                 }
                 $value1[$k] = $v;
             }
         }
         if (!$item->isCustomPrice()) {
             $value1['PRICE'] = $value1['BASE_PRICE'] - $value1['DISCOUNT_PRICE'];
         }
         if (!$item) {
             $item = $this->createItem($value['MODULE_ID'], $value['PRODUCT_ID']);
         }
         if (!$item) {
             continue;
         }
         if ($discount !== null) {
             if ($basePrice && $currency) {
                 $discount->setBasketItemBasePrice($key, $value['BASE_PRICE'], $value['CURRENCY']);
             }
             if ($discountList) {
                 $discount->setBasketItemDiscounts($key, $value['DISCOUNT_LIST']);
             }
         }
         /** @var Result $r */
         $r = $item->setFields($value1);
         if (!$r->isSuccess()) {
             $result->addErrors($r->getErrors());
         }
     }
     /** @var Order $order */
     if ($order = $this->getOrder()) {
         $r = $order->refreshData(array('PRICE', 'PRICE_DELIVERY'));
         if (!$r->isSuccess()) {
             $result->addErrors($r->getErrors());
         }
     }
     if ($isStartField) {
         $hasMeaningfulFields = $this->hasMeaningfulField();
         /** @var Result $r */
         $r = $this->doFinalAction($hasMeaningfulFields);
         if (!$r->isSuccess()) {
             $result->addErrors($r->getErrors());
         }
     }
     return $result;
 }
开发者ID:webgksupport,项目名称:alpina,代码行数:100,代码来源:basket.php

示例4: refreshData

 /**
  * @param array $select
  * @param BasketItem $refreshItem
  * @return Result
  * @throws Main\ArgumentNullException
  * @throws Main\NotSupportedException
  * @throws Main\ObjectNotFoundException
  */
 public function refreshData($select = array(), BasketItem $refreshItem = null)
 {
     $result = new Result();
     $isStartField = $this->isStartField();
     $discount = null;
     /** @var Order $order */
     if ($order = $this->getOrder()) {
         $discount = $order->getDiscount();
     }
     $settableFields = array_fill_keys(BasketItem::getSettableFields(), true);
     $data = Provider::getProductData($this, $select, $refreshItem);
     foreach ($data as $key => $value) {
         /** @var null|BasketItem $item */
         $item = null;
         //$item = $this->getItemByBasketCode($key);
         //			if(!($item = $this->getItemByBasketCode($key)))
         //			{
         //				continue;
         //			}
         $item = $this->getItemByBasketCode($key);
         if (isset($value['DELETE']) && $value['DELETE']) {
             if ($item) {
                 $item->delete();
                 if ($discount !== null) {
                     $discount->clearBasketItemData($key);
                 }
             }
             continue;
         }
         $value1 = array();
         $roundFields = static::getRoundFields();
         foreach ($value as $k => $v) {
             if (isset($settableFields[$k])) {
                 if ($item) {
                     if ($k == "PRICE" && $item->isCustomPrice()) {
                         $v = $item->getPrice();
                     }
                     if (in_array($k, $roundFields)) {
                         $v = PriceMaths::roundPrecision($v);
                     }
                 }
                 $value1[$k] = $v;
             }
         }
         if (!$item) {
             $item = $this->createItem($value['MODULE_ID'], $value['PRODUCT_ID']);
         }
         if (!$item) {
             continue;
         }
         if (!$item->isCustomPrice() && array_key_exists('DISCOUNT_PRICE', $value1) && array_key_exists('BASE_PRICE', $value1)) {
             $value1['PRICE'] = $value1['BASE_PRICE'] - $value1['DISCOUNT_PRICE'];
         }
         if ($discount instanceof Discount) {
             $discount->setBasketItemData($key, $value);
         }
         $isBundleParent = (bool) ($item && $item->isBundleParent());
         /** @var Result $r */
         $r = $item->setFields($value1);
         if (!$r->isSuccess()) {
             $result->addErrors($r->getErrors());
         }
         if (($isBundleParent || $item->isBundleParent()) && array_key_exists('BUNDLE_ITEMS', $value)) {
             /** @var BasketBundleCollection $bundleCollection */
             if ($bundleCollection = $item->getBundleCollection()) {
                 $bundleIndexList = array();
                 /** @var BasketItem $bundleBasketItem */
                 foreach ($bundleCollection as $bundleBasketItem) {
                     $bundleIndexList[$bundleBasketItem->getBasketCode()] = true;
                 }
                 /** @var array $bundleBasketItemData */
                 foreach ($value['BUNDLE_ITEMS'] as $bundleBasketItemData) {
                     if (empty($bundleBasketItemData['MODULE']) || empty($bundleBasketItemData['PRODUCT_ID'])) {
                         continue;
                     }
                     /** @var BasketItem $bundleBasketItem */
                     if ($bundleBasketItem = $bundleCollection->getExistsItem($bundleBasketItemData['MODULE'], $bundleBasketItemData['PRODUCT_ID'], !empty($bundleBasketItemData['PROPS']) && is_array($bundleBasketItemData['PROPS']) ? $bundleBasketItemData['PROPS'] : array())) {
                         if (isset($bundleIndexList[$bundleBasketItem->getBasketCode()])) {
                             unset($bundleIndexList[$bundleBasketItem->getBasketCode()]);
                         }
                     } else {
                         /** @var BasketItem $bundleBasketItem */
                         $bundleBasketItem = BasketItem::create($bundleCollection, $bundleBasketItemData['MODULE'], $bundleBasketItemData['PRODUCT_ID']);
                     }
                     if (!$bundleBasketItem) {
                         continue;
                     }
                     $fields = array_intersect_key($bundleBasketItemData, $settableFields);
                     $r = $bundleBasketItem->setFields($fields);
                     if (!$r->isSuccess()) {
                         $result->addErrors($r->getErrors());
                     }
//.........这里部分代码省略.........
开发者ID:akniyev,项目名称:itprom_dobrohost,代码行数:101,代码来源:basket.php


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