當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。