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


PHP Mage_Catalog_Model_Product_Option类代码示例

本文整理汇总了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类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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