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


PHP Mage_Catalog_Model_Product類代碼示例

本文整理匯總了PHP中Mage_Catalog_Model_Product的典型用法代碼示例。如果您正苦於以下問題:PHP Mage_Catalog_Model_Product類的具體用法?PHP Mage_Catalog_Model_Product怎麽用?PHP Mage_Catalog_Model_Product使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: _initProductLayout

 /**
  * Initialize product view layout
  *
  * @param   Mage_Catalog_Model_Product $product
  * @return  Mage_Catalog_ProductController
  */
 protected function _initProductLayout($product)
 {
     $update = $this->getLayout()->getUpdate();
     $update->addHandle('default');
     $this->addActionLayoutHandles();
     $update->addHandle('PRODUCT_TYPE_' . $product->getTypeId());
     $update->addHandle('PRODUCT_' . $product->getId());
     if ($product->getPageLayout()) {
         $this->getLayout()->helper('page/layout')->applyHandle($product->getPageLayout());
     }
     $this->loadLayoutUpdates();
     $update->addUpdate($product->getCustomLayoutUpdate());
     $this->generateLayoutXml()->generateLayoutBlocks();
     if ($product->getPageLayout()) {
         $this->getLayout()->helper('page/layout')->applyTemplate($product->getPageLayout());
     }
     $currentCategory = Mage::registry('current_category');
     if ($root = $this->getLayout()->getBlock('root')) {
         $root->addBodyClass('product-' . $product->getUrlKey());
         if ($currentCategory instanceof Mage_Catalog_Model_Category) {
             $root->addBodyClass('categorypath-' . $currentCategory->getUrlPath())->addBodyClass('category-' . $currentCategory->getUrlKey());
         }
     }
     return $this;
 }
開發者ID:uibar,項目名稱:laviniailies2,代碼行數:31,代碼來源:QuickviewController.php

示例2: createIndexData

 public function createIndexData(Mage_Catalog_Model_Product $object, Mage_Eav_Model_Entity_Attribute_Abstract $attribute = null)
 {
     $searchEntityId = $object->getId();
     $priceAttributeId = $this->getTierPriceAttribute()->getId();
     if ($object->isGrouped()) {
         $priceAttributeId = $this->getPriceAttribute()->getId();
         $associated = $object->getTypeInstance(true)->getAssociatedProducts($object);
         $searchEntityId = array();
         foreach ($associated as $product) {
             $searchEntityId[] = $product->getId();
         }
     }
     if (!count($searchEntityId)) {
         return false;
     }
     $result = array();
     $data = array();
     $data['store_id'] = $object->getStoreId();
     $data['entity_id'] = $object->getId();
     $search['store_id'] = $object->getStoreId();
     $search['entity_id'] = $searchEntityId;
     $search['attribute_id'] = $priceAttributeId;
     foreach ($this->_customerGroups as $group) {
         $search['customer_group_id'] = $group->getId();
         $data['customer_group_id'] = $group->getId();
         $value = $this->_getResource()->getMinimalValue($search);
         if (is_null($value)) {
             continue;
         }
         $data['value'] = $value;
         $result[] = $data;
     }
     return $result;
 }
開發者ID:codercv,項目名稱:urbansurprisedev,代碼行數:34,代碼來源:Minimalprice.php

示例3: setUp

 protected function setUp()
 {
     $this->_product = Mage::getModel('Mage_Catalog_Model_Product');
     $this->_product->load(1);
     $this->_block = Mage::app()->getLayout()->createBlock('Mage_Catalog_Block_Product_View_Type_Configurable');
     $this->_block->setProduct($this->_product);
 }
開發者ID:natxetee,項目名稱:magento2,代碼行數:7,代碼來源:ConfigurableTest.php

示例4: 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)
 {
     $availableUnits = array('mg', 'g', 'kg', 'ml', 'cl', 'l', 'cbm', 'cm', 'm', 'sqm');
     $basePriceAmount = $product->getBasePriceAmount();
     $basePriceUnit = strtolower($product->getBasePriceUnit());
     $unitPricingMeasure = $basePriceAmount . ' ' . $basePriceUnit;
     $basePriceReferenceAmount = $product->getBasePriceBaseAmount();
     $basePriceReferenceUnit = strtolower($product->getBasePriceBaseUnit());
     $unitPricingBaseMeasure = $basePriceReferenceAmount . ' ' . $basePriceReferenceUnit;
     // skip attribute if unit not available
     if (!in_array($basePriceUnit, $availableUnits) || !in_array($basePriceReferenceUnit, $availableUnits)) {
         return $shoppingProduct;
     }
     if (!empty($basePriceAmount) && !empty($basePriceReferenceAmount)) {
         $unitPricingMeasure = new Google_Service_ShoppingContent_ProductUnitPricingMeasure();
         $unitPricingMeasure->setUnit($basePriceUnit);
         $unitPricingMeasure->setValue($basePriceAmount);
         $unitPricingBaseMeasure = new Google_Service_ShoppingContent_ProductUnitPricingBaseMeasure();
         $unitPricingBaseMeasure->setUnit($basePriceReferenceUnit);
         $unitPricingBaseMeasure->setValue($basePriceReferenceAmount);
         $shoppingProduct->setUnitPricingMeasure($unitPricingMeasure);
         $shoppingProduct->setUnitPricingBaseMeasure($unitPricingBaseMeasure);
     }
     return $shoppingProduct;
 }
