• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Mage_Catalog_Model_Product_Option类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getOptionHtml

 /**
  * Get option html block
  *
  * @param Mage_Catalog_Model_Product_Option $option
  *
  * @return string
  */
 public function getOptionHtml(Mage_Catalog_Model_Product_Option $option)
 {
     $renderer = $this->getOptionRender($this->getGroupOfOption($option->getType()));
     if (is_null($renderer['renderer'])) {
         $renderer['renderer'] = $this->getLayout()->createBlock($renderer['block'])->setTemplate($renderer['template'])->setSkipJsReloadPrice(1);
     }
     return $renderer['renderer']->setProduct($this->getProduct())->setOption($option)->toHtml();
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:15,代码来源:Options.php


示例2: getProductCount

 public function getProductCount()
 {
     $product = new Mage_Catalog_Model_Product_Option();
     $collection = $product->getCollection()->addFieldToFilter('type', array('eq' => 'aitcustomer_image'));
     $collection->getSelect()->group('product_id');
     $collection->load();
     return $collection->count();
 }
开发者ID:Eximagen,项目名称:BulletMagento,代码行数:8,代码来源:License.php


示例3: getOptionHtml

 public function getOptionHtml(Mage_Catalog_Model_Product_Option $option)
 {
     $type = $option->getType();
     if (empty($type)) {
         return;
     }
     return parent::getOptionHtml($option);
 }
开发者ID:aamir-zz,项目名称:magento-configurable-simple,代码行数:8,代码来源:Options.php


示例4: isOptionAffectingPrice

 /**
  * Returns true if final price of product depends on given option
  * 
  * @param Mage_Catalog_Model_Product_Option $option
  * @return boolean
  */
 public function isOptionAffectingPrice(Mage_Catalog_Model_Product_Option $option)
 {
     foreach ($option->getValuesCollection() as $value) {
         /* @var $value Mage_Catalog_Model_Product_Option_Value */
         if ($value->getPrice() * 1 > 0) {
             return true;
         }
     }
     return false;
 }
开发者ID:helirexi,项目名称:EditCustomOptions,代码行数:16,代码来源:Data.php


示例5: getOptionHtml

 /**
  * Get option html
  *
  * @param Mage_Catalog_Model_Product_Option $option
  * @return string
  */
 public function getOptionHtml($option)
 {
     if (!isset($this->_optionRenderers[$option->getType()])) {
         return $this->__('There is no defined renderer for "%s" option type.', $option->getType());
     }
     $html = $this->getLayout()->createBlock($this->_optionRenderers[$option->getType()])->setOption($option)->setProduct($this->getProduct())->toHtml();
     $html = str_replace('bundle.changeSelection(this)', 'return;', $html);
     $html = str_replace('name="bundle_option[', 'name="cart[' . $this->getItem()->getId() . '][bundle_option][', $html);
     $html = str_replace('name="bundle_option_qty[', 'name="cart[' . $this->getItem()->getId() . '][bundle_option_qty][', $html);
     return $html;
 }
开发者ID:booklein,项目名称:bookle,代码行数:17,代码来源:Bundle.php


示例6: duplicate

 /**
  * Duplicate custom options for product
  *
  * @param Mage_Catalog_Model_Product_Option $object
  * @param int $oldProductId
  * @param int $newProductId
  * @return Mage_Catalog_Model_Product_Option
  */
 public function duplicate(Mage_Catalog_Model_Product_Option $object, $oldProductId, $newProductId)
 {
     $write = $this->_getWriteAdapter();
     $read = $this->_getReadAdapter();
     $optionsCond = array();
     $optionsData = array();
     // read and prepare original product options
     $select = $read->select()->from($this->getTable('catalog/product_option'))->where('product_id=?', $oldProductId);
     $query = $read->query($select);
     while ($row = $query->fetch()) {
         $optionsData[$row['option_id']] = $row;
         $optionsData[$row['option_id']]['product_id'] = $newProductId;
         unset($optionsData[$row['option_id']]['option_id']);
     }
     // insert options to duplicated product
     foreach ($optionsData as $oId => $data) {
         $write->insert($this->getMainTable(), $data);
         $optionsCond[$oId] = $write->lastInsertId();
     }
     // copy options prefs
     foreach ($optionsCond as $oldOptionId => $newOptionId) {
         // title
         $table = $this->getTable('catalog/product_option_title');
         $sql = 'REPLACE INTO `' . $table . '` ' . 'SELECT NULL, ' . $newOptionId . ', `store_id`, `title`' . 'FROM `' . $table . '` WHERE `option_id`=' . $oldOptionId;
         $this->_getWriteAdapter()->query($sql);
         // price
         $table = $this->getTable('catalog/product_option_price');
         $sql = 'REPLACE INTO `' . $table . '` ' . 'SELECT NULL, ' . $newOptionId . ', `store_id`, `price`, `price_type`' . 'FROM `' . $table . '` WHERE `option_id`=' . $oldOptionId;
         $this->_getWriteAdapter()->query($sql);
         // description
         $table = $this->getTable('customoptiondescription/product_option_description');
         $sql = 'REPLACE INTO `' . $table . '` ' . 'SELECT NULL, ' . $newOptionId . ', `store_id`, `description`' . 'FROM `' . $table . '` WHERE `option_id`=' . $oldOptionId;
         $this->_getWriteAdapter()->query($sql);
         $object->getValueInstance()->duplicate($oldOptionId, $newOptionId);
     }
     return $object;
 }
开发者ID:xiaoguizhidao,项目名称:BumblebeeSite,代码行数:45,代码来源:Option.php


示例7: duplicate

 /**
  * Duplicate custom options for product
  *
  * @param Mage_Catalog_Model_Product_Option $object
  * @param int $oldProductId
  * @param int $newProductId
  * @return Mage_Catalog_Model_Product_Option
  */
 public function duplicate(Mage_Catalog_Model_Product_Option $object, $oldProductId, $newProductId)
 {
     $write = $this->_getWriteAdapter();
     $read = $this->_getReadAdapter();
     $optionsCond = array();
     $optionsData = array();
     // read and prepare original product options
     $select = $read->select()->from($this->getTable('catalog/product_option'))->where('product_id = ?', $oldProductId);
     $query = $read->query($select);
     while ($row = $query->fetch()) {
         $optionsData[$row['option_id']] = $row;
         $optionsData[$row['option_id']]['product_id'] = $newProductId;
         unset($optionsData[$row['option_id']]['option_id']);
     }
     // insert options to duplicated product
     foreach ($optionsData as $oId => $data) {
         $write->insert($this->getMainTable(), $data);
         $optionsCond[$oId] = $write->lastInsertId($this->getMainTable());
     }
     // copy options prefs
     foreach ($optionsCond as $oldOptionId => $newOptionId) {
         // title
         $table = $this->getTable('catalog/product_option_title');
         $select = $this->_getReadAdapter()->select()->from($table, array(new Zend_Db_Expr($newOptionId), 'store_id', 'title'))->where('option_id = ?', $oldOptionId);
         $insertSelect = $write->insertFromSelect($select, $table, array('option_id', 'store_id', 'title'), Varien_Db_Adapter_Interface::INSERT_ON_DUPLICATE);
         $write->query($insertSelect);
         // price
         $table = $this->getTable('catalog/product_option_price');
         $select = $read->select()->from($table, array(new Zend_Db_Expr($newOptionId), 'store_id', 'price', 'price_type'))->where('option_id = ?', $oldOptionId);
         $insertSelect = $write->insertFromSelect($select, $table, array('option_id', 'store_id', 'price', 'price_type'), Varien_Db_Adapter_Interface::INSERT_ON_DUPLICATE);
         $write->query($insertSelect);
         $object->getValueInstance()->duplicate($oldOptionId, $newOptionId);
     }
     return $object;
 }
开发者ID:cewolf2002,项目名称:magento,代码行数:43,代码来源:Option.php


示例8: getValuesCollection

 /**
  * Enter description here...
  *
  * @param Mage_Catalog_Model_Product_Option $option
  * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Option_Value_Collection
  */
 public function getValuesCollection(Mage_Catalog_Model_Product_Option $option)
 {
     $collection = Mage::getResourceModel('catalog/product_option_value_collection')->addFieldToFilter('option_id', $option->getId())->getValues($option->getStoreId());
     return $collection;
 }
开发者ID:okite11,项目名称:frames21,代码行数:11,代码来源:Value.php


示例9: saveOptions

 /**
  * Save options.
  *
  * @return Mage_Catalog_Model_Product_Option
  */
 public function saveOptions()
 {
     /* {#AITOC_COMMENT_END#}
              Mage::app()->removeCache('aitsys_used_product_count_aitcg_count');
              
              if($this->getProduct()->getData('status') == Mage_Catalog_Model_Product_Status::STATUS_ENABLED) {
                 
                 $bHasAitOption = false;
                 $updateOptions = array();
                 foreach ($this->getOptions() as $iKey => $aOption)
                 {
                     if( Mage::helper('aitcg/options')->checkAitOption( $aOption ) ) {
                         if($aOption['option_id'] == 0) {
                             $bHasAitOption = true;
                             break;
                         }
                         $updateOptions[ $aOption['option_id'] ] = $aOption['is_delete'];
                     }
                 }
     
                 if($bHasAitOption == false) {
                     foreach ($this->getProduct()->getOptions() as $iKey => $aOption)
                     {
                         if(Mage::helper('aitcg/options')->checkAitOption( $aOption )) {
                             if(!isset($updateOptions[ $aOption->getId() ]) || $updateOptions[ $aOption->getId() ]!=1) {
                                 $bHasAitOption = true;
                                 break;
                             }
                         }
                     }
                 }
     
                 if($bHasAitOption) {
                     $performer = Aitoc_Aitsys_Abstract_Service::get()->platform()->getModule('Aitoc_Aitcg')->getLicense()->getPerformer();
                     $ruler = $performer->getRuler();
                     $ruler->checkRuleAdd($this->getProduct(), true);
                 }
     
                 
             }
             {#AITOC_COMMENT_START#} */
     parent::saveOptions();
 }
开发者ID:Eximagen,项目名称:BulletMagento,代码行数:48,代码来源:Option.php


示例10: testOptionApi

 /**
  * @covers Mage_Catalog_Model_Product::addOption
  * @covers Mage_Catalog_Model_Product::getOptionById
  * @covers Mage_Catalog_Model_Product::getOptions
  */
 public function testOptionApi()
 {
     $this->assertEquals(array(), $this->_model->getOptions());
     $optionId = uniqid();
     $option = new Mage_Catalog_Model_Product_Option(array('key' => 'value'));
     $option->setId($optionId);
     $this->_model->addOption($option);
     $this->assertSame($option, $this->_model->getOptionById($optionId));
     $this->assertEquals(array($optionId => $option), $this->_model->getOptions());
 }
开发者ID:relue,项目名称:magento2,代码行数:15,代码来源:ProductExternalTest.php


示例11: _getCustomOptionValuesPrices

 /**
  * Get all custom option values prices
  *
  * @param Mage_Catalog_Model_Product_Option $option
  * @return array
  */
 protected function _getCustomOptionValuesPrices($option)
 {
     $values = $option->getValues();
     $prices = array();
     if ($values) {
         foreach ($values as $value) {
             /* @var $value Mage_Catalog_Model_Product_Option_Value */
             $prices[] = $value->getPrice(true);
         }
     }
     return $prices;
 }
开发者ID:hyhoocchan,项目名称:mage-local,代码行数:18,代码来源:Price.php


示例12: _isOptionMultiple

 /**
  * Check whether specified option could have multiple values
  *
  * @param Mage_Catalog_Model_Product_Option $option
  * @return bool
  */
 protected function _isOptionMultiple($option)
 {
     switch ($option->getType()) {
         case Mage_Catalog_Model_Product_Option::OPTION_TYPE_MULTIPLE:
         case Mage_Catalog_Model_Product_Option::OPTION_TYPE_CHECKBOX:
             return true;
     }
     return false;
 }
开发者ID:hazaeluz,项目名称:magento_connect,代码行数:15,代码来源:Cart.php


示例13: _uploadPhoto

 /**
  *
  * @param string $filename
  * @param resource $image
  * @param Mage_Catalog_Model_Product_Option $option
  */
 protected function _uploadPhoto($filename, $image, $option)
 {
     $result = array();
     $optionFile = $option->groupFactory($option->getType());
     $extension = pathinfo(strtolower($filename), PATHINFO_EXTENSION);
     $filename = Mage_Core_Model_File_Uploader::getCorrectFileName($filename);
     $dispersion = Mage_Core_Model_File_Uploader::getDispretionPath($filename);
     $quoteDir = $optionFile->getQuoteTargetDir() . $dispersion;
     $uploadDir = Mage::helper('aydus_customconfigurable')->getMediaDir() . DS . $dispersion;
     if (!file_exists($quoteDir)) {
         mkdir($quoteDir, 0775, true);
     }
     if (!file_exists($uploadDir)) {
         mkdir($uploadDir, 0775, true);
     }
     $hash = md5($image);
     $filenameHash = $hash . '.' . $extension;
     $quoteFilePath = $quoteDir . DS . $filenameHash;
     $size = file_put_contents($quoteFilePath, $image);
     $result['error'] = $size > 0 ? false : true;
     if ($result['error']) {
         $result['data'] = 'File upload failed';
     } else {
         $time = time();
         $uploadFilePath = $uploadDir . DS . $time . '-' . $filename;
         if (copy($quoteFilePath, $uploadFilePath)) {
             $result['data'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'aydus' . DS . 'customconfigurable' . $dispersion . DS . $time . '-' . $filename;
         } else {
             $result['error'] = true;
             $result['data'] = 'Could not copy uploaded image to ' . $uploadFilePath . '; check permissions';
         }
     }
     return $result;
 }
开发者ID:zhangjiachao,项目名称:CustomConfigurable,代码行数:40,代码来源:Customconfigurable.php


示例14: addOption

 /**
  * Add option to array of product options
  *
  * @param Mage_Catalog_Model_Product_Option $option
  * @return Mage_Catalog_Model_Product
  */
 public function addOption(Mage_Catalog_Model_Product_Option $option)
 {
     $this->_options[$option->getId()] = $option;
     return $this;
 }
开发者ID:cewolf2002,项目名称:magento,代码行数:11,代码来源:Product.php


示例15: _getOptionValues

 /**
  * Retrieve option values or false for options which has no values
  *
  * @param Mage_Catalog_Model_Product_Option $option
  * @return array|bool
  */
 protected function _getOptionValues(Mage_Catalog_Model_Product_Option $option)
 {
     $values = $option->getValues();
     if (!empty($values)) {
         $result = array();
         /** @var $value Mage_Catalog_Model_Product_Option_Value */
         foreach ($values as $value) {
             $optionData = array();
             foreach ($this->_assertOptionValues as $assertKey) {
                 if ($value->hasData($assertKey)) {
                     $optionData[$assertKey] = $value->getData($assertKey);
                 }
             }
             $result[] = $optionData;
         }
         return $result;
     }
     return false;
 }
开发者ID:nemphys,项目名称:magento2,代码行数:25,代码来源:ProductTest.php


示例16: getOptionHtml

 /**
  * Get option html
  *
  * @param Mage_Catalog_Model_Product_Option $option
  * @return string
  */
 public function getOptionHtml($option)
 {
     if (!isset($this->_optionRenderers[$option->getType()])) {
         return $this->__('There is no defined renderer for "%s" option type.', $option->getType());
     }
     return $this->getLayout()->createBlock($this->_optionRenderers[$option->getType()])->setOption($option)->toHtml();
 }
开发者ID:quyip8818,项目名称:Mag,代码行数:13,代码来源:Bundle.php


示例17: groupFactory

 public function groupFactory($type)
 {
     //if (!Mage::helper('giftcard')->isActive())
     //    return parent::groupFactory($type);
     if ($type === self::OPTION_TYPE_GIFT_CARD_VALUE) {
         return Mage::getModel('giftcard/catalog_product_option_type_giftcardvalue');
     }
     return parent::groupFactory($type);
 }
开发者ID:ahsanmage,项目名称:vr,代码行数:9,代码来源:Option.php


示例18: getGroupByType

 /**
  * Get group name of option by given option type
  *
  * @param string $type
  * @return string
  */
 public function getGroupByType($type = null)
 {
     if (is_null($type)) {
         $type = $this->getType();
     }
     $swatch_id = str_replace(self::OPTION_GROUP_SWATCH . '_', '', $type);
     $swatch = Mage::getModel('swatches/input')->load($swatch_id);
     if ($swatch && $swatch->getSwatchId()) {
         return self::OPTION_GROUP_SWATCH;
     }
     return parent::getGroupByType($type);
 }
开发者ID:BBFMedia,项目名称:Ip_Swatches,代码行数:18,代码来源:Option.php


示例19: _afterSave

 protected function _afterSave()
 {
     if (!Mage::helper('customoptions')->isEnabled() || Mage::app()->getRequest()->getControllerName() != 'catalog_product' && Mage::app()->getRequest()->getControllerName() != 'adminhtml_catalog_product') {
         return parent::_afterSave();
     }
     $optionId = $this->getData('option_id');
     $defaultArray = $this->getData('default') ? $this->getData('default') : array();
     $tablePrefix = (string) Mage::getConfig()->getTablePrefix();
     $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
     $helper = Mage::helper('customoptions');
     $storeId = $this->getProduct()->getStoreId();
     if (is_array($this->getData('values'))) {
         $values = array();
         foreach ($this->getData('values') as $key => $value) {
             if (isset($value['option_type_id'])) {
                 if (isset($value['dependent_ids']) && $value['dependent_ids'] != '') {
                     $dependentIds = array();
                     $dependentIdsTmp = explode(',', $value['dependent_ids']);
                     foreach ($dependentIdsTmp as $d_id) {
                         if ($this->decodeViewIGI($d_id) > 0) {
                             $dependentIds[] = $this->decodeViewIGI($d_id);
                         }
                     }
                     $value['dependent_ids'] = implode(',', $dependentIds);
                 }
                 $value['sku'] = trim($value['sku']);
                 // prepare customoptions_qty
                 $customoptionsQty = '';
                 if (isset($value['customoptions_qty']) && (!$helper->isSkuQtyLinkingEnabled() || $helper->getProductIdBySku($value['sku']) == 0)) {
                     $customoptionsQty = strtolower(trim($value['customoptions_qty']));
                     if (substr($customoptionsQty, 0, 1) != 'x' && substr($customoptionsQty, 0, 1) != 'i' && substr($customoptionsQty, 0, 1) != 'l' && !is_numeric($customoptionsQty)) {
                         $customoptionsQty = '';
                     }
                     if (is_numeric($customoptionsQty)) {
                         $customoptionsQty = intval($customoptionsQty);
                     }
                     if (substr($customoptionsQty, 0, 1) == 'i') {
                         $customoptionsQty = $this->decodeViewIGI($customoptionsQty);
                     }
                 }
                 $optionValue = array('option_id' => $optionId, 'sku' => $value['sku'], 'sort_order' => $value['sort_order'], 'customoptions_qty' => $customoptionsQty, 'default' => array_search($key, $defaultArray) !== false ? 1 : 0, 'in_group_id' => $value['in_group_id']);
                 if (isset($value['dependent_ids'])) {
                     $optionValue['dependent_ids'] = $value['dependent_ids'];
                 }
                 if (isset($value['weight'])) {
                     $optionValue['weight'] = $value['weight'];
                 }
                 if (isset($value['cost'])) {
                     $optionValue['cost'] = $value['cost'];
                 }
                 $optionTypePriceId = 0;
                 if ($helper->isSkuNameLinkingEnabled() && (!isset($value['scope']['title']) || $value['scope']['title'] != 1) && (!isset($value['title']) || $value['title'] == '') && $value['sku']) {
                     $value['title'] = $helper->getProductNameBySku($value['sku'], $storeId);
                 }
                 if (isset($value['option_type_id']) && $value['option_type_id'] > 0) {
                     $optionTypeId = $value['option_type_id'];
                     if ($value['is_delete'] == '1') {
                         $connection->delete($tablePrefix . 'catalog_product_option_type_value', 'option_type_id = ' . $optionTypeId);
                         $helper->deleteOptionFile(null, $optionId, $optionTypeId);
                     } else {
                         $connection->update($tablePrefix . 'catalog_product_option_type_value', $optionValue, 'option_type_id = ' . $optionTypeId);
                         // update or insert price
                         $select = $connection->select()->from($tablePrefix . 'catalog_product_option_type_price', array('option_type_price_id'))->where('option_type_id = ' . $optionTypeId . ' AND `store_id` = ' . $storeId);
                         $optionTypePriceId = $isUpdate = $connection->fetchOne($select);
                         if (isset($value['price']) && isset($value['price_type'])) {
                             $priceValue = array('price' => $value['price'], 'price_type' => $value['price_type']);
                             if ($isUpdate) {
                                 $connection->update($tablePrefix . 'catalog_product_option_type_price', $priceValue, 'option_type_id = ' . $optionTypeId . ' AND `store_id` = ' . $storeId);
                             } else {
                                 $priceValue['option_type_id'] = $optionTypeId;
                                 $priceValue['store_id'] = $storeId;
                                 $connection->insert($tablePrefix . 'catalog_product_option_type_price', $priceValue);
                                 $optionTypePriceId = $connection->lastInsertId($tablePrefix . 'catalog_product_option_type_price');
                             }
                         } elseif (isset($value['scope']['price']) && $value['scope']['price'] == 1 && $isUpdate && $storeId > 0) {
                             $connection->delete($tablePrefix . 'catalog_product_option_type_price', 'option_type_id = ' . $optionTypeId . ' AND `store_id` = ' . $storeId);
                             $optionTypePriceId = -1;
                         }
                         // update or insert title
                         if ($storeId > 0) {
                             $select = $connection->select()->from($tablePrefix . 'catalog_product_option_type_title', array('COUNT(*)'))->where('option_type_id = ' . $optionTypeId . ' AND `store_id` = ' . $storeId);
                             $isUpdate = $connection->fetchOne($select);
                         } else {
                             $isUpdate = 1;
                         }
                         if (isset($value['title'])) {
                             if ($isUpdate) {
                                 $connection->update($tablePrefix . 'catalog_product_option_type_title', array('title' => $value['title']), 'option_type_id = ' . $optionTypeId . ' AND `store_id` = ' . $storeId);
                             } else {
                                 $connection->insert($tablePrefix . 'catalog_product_option_type_title', array('option_type_id' => $optionTypeId, 'store_id' => $storeId, 'title' => $value['title']));
                             }
                         } elseif (isset($value['scope']['title']) && $value['scope']['title'] == 1 && $isUpdate && $storeId > 0) {
                             $connection->delete($tablePrefix . 'catalog_product_option_type_title', 'option_type_id = ' . $optionTypeId . ' AND `store_id` = ' . $storeId);
                         }
                         // update or insert description
                         if (isset($value['description']) || isset($value['scope']['description'])) {
                             $select = $connection->select()->from($tablePrefix . 'custom_options_option_type_description', array('COUNT(*)'))->where('option_type_id = ' . $optionTypeId . ' AND `store_id` = ' . $storeId);
                             $isUpdate = $connection->fetchOne($select);
                         }
                         if (isset($value['description']) && $value['description'] != '') {
//.........这里部分代码省略.........
开发者ID:xiaoguizhidao,项目名称:cupboardglasspipes.ecomitize.com,代码行数:101,代码来源:Option.php


示例20: getProductOptionCollection

 public function getProductOptionCollection(Mage_Catalog_Model_Product $product)
 {
     $action = Mage::app()->getFrontController()->getAction()->getFullActionName();
     if ($action == "catalog_category_view") {
         return parent::getProductOptionCollection($product);
     }
     $helper = Mage::helper('mageworx_customoptions');
     $collection = $this->getCollection()->addFieldToFilter('product_id', $product->getId())->addTitleToResult($product->getStoreId())->addPriceToResult($product->getStoreId())->addViewModeToResult($product->getStoreId())->addDescriptionToResult($product->getStoreId())->addDefaultTextToResult($product->getStoreId())->setOrder('sort_order', 'asc')->setOrder('title', 'asc');
     $isProductEditPage = Mage::app()->getStore()->isAdmin() && Mage::app()->getRequest()->getControllerName() == 'catalog_product';
     if ($isProductEditPage) {
         $collection->addTemplateTitleToResult();
     }
     $collection->addValuesToResult($product->getStoreId());
     if (!$isProductEditPage) {
         // filter by view_mode
         $isRequire = false;
         foreach ($collection as $key => $item) {
             // 0-Disable, 1-Visible, 2-Hidden, 3-Backend, 4-Admin Only
             if ($item->getViewMode() == 0 && !is_null($item->getViewMode())) {
                 $collection->removeItemByKey($key);
             } elseif (!Mage::app()->getStore()->isAdmin() && ($item->getViewMode() == 3 || $item->getViewMode() == 4)) {
                 $collection->removeItemByKey($key);
             } elseif ($item->getIsRequire(true)) {
                 $isRequire = true;
             }
         }
         if (!$isRequire) {
             $product->setRequiredOptions(0);
         }
         if (count($collection) == 0) {
             $product->setHasOptions(0);
         }
         $customerGroupId = $helper->getCustomerGroupId();
         // filter by CustomerGroups
         if ($helper->isCustomerGroupsEnabled()) {
             $isRequire = false;
             foreach ($collection as $key => $item) {
                 $groups = $item->getCustomerGroups();
                 if ($groups !== '' && !in_array($customerGroupId, explode(',', $groups))) {
                     $collection->removeItemByKey($key);
                 } elseif ($item->getIsRequire(true)) {
                     $isRequire = true;
                 }
             }
             if (!$isRequire) {
                 $product->setRequiredOptions(0);
             }
             if (count($collection) == 0) {
                 $product->setHasOptions(0);
             }
         }
         $storeViewId = Mage::app()->getStore()->getId();
         // filter by StoreViews
         if ($helper->isStoreViewsEnabled()) {
             $isRequire = false;
             foreach ($collection as $key => $item) {
                 $storeViews = $item->getStoreViews();
                 if ($storeViews !== '' && !in_array($storeViewId, explode(',', $storeViews))) {
                     $collection->removeItemByKey($key);
                 } elseif ($item->getIsRequire(true)) {
                     $isRequire = true;
                 }
             }
             if (!$isRequire) {
                 $product->setRequiredOptions(0);
             }
             if (count($collection) == 0) {
                 $product->setHasOptions(0);
             }
         }
         // recheck inventory
         if ($product->getRequiredOptions()) {
             if ($helper->isInventoryEnabled() && ($helper->getOutOfStockOptions() == 1 || $helper->isSetProductOutOfStock())) {
                 $isDependentEnabled = $helper->isDependentEnabled();
                 // checkDependentInventory for parent -> set parent option "Out of stock"
                 if ($isDependentEnabled) {
                     foreach ($collection as $option) {
                         if ($this->getGroupByType($option->getType()) != self::OPTION_GROUP_SELECT || count($option->getValues()) == 0) {
                             continue;
                         }
                         foreach ($option->getValues() as $value) {
                             if (!$value->getDependentIds()) {
                                 continue;
                             }
                             $customoptionsQty = $helper->getCustomoptionsQty($value->getCustomoptionsQty(), $value->getSku(), $product->getId(), $value->getExtra(), $value);
                             if ($customoptionsQty !== 0 && !$this->checkDependentInventory($collection, $value, $product)) {
                                 $value->setCustomoptionsQty(0);
                             }
                         }
                     }
                 }
                 // if all required options "Out of stock" -> set product "Out of stock"
                 foreach ($collection as $option) {
                     if (!$option->getIsRequire(true) || $isDependentEnabled && $option->getIsDependent() || $this->getGroupByType($option->getType()) != self::OPTION_GROUP_SELECT || count($option->getValues()) == 0) {
                         continue;
                     }
                     $outOfStockFlag = true;
                     foreach ($option->getValues() as $value) {
                         $customoptionsQty = $helper->getCustomoptionsQty($value->getCustomoptionsQty(), $value->getSku(), $product->getId(), $value->getExtra(), $value);
                         if (is_numeric($customoptionsQty) && $customoptionsQty != 0) {
//.........这里部分代码省略.........
开发者ID:Eximagen,项目名称:pfizer,代码行数:101,代码来源:Option.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Mage_Catalog_Model_Product_Type类代码示例发布时间:2022-05-23
下一篇:
PHP Mage_Catalog_Model_Product类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap