當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Mage_Catalog_Model_Resource_Product_Collection::getFlag方法代碼示例

本文整理匯總了PHP中Mage_Catalog_Model_Resource_Product_Collection::getFlag方法的典型用法代碼示例。如果您正苦於以下問題:PHP Mage_Catalog_Model_Resource_Product_Collection::getFlag方法的具體用法?PHP Mage_Catalog_Model_Resource_Product_Collection::getFlag怎麽用?PHP Mage_Catalog_Model_Resource_Product_Collection::getFlag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mage_Catalog_Model_Resource_Product_Collection的用法示例。


在下文中一共展示了Mage_Catalog_Model_Resource_Product_Collection::getFlag方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: sort

 /**
  * @param Mage_Catalog_Model_Resource_Product_Collection $productCollection
  * @return mixed
  */
 public function sort(Mage_Catalog_Model_Resource_Product_Collection $productCollection)
 {
     //Pass a small validation
     if (!$this->_getHelper()->isCategorySortingEnable() || $productCollection->getFlag(self::MARKETO_SORTED)) {
         return $productCollection;
     }
     $categoriesList = $this->_getPesonalizeCalculator()->getScoreCategoryParams(HooshMarketing_Marketo_Model_Personalize_Calculator::CATEGORY_ID_AND_SCORE);
     //get List of categories with key -> Category_id and value - Score
     if (!count($categoriesList)) {
         //if we havn`t score categories do nothing
         return $productCollection;
     }
     uasort($categoriesList, function ($f, $s) {
         return $f > $s ? 1 : -1;
         //sort by descending
     });
     //Sort categories in order to show top scored categories first
     $categoriesList = array_keys($categoriesList);
     // get only category ids
     try {
         $productCategoryTable = $this->_getCoreResource()->getTableName("catalog_category_product");
         $productCollection->getSelect()->joinLeft(array("marketo_category_table" => $productCategoryTable), "marketo_category_table.product_id = e.entity_id", array("top_category_id" => "marketo_category_table.category_id"))->group("entity_id")->order("FIELD(top_category_id, " . implode(',', $categoriesList) . ") DESC");
         //order by top
         $productCollection->setFlag(self::MARKETO_SORTED, true);
         //to set order only one time
     } catch (Exception $e) {
         Mage::logException($e);
     }
     return $productCollection;
 }
開發者ID:sereban,項目名稱:magento-marketo-integration,代碼行數:34,代碼來源:Sorting.php

示例2: addIndexToProductCollection

 /**
  * Add index select in product collection
  *
  * @param Mage_Catalog_Model_Resource_Product_Collection $collection
  * @param int $customerGroupId
  * @return Enterprise_CatalogPermissions_Model_Resource_Permission_Index
  */
 public function addIndexToProductCollection($collection, $customerGroupId)
 {
     $parts = $collection->getSelect()->getPart(Zend_Db_Select::FROM);
     if (isset($parts['perm'])) {
         return $this;
     }
     if ($collection->getFlag('disable_root_category_filter')) {
         $permColumns = $this->_getPermColumns();
     } else {
         $permColumns = array('grant_catalog_category_view', 'grant_catalog_product_price', 'grant_checkout_items');
     }
     $collection->getSelect()->joinLeft(array('perm' => $this->getTable('permission_index')), 'perm.category_id=cat_index.category_id
                     AND perm.customer_group_id= ' . $customerGroupId . ' AND perm.website_id=' . Mage::app()->getStore()->getWebsiteId(), $permColumns);
     if (!Mage::helper('enterprise_catalogpermissions')->isAllowedCategoryView()) {
         $collection->getSelect()->where('perm.grant_catalog_category_view = ?', Enterprise_CatalogPermissions_Model_Permission::PERMISSION_ALLOW);
     } else {
         $collection->getSelect()->where('perm.grant_catalog_category_view != ?' . ' OR perm.grant_catalog_category_view IS NULL', Enterprise_CatalogPermissions_Model_Permission::PERMISSION_DENY);
     }
     $collection->getSelect()->where('cat_index.store_id=' . $collection->getStoreId());
     if ($collection->getFlag('disable_root_category_filter')) {
         $collection->getSelect()->where('cat_index.is_parent=1');
         $collection->getSelect()->group('cat_index.product_id');
     }
     if ($this->_isLinkCollection($collection)) {
         $collection->getSelect()->where('perm.grant_catalog_product_price!=' . Enterprise_CatalogPermissions_Model_Permission::PERMISSION_DENY . ' OR perm.grant_catalog_product_price IS NULL')->where('perm.grant_checkout_items!=' . Enterprise_CatalogPermissions_Model_Permission::PERMISSION_DENY . ' OR perm.grant_checkout_items IS NULL');
     }
     return $this;
 }
開發者ID:QiuLihua83,項目名稱:magento-enterprise-1.13.1.0,代碼行數:35,代碼來源:Index.php


注:本文中的Mage_Catalog_Model_Resource_Product_Collection::getFlag方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。