開發者ID:shakhawat4g,項目名稱:MagentoExtensions,代碼行數:32,代碼來源:ProductUom.php

示例5: _prepareProduct

 /**
  * Processes the product and its options before adding it to a quote or a wishlist
  *
  * @param Varien_Object              $buyRequest  request object
  * @param Mage_Catalog_Model_Product $product     product ibject
  * @param string                     $processMode process mode: strict for cart, lite for wishlist
  *
  * @return array|string
  */
 protected function _prepareProduct(Varien_Object $buyRequest, $product, $processMode)
 {
     if ($this->_isStrictProcessMode($processMode)) {
         return Mage::helper('solvingmagento_affiliateproduct')->__('Affiliate product %s cannot be added to cart. ' . ' On the product detail page click the "Go to parent site" button to access the product.', $product->getName());
     }
     return parent::_prepareProduct($buyRequest, $product, $processMode);
 }
開發者ID:hafeez3000,項目名稱:Solvingmagento_AffiliateProduct,代碼行數:16,代碼來源:Type.php

示例6: getFinalPrice

 /**
  * Returns product final price depending on options chosen
  *
  * @param   double $qty
  * @param   Mage_Catalog_Model_Product $product
  * @return  double
  */
 public function getFinalPrice($qty = null, $product)
 {
     if (is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
         return $product->getCalculatedFinalPrice();
     }
     $finalPrice = parent::getFinalPrice($qty, $product);
     if ($product->hasCustomOptions()) {
         /* @var $typeInstance Mage_Catalog_Model_Product_Type_Grouped */
         $typeInstance = $product->getTypeInstance(true);
         $associatedProducts = $typeInstance->setStoreFilter($product->getStore(), $product)->getAssociatedProducts($product);
         foreach ($associatedProducts as $childProduct) {
             /* @var $childProduct Mage_Catalog_Model_Product */
             $option = $product->getCustomOption('associated_product_' . $childProduct->getId());
             if (!$option) {
                 continue;
             }
             $childQty = $option->getValue();
             if (!$childQty) {
                 continue;
             }
             $finalPrice += $childProduct->getFinalPrice($childQty) * $childQty;
         }
     }
     $product->setFinalPrice($finalPrice);
     Mage::dispatchEvent('catalog_product_type_grouped_price', array('product' => $product));
     return max(0, $product->getData('final_price'));
 }
開發者ID:evinw,項目名稱:project_bloom_magento,代碼行數:34,代碼來源:Price.php

示例7: _getProductHelper

 /**
  * Returns helper for product type
  *
  * @param Mage_Catalog_Model_Product $product
  * @return Mage_Catalog_Helper_Product_Configuration_Interface
  */
 protected function _getProductHelper($product)
 {
     // Retrieve whole array of renderers
     $productHelpers = $this->getProductHelpers();
     if (!is_array($productHelpers)) {
         $column = $this->getColumn();
         if ($column) {
             $grid = $column->getGrid();
             if ($grid) {
                 $productHelpers = $grid->getProductConfigurationHelpers();
                 $this->setProductHelpers($productHelpers ? $productHelpers : array());
             }
         }
     }
     // Check whether we have helper for our product
     $productType = $product->getTypeId();
     if (isset($productHelpers[$productType])) {
         $helperName = $productHelpers[$productType];
     } else {
         if (isset($productHelpers['default'])) {
             $helperName = $productHelpers['default'];
         } else {
             $helperName = 'catalog/product_configuration';
         }
     }
     $helper = Mage::helper($helperName);
     if (!$helper instanceof Mage_Catalog_Helper_Product_Configuration_Interface) {
         Mage::throwException($this->__("Helper for options rendering doesn't implement required interface."));
     }
     return $helper;
 }
開發者ID:Airmal,項目名稱:Magento-Em,代碼行數:37,代碼來源:Item.php

示例8: getProductUrl

 /**
  * @param Mage_Catalog_Model_Product $product
  * @return string
  */
 public function getProductUrl($product)
 {
     if ($product->getVisibleInSiteVisibilities()) {
         return $product->getUrlModel()->getUrl($product);
     }
     return '#';
 }
開發者ID:hwguyguy,項目名稱:magento-customer-product-alert,代碼行數:11,代碼來源:View.php

