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


PHP Mage_Catalog_Model_Product::getCategoryIds方法代码示例

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


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

示例1: inRestrictProducts

 public static function inRestrictProducts(Mage_Catalog_Model_Product $oProduct)
 {
     $product_disabled = false;
     $restrict_groups = Mage::getStoreConfig('zeo_actions_setting/product_price/customer_groups');
     $restrict_groups = trim($restrict_groups);
     $restrict_groups = trim($restrict_groups, ",");
     if ($restrict_groups != "") {
         $restrict_groups_array = explode(",", $restrict_groups);
         $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
         if (in_array($groupId, $restrict_groups_array)) {
             return true;
         }
     }
     $restrict_categories = Mage::getStoreConfig('zeo_actions_setting/product_price/catalog_categories');
     $restrict_categories = trim($restrict_categories);
     $restrict_categories = trim($restrict_categories, ",");
     if ($restrict_categories != "") {
         $restrict_categories_array = explode(",", $restrict_categories);
         $product_categpries = $oProduct->getCategoryIds();
         $final_cats = array_intersect($restrict_categories_array, $product_categpries);
         if (count($final_cats) > 0) {
             return true;
         }
     }
     return $product_disabled;
 }
开发者ID:zexperto,项目名称:magento1-zeo-actions,代码行数:26,代码来源:Data.php

示例2: getItemBaseInfo

 public function getItemBaseInfo()
 {
     $helper = Mage::helper('catalog/image');
     $helper->init($this->product, $this->getProductImageType())->keepAspectRatio($this->_keepAspectRatio)->keepFrame($this->_keepFrame);
     $this->item['item_id'] = $this->product->getId();
     $this->item['item_title'] = $this->product->getName();
     $this->item['item_url'] = $this->product->getProductUrl();
     $this->item['cid'] = $this->product->getCategoryIds();
     $this->item['qty'] = $this->product->getStockItem()->getQty();
     $this->item['thumbnail_pic_url'] = (string) $helper->resize($this->thumbnail_with, $this->thumbnail_height);
     $this->item['main_pic_url'] = (string) $helper->resize($this->main_with, $this->main_height);
     $this->item['is_virtual'] = $this->product->isVirtual();
     $this->item['item_status'] = $this->product->isSaleable() ? 'instock' : 'outofstock';
     if (!$this->product->getRatingSummary()) {
         Mage::getModel('review/review')->getEntitySummary($this->product, Mage::app()->getStore()->getId());
     }
     $this->item['allow_add_to_cart'] = !$this->HasOptions();
     $this->item['rating_score'] = round((int) $this->product->getRatingSummary()->getRatingSummary() / 20);
     $this->item['rating_count'] = $this->product->getRatingSummary()->getReviewsCount();
     $this->item['sales_type'] = $this->product->isInStock() ? 'stock' : 'distribute';
     $this->item['qty_min_unit'] = 1;
     $stockItem = $this->product->getStockItem();
     if ($stockItem) {
         if ($stockItem->getMinSaleQty() && $stockItem->getMinSaleQty() > 0) {
             $this->item['qty_min_unit'] = $stockItem->getMinSaleQty();
         }
     }
     $this->item['item_type'] = $this->product->getTypeId();
     return $this->item;
 }
开发者ID:guohuadeng,项目名称:stampApp,代码行数:30,代码来源:ItemController.php

示例3: _isProductInCategory

 /**
  * Check if product is inside of the category
  * 
  * @param  Mage_Catalog_Model_Product   $product  
  * @param  Mage_Catalog_Model_Category  $category 
  * @return boolean
  */
 private function _isProductInCategory($product, $category)
 {
     $categoryIds = $product->getCategoryIds();
     $categoryId = $category->getId();
     if (in_array($categoryId, $categoryIds)) {
         return true;
     }
     return false;
 }
开发者ID:danielozano,项目名称:magento_prevnext,代码行数:16,代码来源:Product.php

示例4: getProductCategoryName

 public function getProductCategoryName(Mage_Catalog_Model_Product $product)
 {
     $productCategories = $product->getCategoryIds();
     if (!count($productCategories)) {
         return;
     }
     $tmpCategory = Mage::getModel('catalog/category')->load($productCategories[0]);
     //echo $tmpCategory->getId();
     return $tmpCategory->getName();
 }
开发者ID:liemnv,项目名称:Groupon-Clone-On-Magento,代码行数:10,代码来源:Data.php

