本文整理汇总了PHP中Mage_Catalog_Model_Product_Option::saveOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Product_Option::saveOptions方法的具体用法?PHP Mage_Catalog_Model_Product_Option::saveOptions怎么用?PHP Mage_Catalog_Model_Product_Option::saveOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Product_Option
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Product_Option::saveOptions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveOptions
public function saveOptions()
{
$helper = Mage::helper('customoptions');
if (!$helper->isEnabled() || Mage::app()->getRequest()->getControllerName() != 'catalog_product' && Mage::app()->getRequest()->getControllerName() != 'adminhtml_catalog_product') {
return parent::saveOptions();
}
$options = $this->getOptions();
$post = Mage::app()->getRequest()->getPost();
$productId = $this->getProduct()->getId();
$storeId = $this->getProduct()->getStoreId();
// bug magento fix
if ($storeId > 0 && isset($post['copy_to_stores'][$storeId]) && $post['copy_to_stores'][$storeId] == 0) {
return $this;
}
$relation = Mage::getSingleton('customoptions/relation');
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
$tablePrefix = (string) Mage::getConfig()->getTablePrefix();
if (isset($post['image_delete'])) {
$productOption = Mage::getModel('catalog/product_option');
foreach ($post['image_delete'] as $optionId) {
$connection->update($tablePrefix . 'catalog_product_option', array('image_path' => ''), 'option_id = ' . intval($optionId));
$helper->deleteOptionFile(null, $optionId, false);
}
}
foreach ($options as $option) {
if (isset($option['option_id'])) {
$connection->update($tablePrefix . 'catalog_product_option_type_value', array('default' => 0), 'option_id = ' . $option['option_id']);
if (isset($option['default'])) {
foreach ($option['default'] as $value) {
$connection->update($tablePrefix . 'catalog_product_option_type_value', array('default' => 1), 'option_type_id = ' . $value);
}
}
}
}
if ($helper->isCustomerGroupsEnabled()) {
$options = $this->getOptions();
foreach ($options as $key => $option) {
if (isset($option['customer_groups'])) {
$options[$key]['customer_groups'] = implode(',', $option['customer_groups']);
}
}
$this->setOptions($options);
}
if ($helper->isStoreViewsEnabled()) {
$options = $this->getOptions();
foreach ($options as $key => $option) {
if (isset($option['store_views'])) {
$options[$key]['store_views'] = implode(',', $option['store_views']);
}
}
$this->setOptions($options);
}
// qnty_input, exclude_first_image
$options = $this->getOptions();
foreach ($options as $key => $option) {
if (!isset($option['qnty_input']) || $this->getGroupByType($option['type']) != self::OPTION_GROUP_SELECT || $option['type'] == 'multiple' || $option['type'] == 'hidden') {
$options[$key]['qnty_input'] = 0;
}
if (!isset($option['exclude_first_image']) || $this->getGroupByType($option['type']) != self::OPTION_GROUP_SELECT) {
$options[$key]['exclude_first_image'] = 0;
}
if ($helper->isSkuNameLinkingEnabled() && (!isset($option['scope']['title']) || $option['scope']['title'] != 1) && (!isset($option['title']) || $option['title'] == '') && $this->getGroupByType($option['type']) != self::OPTION_GROUP_SELECT && $option['sku']) {
$options[$key]['title'] = $helper->getProductNameBySku($option['sku'], $storeId);
}
}
$this->setOptions($options);
// original code m1510 parent::saveOptions();
foreach ($this->getOptions() as $option) {
$this->setData($option)->setData('product_id', $productId)->setData('store_id', $storeId);
if ($this->getData('option_id') == '0') {
$this->unsetData('option_id');
} else {
$this->setId($this->getData('option_id'));
}
$isEdit = (bool) $this->getId() ? true : false;
if ($this->getData('is_delete') == '1') {
if ($isEdit) {
$this->getValueInstance()->deleteValue($this->getId());
$this->deletePrices($this->getId());
$this->deleteTitles($this->getId());
$this->delete();
$helper->deleteOptionFile(null, $this->getId(), false);
}
} else {
if ($this->getData('previous_type') != '') {
$previousType = $this->getData('previous_type');
//if previous option has dfferent group from one is came now need to remove all data of previous group
if ($this->getGroupByType($previousType) != $this->getGroupByType($this->getData('type'))) {
switch ($this->getGroupByType($previousType)) {
case self::OPTION_GROUP_SELECT:
$this->unsetData('values');
if ($isEdit) {
$this->getValueInstance()->deleteValue($this->getId());
}
break;
case self::OPTION_GROUP_FILE:
$this->setData('file_extension', '');
$this->setData('image_size_x', '0');
$this->setData('image_size_y', '0');
break;
//.........这里部分代码省略.........
示例2: 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();
}