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


PHP Mage_Catalog_Model_Resource_Product_Collection::getItemByColumnValue方法代码示例

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


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

示例1: _process

 /**
  * @param Mage_Catalog_Model_Resource_Product_Collection $products
  * @return bool
  */
 protected function _process($products)
 {
     $processor = $this->_htmlProcessor;
     $helper = $this->_getHelper();
     foreach ($products as $product) {
         $product->setData('url', $product->getProductUrl());
     }
     $items = $processor->query($helper->getCssSelector('related_product_link'));
     if (count($items) === 0) {
         return false;
     }
     $positions = array();
     foreach ($items as $i => $item) {
         /** @var $item DOMElement */
         $url = $item->getAttribute('href');
         $product = $products->getItemByColumnValue('url', $url);
         if (!$product) {
             continue;
         }
         if ($helper->isEnabledForProduct($product)) {
             $positions[] = $i;
         }
     }
     $processor->replace($helper->getCssSelector('related_product_price'), $this->_getHelper()->prepareReplacement(), $positions);
 }
开发者ID:CE-Webmaster,项目名称:CE-Hub,代码行数:29,代码来源:Related.php

示例2: _linkProducts

 /**
  * Update product links for the given type of links - up sell, related, cross sell
  * @param  Mage_Catalog_Model_Product $product     Product to add links to
  * @param  array                      $linkUpdates Product links data
  * @param  string                     $linkType    Type of product links to create
  * @return array                                   Any links that could not be added
  */
 protected function _linkProducts(Mage_Catalog_Model_Product $product, $linkUpdates, $linkType)
 {
     $opFilter = function ($operation) {
         return function ($el) use($operation) {
             return strtolower($el['operation_type']) === $operation;
         };
     };
     $skuMap = function ($link) {
         return $link['link_to_unique_id'];
     };
     // get all currently linked products of this link type
     $linkedProductsGetter = $this->_linkTypes[$linkType]['linked_products_getter_method'];
     $linkedProducts = $product->{$linkedProductsGetter}();
     // remove any links that are supposed to be getting deleted
     $deleteSkus = array_map($skuMap, array_filter($linkUpdates, $opFilter('delete')));
     $linkedProducts = array_filter($linkedProducts, function ($prod) use($deleteSkus) {
         return !in_array($prod->getSku(), $deleteSkus);
     });
     $addSkus = array_map($skuMap, array_filter($linkUpdates, $opFilter('add')));
     // Go through the skus to add and look up the product id for each one.
     // If any are missing, add the product link for that sku to a list of links that
     // cannot be resolved yet.
     $missingLinks = array();
     $idsToAdd = array();
     foreach ($addSkus as $sku) {
         $linkProduct = $this->_products->getItemByColumnValue('sku', $sku);
         $id = $linkProduct ? $linkProduct->getId() : null;
         if ($id) {
             $idsToAdd[] = $id;
         } else {
             $missingLinks[] = $this->_buildProductLinkForSku($sku, $linkType, 'Add');
         }
     }
     // get a list of all products that should be linked
     $linkIds = array_filter(array_unique(array_merge(array_map(function ($prod) {
         return $prod->getId();
     }, $linkedProducts), $idsToAdd)));
     $linkData = array();
     foreach ($linkIds as $id) {
         $linkData[$id] = array('position' => '');
     }
     // add the updated links to the product
     $product->setData($this->_linkTypes[$linkType]['data_attribute'], $linkData);
     // return links that were not resolved
     return $missingLinks;
 }
开发者ID:ryaan-anthony,项目名称:magento-retail-order-management,代码行数:53,代码来源:Cleaner.php

示例3: addImportErrors

 /**
  * given a Mage_Catalog_Model_Resource_Product_Collection object and a list of SKUs
  * if the SKUs in the list of sku is not in the collection then add error confirmation node
  * to feed file about sku was not imported
  * @param  Mage_Catalog_Model_Resource_Product_Collection $collection
  * @param  array list of SKUs that were suppose to be imported
  * @param  string the file the sku was found on
  * @param  string the event type
  * @return self
  */
 protected function addImportErrors(Mage_Catalog_Model_Resource_Product_Collection $collection, array $skus, $fileName, $type)
 {
     foreach ($skus as $sku) {
         $product = $collection->getItemByColumnValue('sku', $sku);
         if (is_null($product)) {
             $this->appendError(self::SKU_NOT_IMPORTED, '', $type, $fileName, $sku);
         }
     }
     return $this;
 }
开发者ID:sirishreddyg,项目名称:magento-retail-order-management,代码行数:20,代码来源:Confirmations.php


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