示例5: getAssociatedCategoryIds

 /**
  * Retrieve an array of category_ids that are associated with the product
  *
  * @param Mage_Catalog_Model_Product $product
  * @return array
  */
 public function getAssociatedCategoryIds(Mage_Catalog_Model_Product $product)
 {
     $wpCategoryIds = $this->_getAssociatedWpEntityIds($product->getId(), 'category', 'category');
     if ($categoryIds = $product->getCategoryIds()) {
         foreach ($categoryIds as $categoryId) {
             $wpCategoryIds = array_merge($wpCategoryIds, $this->_getAssociatedWpEntityIds($categoryId, 'wp_category', 'category', 'category_id', 'category'));
         }
     }
     return array_unique($wpCategoryIds);
 }
开发者ID:linusshops,项目名称:mirror-connect20-fishpig-wordpress-integration,代码行数:16,代码来源:Product.php

示例6: getProductActiveCategories

 public function getProductActiveCategories(Mage_Catalog_Model_Product $product, $storeId = null)
 {
     $activeCategories = array();
     foreach ($product->getCategoryIds() as $categoryId) {
         if ($this->isCategoryActive($categoryId, $storeId)) {
             $activeCategories[] = $categoryId;
         }
     }
     return $activeCategories;
 }
开发者ID:halk,项目名称:algoliasearch-magento,代码行数:10,代码来源:Helper.php

示例7: testGetCategoryIds

 public function testGetCategoryIds()
 {
     // none
     /** @var $model Mage_Catalog_Model_Product */
     $model = Mage::getModel('Mage_Catalog_Model_Product');
     $this->assertEquals(array(), $model->getCategoryIds());
     // fixture
     $this->_model->setId(1);
     $this->assertEquals(array(2, 3, 4), $this->_model->getCategoryIds());
 }
开发者ID:natxetee,项目名称:magento2,代码行数:10,代码来源:ProductExternalTest.php

示例8: getReverbCategoryObjectsByProduct

 public function getReverbCategoryObjectsByProduct(Mage_Catalog_Model_Product $magentoProduct)
 {
     $magento_category_ids = $magentoProduct->getCategoryIds();
     $reverb_category_uuids = Mage::getResourceSingleton('reverbSync/category_reverb_magento_xref')->getReverbCategoryUuidsByMagentoCategoryIds($magento_category_ids);
     if (empty($reverb_category_uuids)) {
         // Return an empty array
         return array();
     }
     $reverb_category_uuids = array_unique($reverb_category_uuids);
     $reverbCategoryCollection = Mage::getModel('reverbSync/category_reverb')->getCollection()->addCategoryUuidFilter($reverb_category_uuids);
     return $reverbCategoryCollection->getItems();
 }
开发者ID:zztimur,项目名称:reverb-magento,代码行数:12,代码来源:Category.php

示例9: _collectTags

 /**
  * Should return list of tags to clean
  *
  * @param Mage_Catalog_Model_Product $object
  * @return string[]|string
  */
 protected function _collectTags($object)
 {
     // Clear category cache for new products
     if ($this->_isForUpdate && !$object->getId()) {
         $result = array();
         foreach ($object->getCategoryIds() as $categoryId) {
             $result[] = EcomDev_Varnish_Model_Processor_Category::TAG_PREFIX . $categoryId;
         }
         return $result;
     }
     return self::TAG_PREFIX . $object->getId();
 }
开发者ID:jonesio,项目名称:EcomDev_Varnish,代码行数:18,代码来源:Product.php

示例10: isCategoryActiveByProduct

 /**
  * Validate that the category of a give product is activated in the module
  *
  * @param Mage_Catalog_Model_Product $oProduct
  * @return bool
  */
 public function isCategoryActiveByProduct(Mage_Catalog_Model_Product $oProduct)
 {
     $aCurrentCategories = $oProduct->getCategoryIds();
     $aLinkedProductIds = array();
     if ($oProduct->isSuper()) {
         $aLinkedProductIds = $this->getChildrenAndParentIds($oProduct);
     }
     if (!empty($aLinkedProductIds)) {
         $aCurrentCategories = $this->getAllCategoryIds($aLinkedProductIds, $aCurrentCategories);
     }
     if (!is_array($aCurrentCategories)) {
         $aCurrentCategories = array($aCurrentCategories);
     }
     return $this->hasActiveCategory($aCurrentCategories);
 }
开发者ID:dwdonline,项目名称:B2BProfessional,代码行数:21,代码来源:Category.php

示例11: processCategoriesActions

 private function processCategoriesActions(Mage_Catalog_Model_Product $product)
 {
     $productCategories = $product->getCategoryIds();
     $categoriesByWebsite = array(0 => $productCategories);
     foreach ($product->getWebsiteIds() as $websiteId) {
         $categoriesByWebsite[$websiteId] = $productCategories;
     }
     /** @var Ess_M2ePro_Model_Listing_Auto_Actions_Mode_Category $autoActionsCategory */
     $autoActionsCategory = Mage::getModel('M2ePro/Listing_Auto_Actions_Mode_Category');
     $autoActionsCategory->setProduct($product);
     foreach ($categoriesByWebsite as $websiteId => $categoryIds) {
         foreach ($categoryIds as $categoryId) {
             $autoActionsCategory->synchWithAddedCategoryId($categoryId, $websiteId);
         }
     }
 }