示例9: saveGallery

 /**
  * Put the gallery value into the document collection
  *
  * @param Mage_Catalog_Model_Product $product       The product we want to save the gallery for
  * @param string                     $attributeCode The attribute code of the saved gallery
  * @param array                      $savedGallery  The content of the gallery to be saved
  *
  * @return Mage_Catalog_Model_Resource_Product_Attribute_Backend_Media Self reference
  */
 public function saveGallery($product, $attributeCode, $savedGallery)
 {
     $updateFilter = array('_id' => new MongoInt32($product->getId()));
     $updateValue = array('galleries.' . $attributeCode => array_values($savedGallery));
     $this->_getDocumentCollection()->update($updateFilter, array('$set' => $updateValue));
     return $this;
 }
開發者ID:keyur-iksula,項目名稱:mongogento,代碼行數:16,代碼來源:Media.php

示例10: redirectToProductPage

 /**
  * Redirect to product page
  *
  * @param \Mage_Catalog_Model_Product $product
  */
 public function redirectToProductPage(Mage_Catalog_Model_Product $product)
 {
     $response = Mage::app()->getResponse();
     $response->setRedirect($product->getProductUrl());
     $response->sendResponse();
     exit;
 }
開發者ID:KaiStapel,項目名稱:Magento-FACTFinder,代碼行數:12,代碼來源:Data.php

示例11: 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

示例12: 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)
 {
     $config = Mage::getSingleton('googleshoppingapi/config');
     $targetCountry = $config->getTargetCountry($product->getStoreId());
     $value = $config->getCountryInfo($targetCountry, 'language', $product->getStoreId());
     $shoppingProduct->setContentLanguage($value);
 }
開發者ID:shakhawat4g,項目名稱:MagentoExtensions,代碼行數:14,代碼來源:ContentLanguage.php

示例13: _getProductPrice

 /**
  * Get unit/final price for a product model.
  *
  * @param Mage_Catalog_Model_Product $product    the product model.
  * @param bool                       $finalPrice if final price.
  * @param bool                       $inclTax    if tax is to be included.
  *
  * @return float
  */
 protected function _getProductPrice($product, $finalPrice = false, $inclTax = true)
 {
     $price = 0;
     switch ($product->getTypeId()) {
         case Mage_Catalog_Model_Product_Type::TYPE_BUNDLE:
             // Get the bundle product "from" price.
             $price = $product->getPriceModel()->getTotalPrices($product, 'min', $inclTax);
             break;
         case Mage_Catalog_Model_Product_Type::TYPE_GROUPED:
             // Get the grouped product "starting at" price.
             /** @var $tmpProduct Mage_Catalog_Model_Product */
             $tmpProduct = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->addAttributeToFilter('entity_id', $product->getId())->setPage(1, 1)->addMinimalPrice()->addTaxPercents()->load()->getFirstItem();
             if ($tmpProduct) {
                 $price = $tmpProduct->getMinimalPrice();
                 if ($inclTax) {
                     $price = Mage::helper('tax')->getPrice($tmpProduct, $price, true);
                 }
             }
             break;
         default:
             $price = $finalPrice ? $product->getFinalPrice() : $product->getPrice();
             if ($inclTax) {
                 $price = Mage::helper('tax')->getPrice($product, $price, true);
             }
             break;
     }
     return $price;
 }
開發者ID:nosto,項目名稱:nosto-magento-nodeps,代碼行數:37,代碼來源:Price.php

示例14: getAddUrl

 /**
  * Retrieve url for add product to cart
  *
  * @param   Mage_Catalog_Model_Product $product
  * @return  string
  */
 public function getAddUrl($product, $additional = array())
 {
     /**
      * Identify continue shopping url
      */
     if ($currentProduct = Mage::registry('current_product')) {
         /**
          * go to product view page
          */
         $continueShoppingUrl = $currentProduct->getProductUrl();
     } elseif ($currentCategory = Mage::registry('current_category')) {
         /**
          * go to category view page
          */
         $continueShoppingUrl = $currentCategory->getCategoryUrl();
     } else {
         $continueShoppingUrl = $this->_getUrl('*/*/*', array('_current' => true));
     }
     $params = array(Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => Mage::helper('core')->urlEncode($continueShoppingUrl), 'product' => $product->getId());
     if ($this->_getRequest()->getModuleName() == 'checkout' && $this->_getRequest()->getControllerName() == 'cart') {
         $params['in_cart'] = 1;
     }
     if (count($additional)) {
         $params = array_merge($params, $additional);
     }
     return $this->_getUrl('checkout/cart/add', $params);
 }
開發者ID:arslbbt,項目名稱:mangentovies,代碼行數:33,代碼來源:Cart.php

示例15: setProduct

 public function setProduct(Mage_Catalog_Model_Product $product)
 {
     $store = Mage::app()->getStore($product->getStoreId());
     $product->setStore($store);
     $this->_product = $product;
     return $this;
 }
開發者ID:protechhelp,項目名稱:gamamba,代碼行數:7,代碼來源:Abstract.php


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