本文整理汇总了PHP中Mage_Catalog_Model_Product类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Product类的具体用法?PHP Mage_Catalog_Model_Product怎么用?PHP Mage_Catalog_Model_Product使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Catalog_Model_Product类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: getSelectionQtyTitlePrice
/**
* Returns the formatted string for the quantity chosen for the given selection
*
* @param Mage_Catalog_Model_Product $_selection
* @param bool $includeContainer
* @return string
*/
public function getSelectionQtyTitlePrice(Mage_Catalog_Model_Product $_selection, $includeContainer = true)
{
if ($this->isGuestView()) {
return $_selection->getSelectionQty() * 1 . ' x ' . $this->escapeHtml($_selection->getName());
}
return parent::getSelectionQtyTitlePrice($_selection, $includeContainer);
}
开发者ID:ryaan-anthony,项目名称:magento-members-only,代码行数:14,代码来源:TOption.php
示例17: getUrl
public function getUrl(Mage_Catalog_Model_Product $product, $params = array())
{
if (Mage::getVersion() >= 1.8) {
$product->setData('url', '');
}
return parent::getUrl($product, $params);
}
开发者ID:chaudhary4k4,项目名称:supershopmagento,代码行数:7,代码来源:Vt_Flycart_Model_Product_Url.php
示例18: 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)
{
$entry->cleanTaxes();
if (Mage::helper('tax')->getConfig()->priceIncludesTax()) {
return $entry;
}
$calc = Mage::helper('tax')->getCalculator();
$customerTaxClass = $calc->getDefaultCustomerTaxClass($product->getStoreId());
$rates = $calc->getRatesByCustomerAndProductTaxClasses($customerTaxClass, $product->getTaxClassId());
$targetCountry = Mage::getSingleton('googleshopping/config')->getTargetCountry($product->getStoreId());
$ratesTotal = 0;
foreach ($rates as $rate) {
if ($targetCountry == $rate['country']) {
$regions = $this->_parseRegions($rate['state'], $rate['postcode']);
$ratesTotal += count($regions);
if ($ratesTotal > self::RATES_MAX) {
Mage::throwException(Mage::helper('googleshopping')->__("Google shopping only supports %d tax rates per product", self::RATES_MAX));
}
foreach ($regions as $region) {
$entry->addTax(array('tax_rate' => $rate['value'] * 100, 'tax_country' => empty($rate['country']) ? '*' : $rate['country'], 'tax_region' => $region));
}
}
}
return $entry;
}
开发者ID:ksaltik,项目名称:tooldexlive,代码行数:32,代码来源:Tax.php
示例19: getAddUrl
/**
* Retrieve url for add product to cart
*
* @param Mage_Catalog_Model_Product $product
* @return string
*/
public function getAddUrl($product, $additional = array())
{
$continueUrl = Mage::helper('core')->urlEncode($this->getCurrentUrl());
$urlParamName = Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED;
$routeParams = array(
$urlParamName => $continueUrl,
'product' => $product->getEntityId()
);
if (!empty($additional)) {
$routeParams = array_merge($routeParams, $additional);
}
if ($product->hasUrlDataObject()) {
$routeParams['_store'] = $product->getUrlDataObject()->getStoreId();
$routeParams['_store_to_url'] = true;
}
if ($this->_getRequest()->getRouteName() == 'checkout'
&& $this->_getRequest()->getControllerName() == 'cart') {
$routeParams['in_cart'] = 1;
}
return $this->_getUrl('checkout/cart/add', $routeParams);
}
开发者ID:ravi2jdesign,项目名称:magentoOLD,代码行数:31,代码来源:Cart.php
示例20: saveProductLinks
/**
* Save Product Links process
*
* @param Mage_Catalog_Model_Product $product
* @param array $data
* @param int $typeId
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Link
*/
public function saveProductLinks($product, $data, $typeId)
{
if (!is_array($data)) {
$data = array();
}
$attributes = $this->getAttributesByType($typeId);
$deleteCondition = $this->_getWriteAdapter()->quoteInto('product_id=?', $product->getId()) . $this->_getWriteAdapter()->quoteInto(' AND link_type_id=?', $typeId);
$this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition);
foreach ($data as $linkedProductId => $linkInfo) {
$this->_getWriteAdapter()->insert($this->getMainTable(), array('product_id' => $product->getId(), 'linked_product_id' => $linkedProductId, 'link_type_id' => $typeId));
$linkId = $this->_getWriteAdapter()->lastInsertId();
foreach ($attributes as $attributeInfo) {
$attributeTable = $this->getAttributeTypeTable($attributeInfo['type']);
if ($attributeTable && isset($linkInfo[$attributeInfo['code']])) {
$this->_getWriteAdapter()->insert($attributeTable, array('product_link_attribute_id' => $attributeInfo['id'], 'link_id' => $linkId, 'value' => $linkInfo[$attributeInfo['code']]));
}
}
}
/**
* Grouped product relations should be added to relation table
*/
if ($typeId == Mage_Catalog_Model_Product_Link::LINK_TYPE_GROUPED) {
}
return $this;
}
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:33,代码来源:Link.php
注:本文中的Mage_Catalog_Model_Product类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论