开发者ID:newedge-media,项目名称:iwantmymeds,代码行数:16,代码来源:AutoActions.php

示例12: _changeUrlKey

 /**
  * @param Mage_Catalog_Model_Product $product
  * @return boolean
  */
 protected function _changeUrlKey(Mage_Catalog_Model_Product &$product)
 {
     if ($product->getCategoryId() || !$this->_getHelper()->isUrlRewriteEnable()) {
         return false;
     }
     //if category already exist or rewrite categories is disabled
     $categoryIds = $product->getCategoryIds();
     $categoryId = null;
     $product->setData("request_path", null);
     /** Process categories if they exists */
     if (is_array($categoryIds) && count($categoryIds)) {
         $categoryId = $categoryIds[count($categoryIds) - 1];
         //get the last element
     }
     return $this->_getUrlModel()->getProductUrl($product, null, $categoryId);
 }
开发者ID:sereban,项目名称:magento-marketo-integration,代码行数:20,代码来源:Url.php

示例13: convertAttribute

 /**
  * Set current attribute to entry (for specified product)
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Varien_Gdata_Gshopping_Entry $entry
  * @return Varien_Gdata_Gshopping_Entry
  */
 public function convertAttribute($product, $entry)
 {
     $productCategories = $product->getCategoryIds();
     // TODO: set Default value for product_type attribute if product isn't assigned for any category
     $value = 'Shop';
     if (!empty($productCategories)) {
         $category = Mage::getModel('Mage_Catalog_Model_Category')->load(array_shift($productCategories));
         $breadcrumbs = array();
         foreach ($category->getParentCategories() as $cat) {
             $breadcrumbs[] = $cat->getName();
         }
         $value = implode(' > ', $breadcrumbs);
     }
     $this->_setAttribute($entry, 'product_type', self::ATTRIBUTE_TYPE_TEXT, $value);
     return $entry;
 }
开发者ID:nemphys,项目名称:magento2,代码行数:23,代码来源:ProductType.php

示例14: convertAttribute

 /**
  * Set current attribute to entry (for specified product)
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Google_Service_ShoppingContent_Product $shoppingProduct
  * @return Google_Service_ShoppingContent_Product
  */
 public function convertAttribute($product, $shoppingProduct)
 {
     $productCategories = $product->getCategoryIds();
     // TODO: set Default value for product_type attribute if product isn't assigned for any category
     $value = 'Shop';
     if (!empty($productCategories)) {
         $category = Mage::getModel('catalog/category')->load(array_shift($productCategories));
         $breadcrumbs = array();
         foreach ($category->getParentCategories() as $cat) {
             $breadcrumbs[] = $cat->getName();
         }
         $value = implode(' > ', $breadcrumbs);
         Mage::log($value);
     }
     $shoppingProduct->setProductType($value);
     return $shoppingProduct;
 }
开发者ID:shakhawat4g,项目名称:MagentoExtensions,代码行数:24,代码来源:ProductType.php

示例15: setCategory

 /**
  * 
  * @param Mage_Catalog_Model_Product $product
  */
 public function setCategory($product)
 {
     $collection = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect(array('parent_id'))->addAttributeToFilter('entity_id', array('in' => $product->getCategoryIds()))->addAttributeToFilter('path', array('like' => $this->getRootCategoryPath() . '/%'))->addAttributeToFilter('is_active', 1)->addOrder('level', Varien_Data_Collection_Db::SORT_ORDER_DESC)->addOrder('include_in_menu', Varien_Data_Collection_Db::SORT_ORDER_DESC)->setPageSize(1)->setCurPage(1);
     if (!$product->getSkipEvent()) {
         Mage::dispatchEvent('mp_breadcrumb_category_collection', array('product' => $product, 'collection' => $collection));
     }
     $collection->load();
     if ($collection->count() > 0) {
         $id = $collection->getFirstItem()->getId();
         if ($product->canBeShowInCategory($id)) {
             $category = Mage::getModel('catalog/category')->load($id);
             /* @var $category Mage_Catalog_Model_Category */
             Mage::register('current_category', $category);
             $product->canBeShowInCategory($category->getId());
         }
     }
 }
开发者ID:adamvarga,项目名称:MageProfis_Breadcrumb,代码行数:21,代码来源:Observer.php


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