本文整理汇总了PHP中Mage_Catalog_Model_Product_Type_Abstract类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Product_Type_Abstract类的具体用法?PHP Mage_Catalog_Model_Product_Type_Abstract怎么用?PHP Mage_Catalog_Model_Product_Type_Abstract使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Catalog_Model_Product_Type_Abstract类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: checkProductBuyState
public function checkProductBuyState($product = null)
{
Mage_Catalog_Model_Product_Type_Abstract::checkProductBuyState($product);
$product = $this->getProduct($product);
$productOptionIds = $this->getOptionsIds($product);
$productSelections = $this->getSelectionsCollection($productOptionIds, $product);
$selectionIds = $product->getCustomOption('bundle_selection_ids');
$selectionIds = unserialize($selectionIds->getValue());
$buyRequest = $product->getCustomOption('info_buyRequest');
$buyRequest = new Varien_Object(unserialize($buyRequest->getValue()));
$bundleOption = $buyRequest->getBundleOption();
if (empty($bundleOption)) {
Mage::throwException($this->getSpecifyOptionMessage());
}
$skipSaleableCheck = Mage::helper('catalog/product')->getSkipSaleableCheck();
foreach ($selectionIds as $selectionId) {
/* @var $selection Mage_Bundle_Model_Selection */
$selection = $productSelections->getItemById($selectionId);
if (!$selection || !$selection->isSalable() && !$skipSaleableCheck) {
Mage::throwException(Mage::helper('bundle')->__('Selected required options are not available.'));
}
}
/*
$product->getTypeInstance(true)->setStoreFilter($product->getStoreId(), $product);
$optionsCollection = $this->getOptionsCollection($product);
foreach ($optionsCollection->getItems() as $option) {
if ($option->getRequired() && empty($bundleOption[$option->getId()])) {
Mage::throwException(
Mage::helper('bundle')->__('Required options are not selected.')
);
}
}
*/
return $this;
}
开发者ID:xiaoguizhidao,项目名称:magento,代码行数:35,代码来源:BundleProductType.php
示例2: prepareForCartAdvanced
public function prepareForCartAdvanced(Varien_Object $buyRequest, $product = null, $processMode = null)
{
Mage::getModel('sarp/product_type_default')->checkPeriod($product, $buyRequest);
$Period = Mage::getModel('sarp/period');
/* We should add custom options that doesnt exist */
if ($buyRequest->getAwSarpSubscriptionType()) {
if ($Period->load($buyRequest->getAwSarpSubscriptionType())->getId()) {
$product->addCustomOption('aw_sarp_subscription_type', $Period->getId());
}
}
$options = $buyRequest->getOptions();
if (isset($options['aw_sarp_subscription_start']) && is_array($options['aw_sarp_subscription_start'])) {
$subscriptionStart = $options['aw_sarp_subscription_start'];
$date = new Zend_Date();
$date->setMinute(0)->setHour(0)->setSecond(0)->setDay($subscriptionStart['day'])->setMonth($subscriptionStart['month'])->setYear($subscriptionStart['year']);
$buyRequest->setAwSarpSubscriptionStart($date->toString(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)));
}
if ($buyRequest->getAwSarpSubscriptionStart() && $Period->getId()) {
$date = new Zend_Date($buyRequest->getAwSarpSubscriptionStart(), Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
// Check date
// Never check if start date
//$performDateCompare = !!Mage::getSingleton('customer/session')->getCustomer()->getId();
$performDateCompare = !AW_Sarp_Model_Cron::$isCronSession;
$today = new Zend_Date();
if (!$this->isVirtual($product)) {
$today->addDayOfYear($Period->getPaymentOffset());
}
if ($performDateCompare && ($date->compare($today, Zend_Date::DATE_SHORT) < 0 || !$Period->isAllowedDate($date, $product))) {
throw new Mage_Core_Exception(Mage::helper('sarp')->__("Selected date is not valid for specified period"));
}
} else {
$date = Mage::app()->getLocale()->date();
}
$product->addCustomOption('aw_sarp_subscription_start', $date->toString('Y-MM-dd'));
if ($attributes = $buyRequest->getSuperAttribute()) {
$result = Mage_Catalog_Model_Product_Type_Abstract::prepareForCartAdvanced($buyRequest, $product);
if (is_array($result)) {
$product = $this->getProduct($product);
/**
* $attributes = array($attributeId=>$attributeValue)
*/
if ($subProduct = $this->getProductByAttributes($attributes, $product)) {
$product->addCustomOption('attributes', serialize($attributes));
$product->addCustomOption('product_qty_' . $subProduct->getId(), 1, $subProduct);
$product->addCustomOption('simple_product', $subProduct->getId(), $subProduct);
$_result = $subProduct->getTypeInstance(true)->prepareForCartAdvanced($buyRequest, $subProduct);
if (is_string($_result) && !is_array($_result)) {
return $_result;
}
if (!isset($_result[0])) {
return Mage::helper('checkout')->__('Can not add item to shopping cart');
}
/**
* Adding parent product custom options to child product
* to be sure that it will be unique as its parent
*/
if ($optionIds = $product->getCustomOption('option_ids')) {
$optionIds = explode(',', $optionIds->getValue());
foreach ($optionIds as $optionId) {
if ($option = $product->getCustomOption('option_' . $optionId)) {
$_result[0]->addCustomOption('option_' . $optionId, $option->getValue());
}
}
}
if ($buyRequest->getAwSarpSubscriptionType()) {
if ($Period->getId()) {
$_result[0]->addCustomOption('aw_sarp_subscription_start', $date->toString('Y-MM-dd'));
$_result[0]->addCustomOption('aw_sarp_subscription_type', $Period->getId());
}
}
$_result[0]->setParentProductId($product->getId())->addCustomOption('parent_product_id', $product->getId())->setCartQty(1);
$result[] = $_result[0];
return $result;
}
}
}
return $this->getSpecifyOptionMessage();
}
开发者ID:par-orillonsoft,项目名称:magento_work,代码行数:78,代码来源:Subscription.php
示例3: getOrderOptions
/**
* Prepare additional options/information for order item which will be
* created from this product
*
* @param Mage_Catalog_Model_Product $product
*
* @return array
*/
public function getOrderOptions($product = null)
{
$optionArr = parent::getOrderOptions($product);
$optionArr['shipment_type'] = Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY;
return $optionArr;
}
开发者ID:OpenMage,项目名称:OpenMage_KittedProduct,代码行数:14,代码来源:Type.php
示例4: _prepareProduct
/**
* Copied from Peets_Catalog_Model_Product_Type_Configurable
*
*/
protected function _prepareProduct(Varien_Object $buyRequest, $product, $processMode)
{
$attributes = $buyRequest->getSuperAttribute();
$isConfigurable = $product->getTypeId() == parent::TYPE_CODE;
if ($attributes || !$this->_isStrictProcessMode($processMode) || $isConfigurable) {
if (!$this->_isStrictProcessMode($processMode)) {
if (is_array($attributes)) {
foreach ($attributes as $key => $val) {
if (empty($val)) {
unset($attributes[$key]);
}
}
} else {
$attributes = array();
}
}
$result = Mage_Catalog_Model_Product_Type_Abstract::_prepareProduct($buyRequest, $product, $processMode);
if (is_array($result)) {
$product = $this->getProduct($product);
/**
* $attributes = array($attributeId=>$attributeValue)
*/
$subProduct = true;
if ($this->_isStrictProcessMode($processMode)) {
foreach ($this->getConfigurableAttributes($product) as $attributeItem) {
/* @var $attributeItem Varien_Object */
$attrId = $attributeItem->getData('attribute_id');
if (!isset($attributes[$attrId]) || empty($attributes[$attrId])) {
$subProduct = null;
break;
}
}
}
if ($subProduct) {
$subProduct = $this->getProductByAttributes($attributes, $product);
}
if ($subProduct) {
$product->addCustomOption('attributes', serialize($attributes));
$product->addCustomOption('product_qty_' . $subProduct->getId(), 1, $subProduct);
$product->addCustomOption('simple_product', $subProduct->getId(), $subProduct);
$_result = $subProduct->getTypeInstance(true)->_prepareProduct($buyRequest, $subProduct, $processMode);
if (is_string($_result) && !is_array($_result)) {
return $_result;
}
if (!isset($_result[0])) {
return Mage::helper('checkout')->__('Cannot add the item to shopping cart');
}
/**
* Adding parent product custom options to child product
* to be sure that it will be unique as its parent
*/
if ($optionIds = $product->getCustomOption('option_ids')) {
$optionIds = explode(',', $optionIds->getValue());
foreach ($optionIds as $optionId) {
if ($option = $product->getCustomOption('option_' . $optionId)) {
$_result[0]->addCustomOption('option_' . $optionId, $option->getValue());
}
}
}
$_result[0]->setParentProductId($product->getId())->addCustomOption('parent_product_id', $product->getId());
if ($this->_isStrictProcessMode($processMode)) {
$_result[0]->setCartQty(1);
}
$result[] = $_result[0];
return $result;
} else {
if (!$this->_isStrictProcessMode($processMode) || $isConfigurable) {
return $result;
}
}
}
}
return $this->getSpecifyOptionMessage();
}
开发者ID:xiaoguizhidao,项目名称:magento,代码行数:78,代码来源:Configurable.php
示例5: prepareForCart
public function prepareForCart(Varien_Object $buyRequest, $product = null)
{
if (!$product) {
$product = $this->getProduct();
}
return parent::prepareForCart($buyRequest, $product);
}
开发者ID:hueyl77,项目名称:fourwindsgear,代码行数:7,代码来源:Membershippackage.php
示例6: hasRequiredOptions
public function hasRequiredOptions($product = null)
{
if (ITwebexperts_Payperrentals_Helper_Data::isReservationAndRental($this->getProduct($product))) {
return false;
} else {
return parent::hasRequiredOptions($product);
}
}
开发者ID:hueyl77,项目名称:fourwindsgear,代码行数:8,代码来源:Reservation.php
示例7: _prepareProduct
/**
* Initialize gift card for add to cart process
*
* @param Varien_Object $buyRequest
* @param Mage_Catalog_Model_Product $product
* @return array|string
*/
protected function _prepareProduct(Varien_Object $buyRequest, $product, $processMode)
{
$product = $this->getProduct($product);
$data = $buyRequest->getData();
$cardType = $product->getAttributeText('wts_gc_type');
//change delivery date to mysql format
if (!empty($data['mail_delivery_date'])) {
$tempDate = explode('/', $data['mail_delivery_date']);
$mailDeliveryDate = $tempDate[2] . '-' . $tempDate[0] . '-' . $tempDate[1];
} else {
$mailDeliveryDate = null;
}
/*
* Validate card amount
* TODO: Need options validation
*/
if (!$product->getPrice() || $product->getPrice() == 0) {
// true only if min value is set (more than 0) and price less than min
$min = Mage::getStoreConfig('giftcards/default/min_card_value') > 0 && $data['card_amount'] < Mage::getStoreConfig('giftcards/default/min_card_value');
// true only if max value is set (more than 0) and price more than max
$max = Mage::getStoreConfig('giftcards/default/max_card_value') > 0 && $data['card_amount'] > Mage::getStoreConfig('giftcards/default/max_card_value');
// if one of conditions above is true than return error
if ($min || $max) {
return $this->getSpecifyPriceMessage();
}
}
/*
* Validate card type
* TODO: Need options validation
*/
/* if (!isset($data['card_type']) || !in_array($data['card_type'], array('email', 'print', 'offline'))) {
return $this->getSpecifyOptionsMessage();
}*/
/*
* Add gift card params as product custom options to product quote
* TODO: Need options validation
*/
$product->addCustomOption('card_type', $cardType);
$product->addCustomOption('card_amount', isset($data['card_amount']) ? $data['card_amount'] : $product->getPrice());
$product->addCustomOption('card_currency', Mage::app()->getStore()->getCurrentCurrencyCode());
$product->addCustomOption('mail_to', isset($data['mail_to']) ? $data['mail_to'] : '');
$product->addCustomOption('mail_to_email', isset($data['mail_to_email']) ? $data['mail_to_email'] : '');
$product->addCustomOption('mail_from', isset($data['mail_from']) ? $data['mail_from'] : '');
$product->addCustomOption('mail_message', isset($data['mail_message']) ? $data['mail_message'] : '');
$product->addCustomOption('offline_country', isset($data['offline_country']) ? $data['offline_country'] : '');
$product->addCustomOption('offline_state', isset($data['offline_state']) ? $data['offline_state'] : '');
$product->addCustomOption('offline_city', isset($data['offline_city']) ? $data['offline_city'] : '');
$product->addCustomOption('offline_street', isset($data['offline_street']) ? $data['offline_street'] : '');
$product->addCustomOption('offline_zip', isset($data['offline_zip']) ? $data['offline_zip'] : '');
$product->addCustomOption('offline_phone', isset($data['offline_phone']) ? $data['offline_phone'] : '');
$product->addCustomOption('mail_delivery_date', $mailDeliveryDate);
//delivery date of email
return parent::_prepareProduct($buyRequest, $product, $processMode);
}
开发者ID:bevello,项目名称:bevello,代码行数:61,代码来源:Giftcards.php
示例8: getOrderOptions
public function getOrderOptions($product = null)
{
$optionArr = parent::getOrderOptions($product);
if ($product->hasCustomOptions()) {
$src_option = $product->getCustomOption('src_option')->getValue();
$option['label'] = 'Personalized Image';
$option['value'] = "<img width='100' src='{$src_option}'>";
//// array order page not ok
$option['print_value'] = "<img width='100' src='{$src_option}'>";
$option['custom_view'] = "<img width='100' src='{$src_option}'>";
$optionArr['options'][] = $option;
}
return $optionArr;
}
开发者ID:brobie,项目名称:magento_scene7,代码行数:14,代码来源:Scene7.php
示例9: _prepareProduct
protected function _prepareProduct(Varien_Object $buyRequest, $product, $processMode)
{
if (version_compare(Mage::getVersion(), '1.5.0', '<')) {
return parent::_prepareProduct($buyRequest, $product, $processMode);
}
if (is_null($product)) {
$product = $this->getProduct();
}
$result = parent::_prepareProduct($buyRequest, $product, $processMode);
if (is_string($result)) {
return $result;
}
reset($result);
$product = current($result);
$result = $this->_prepareWebPOSProduct($buyRequest, $product);
return $result;
}
开发者ID:cabrerabywaters,项目名称:magentoSunshine,代码行数:17,代码来源:Type.php
示例10: _prepareProduct
protected function _prepareProduct(Varien_Object $buyRequest, $product, $processMode)
{
$product = $this->getProduct($product);
$servicePrice = (double) $buyRequest->getServicePrice();
$isStrictProcessMode = $this->_isStrictProcessMode($processMode);
if ($buyRequest->getQty() > 1) {
return Mage::helper('catalog')->__('The maximum qty of service product allowed in cart is 1.');
}
if (!$isStrictProcessMode || $servicePrice > 0) {
$maxPrice = Mage::helper('service_product')->getMaxPrice();
if ($maxPrice && $servicePrice > $maxPrice) {
return Mage::helper('catalog')->__('Service price must not be greater than %d.', $maxPrice);
}
$products = parent::_prepareProduct($buyRequest, $product, $processMode);
if (!isset($products[0])) {
return Mage::helper('checkout')->__('Cannot process the item.');
}
return $products;
}
return Mage::helper('catalog')->__('Please specify the product price.');
}
开发者ID:hanhpv,项目名称:service-product-type,代码行数:21,代码来源:Type.php
示例11: beforeSave
public function beforeSave($product = null)
{
parent::beforeSave($product);
$this->getProduct($product)->setTypeHasOptions(true);
$this->getProduct($product)->setTypeHasRequiredOptions(true);
return $this;
}
开发者ID:xiaoguizhidao,项目名称:extensiongsd,代码行数:7,代码来源:Giftcard.php
示例12: save
/**
* Save type related data
*
* @param Mage_Catalog_Model_Product $product
* @return Mage_Catalog_Model_Product_Type_Grouped
*/
public function save($product)
{
parent::save($product);
$product->getLinkInstance()->saveGroupedLinks($product);
return $this;
}
开发者ID:natxetee,项目名称:magento2,代码行数:12,代码来源:Grouped.php
示例13: checkProductBuyState
/**
* Check if product can be bought
*
* @param Mage_Catalog_Model_Product $product
* @return Mage_Bundle_Model_Product_Type
* @throws Mage_Core_Exception
*/
public function checkProductBuyState($product = null)
{
parent::checkProductBuyState($product);
$product = $this->getProduct($product);
$productOptionIds = $this->getOptionsIds($product);
$productSelections = $this->getSelectionsCollection($productOptionIds, $product);
$selectionIds = $product->getCustomOption('bundle_selection_ids');
$selectionIds = unserialize($selectionIds->getValue());
foreach ($selectionIds as $selectionId) {
/* @var $selection Mage_Bundle_Model_Selection */
$selection = $productSelections->getItemById($selectionId);
if (!$selection || !$selection->isSalable()) {
Mage::throwException(Mage::helper('bundle')->__('Selected required options are not available.'));
}
}
return $this;
}
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:24,代码来源:Type.php
示例14: save
/**
* Save configurable product depended data
*
* @return Mage_Catalog_Model_Product_Type_Configurable
*/
public function save()
{
parent::save();
/**
* Save Attributes Information
*/
if ($data = $this->getProduct()->getConfigurableAttributesData()) {
foreach ($data as $attributeData) {
$id = isset($attributeData['id']) ? $attributeData['id'] : null;
$attribute = Mage::getModel('catalog/product_type_configurable_attribute')->setData($attributeData)->setId($id)->setStoreId($this->getProduct()->getStoreId())->setProductId($this->getProduct()->getId())->save();
}
}
/**
* Save product relations
*/
if ($data = $this->getProduct()->getConfigurableProductsData()) {
$productIds = array_keys($data);
Mage::getResourceModel('catalog/product_type_configurable')->saveProducts($this->getProduct()->getId(), $productIds);
}
return $this;
}
开发者ID:arslbbt,项目名称:mangentovies,代码行数:26,代码来源:Configurable.php
示例15: isVirtual
/**
* Check is virtual product
*
* @return bool
*/
public function isVirtual($product = null)
{
if ($productOption = $this->getProduct($product)->getCustomOption('simple_product')) {
if ($optionProduct = $productOption->getProduct()) {
/* @var $optionProduct Mage_Catalog_Model_Product */
return $optionProduct->isVirtual();
}
}
return parent::isVirtual($product);
}
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:15,代码来源:Product_Type_Configurable.php
示例16: beforeSave
public function beforeSave($product = null)
{
parent::beforeSave($product);
if ($product->getAwSarpEnabled() && $this->getProduct($product)->getAwSarpSubscriptionPrice() == '') {
$this->getProduct($product)->setAwSarpSubscriptionPrice($product->getData('price'));
}
}
开发者ID:xiaoguizhidao,项目名称:mydigibits,代码行数:7,代码来源:Subscription.php
示例17: getSku
/**
* Get sku of product
*
* @param Mage_Catalog_Model_Product $product
* @return string
*/
public function getSku($product = null)
{
$sku = $this->getProduct($product)->getData('sku');
if ($simpleOption = $this->getProduct($product)->getCustomOption('simple_product')) {
//$simple_sku = $simpleOption->getProduct($product)->getSku();
$o = $simpleOption->getProduct($product);
$simple_sku = is_object($o) ? $o->getSku() : null;
$sku = parent::getOptionSku($product, $simple_sku);
} else {
$sku = parent::getSku($product);
}
return $sku;
}
开发者ID:rajarshc,项目名称:Rooja,代码行数:19,代码来源:Configurable.php
示例18: getSku
/**
* Get sku of product
*
* @param Mage_Catalog_Model_Product $product
* @return string
*/
public function getSku($product = null)
{
$sku = $this->getProduct($product)->getData('sku');
$simpleOption = $this->getProduct($product)->getCustomOption('simple_product');
if ($simpleOption) {
$optionProduct = $simpleOption->getProduct($product);
$simpleSku = null;
if ($optionProduct) {
$simpleSku = $simpleOption->getProduct($product)->getSku();
}
$sku = parent::getOptionSku($product, $simpleSku);
} else {
$sku = parent::getSku($product);
}
return $sku;
}
开发者ID:njaeger,项目名称:magento_github,代码行数:22,代码来源:Configurable.php
示例19: isSalable
public function isSalable($product = null)
{
if (!$product) {
return false;
}
$prod = Mage::getModel('catalog/product')->load($product->getId());
if ($prod->getAttributeText('wts_gc_pregenerate') != 'Yes') {
return parent::isSalable($product);
}
$collection = Mage::getModel('giftcards/pregenerated')->getCollection()->addFieldToFilter('product_id', $product->getId())->addFieldToFilter('card_status', 1);
if (!count($collection)) {
return false;
}
return true;
}
开发者ID:enjoy2000,项目名称:gemz,代码行数:15,代码来源:Giftcards.php
示例20: isVirtual
/**
* Check is virtual product
*
* @return bool
*/
public function isVirtual()
{
if ($productOption = $this->getProduct()->getCustomOption('simple_product')) {
if ($product = $productOption->getProduct()) {
/* @var $product Mage_Catalog_Model_Product */
return $product->getTypeInstance()->isVirtual();
}
}
return parent::isVirtual();
}
开发者ID:albertobraschi,项目名称:magento-design-training,代码行数:15,代码来源:Configurable.php
注:本文中的Mage_Catalog_Model_Product_Type_Abstract类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论