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


PHP Mage_Core_Model_Abstract::getDefault方法代码示例

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


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

示例1: _saveOption

 /**
  * Save attribute options
  * Override to save image to attribute option
  *
  * @param Mage_Core_Model_Abstract $object
  * @return Mage_Eav_Model_Resource_Entity_Attribute
  * @version 1.7.0.2
  */
 protected function _saveOption(Mage_Core_Model_Abstract $object)
 {
     $option = $object->getOption();
     if (is_array($option)) {
         $adapter = $this->_getWriteAdapter();
         $optionTable = $this->getTable('eav/attribute_option');
         $optionValueTable = $this->getTable('eav/attribute_option_value');
         $stores = Mage::app()->getStores(true);
         if (isset($option['value'])) {
             $attributeDefaultValue = array();
             if (!is_array($object->getDefault())) {
                 $object->setDefault(array());
             }
             foreach ($option['value'] as $optionId => $values) {
                 $intOptionId = (int) $optionId;
                 if (!empty($option['delete'][$optionId])) {
                     if ($intOptionId) {
                         $adapter->delete($optionTable, array('option_id = ?' => $intOptionId));
                     }
                     continue;
                 }
                 $sortOrder = !empty($option['order'][$optionId]) ? $option['order'][$optionId] : 0;
                 $image = !empty($option['image'][$optionId]) ? $option['image'][$optionId] : null;
                 $thumb = !empty($option['thumb'][$optionId]) ? $option['thumb'][$optionId] : null;
                 if (!$intOptionId) {
                     $data = array('attribute_id' => $object->getId(), 'sort_order' => $sortOrder, 'image' => $image, 'thumb' => $thumb);
                     $adapter->insert($optionTable, $data);
                     $intOptionId = $adapter->lastInsertId($optionTable);
                 } else {
                     $data = array('sort_order' => $sortOrder, 'image' => $image, 'thumb' => $thumb);
                     $where = array('option_id =?' => $intOptionId);
                     $adapter->update($optionTable, $data, $where);
                 }
                 if (in_array($optionId, $object->getDefault())) {
                     if ($object->getFrontendInput() == 'multiselect') {
                         $attributeDefaultValue[] = $intOptionId;
                     } elseif ($object->getFrontendInput() == 'select') {
                         $attributeDefaultValue = array($intOptionId);
                     }
                 }
                 // Default value
                 if (!isset($values[0])) {
                     Mage::throwException(Mage::helper('eav')->__('Default option value is not defined'));
                 }
                 $adapter->delete($optionValueTable, array('option_id =?' => $intOptionId));
                 foreach ($stores as $store) {
                     if (isset($values[$store->getId()]) && (!empty($values[$store->getId()]) || $values[$store->getId()] == "0")) {
                         $data = array('option_id' => $intOptionId, 'store_id' => $store->getId(), 'value' => $values[$store->getId()]);
                         $adapter->insert($optionValueTable, $data);
                     }
                 }
             }
             $bind = array('default_value' => implode(',', $attributeDefaultValue));
             $where = array('attribute_id =?' => $object->getId());
             $adapter->update($this->getMainTable(), $bind, $where);
         }
     }
     return $this;
 }
开发者ID:dragontheme1235,项目名称:project-1,代码行数:67,代码来源:Attribute.php

示例2: _saveOption

 protected function _saveOption(Mage_Core_Model_Abstract $object)
 {
     $option = $object->getOption();
     if (is_array($option)) {
         $write = $this->_getWriteAdapter();
         $optionTable = $this->getTable('attribute_option');
         $optionValueTable = $this->getTable('attribute_option_value');
         $stores = Mage::getModel('core/store')->getResourceCollection()->setLoadDefault(true)->load();
         if (isset($option['value'])) {
             $attributeDefaultValue = array();
             if (!is_array($object->getDefault())) {
                 $object->setDefault(array());
             }
             foreach ($option['value'] as $optionId => $values) {
                 $intOptionId = (int) $optionId;
                 if (!empty($option['delete'][$optionId])) {
                     if ($intOptionId) {
                         $condition = $write->quoteInto('option_id=?', $intOptionId);
                         $write->delete($optionTable, $condition);
                     }
                     continue;
                 }
                 if (!$intOptionId) {
                     $data = array('attribute_id' => $object->getId(), 'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0, 'image' => isset($option['image'][$optionId]) ? $option['image'][$optionId] : '', 'thumb' => isset($option['thumb'][$optionId]) ? $option['thumb'][$optionId] : '');
                     $write->insert($optionTable, $data);
                     $intOptionId = $write->lastInsertId();
                 } else {
                     $data = array('sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0, 'image' => isset($option['image'][$optionId]) ? $option['image'][$optionId] : '', 'thumb' => isset($option['thumb'][$optionId]) ? $option['thumb'][$optionId] : '');
                     $write->update($optionTable, $data, $write->quoteInto('option_id=?', $intOptionId));
                 }
                 if (in_array($optionId, $object->getDefault())) {
                     if ($object->getFrontendInput() == 'multiselect') {
                         $attributeDefaultValue[] = $intOptionId;
                     } else {
                         if ($object->getFrontendInput() == 'select') {
                             $attributeDefaultValue = array($intOptionId);
                         }
                     }
                 }
                 // Default value
                 if (!isset($values[0])) {
                     Mage::throwException(Mage::helper('eav')->__('Default option value is not defined.'));
                 }
                 $write->delete($optionValueTable, $write->quoteInto('option_id=?', $intOptionId));
                 foreach ($stores as $store) {
                     if (isset($values[$store->getId()]) && (!empty($values[$store->getId()]) || $values[$store->getId()] == "0")) {
                         $data = array('option_id' => $intOptionId, 'store_id' => $store->getId(), 'value' => $values[$store->getId()]);
                         $write->insert($optionValueTable, $data);
                     }
                 }
             }
             $write->update($this->getMainTable(), array('default_value' => implode(',', $attributeDefaultValue)), $write->quoteInto($this->getIdFieldName() . '=?', $object->getId()));
         }
     }
     return $this;
 }
开发者ID:remiebeling,项目名称:JR_AttributeOptionImage,代码行数:56,代码来源:Attribute.php

示例3: _updateDefaultValue

 /**
  * Update attribute default value
  *
  * @param Mage_Eav_Model_Entity_Attribute|Mage_Core_Model_Abstract $object
  * @param int|string $optionId
  * @param int $intOptionId
  * @param array $defaultValue
  */
 protected function _updateDefaultValue($object, $optionId, $intOptionId, &$defaultValue)
 {
     if (in_array($optionId, $object->getDefault())) {
         $frontendInput = $object->getFrontendInput();
         if ($frontendInput === 'multiselect') {
             $defaultValue[] = $intOptionId;
         } elseif ($frontendInput === 'select') {
             $defaultValue = array($intOptionId);
         }
     }
 }
开发者ID:natxetee,项目名称:magento2,代码行数:19,代码来源:Attribute.php

示例4: _saveOption

 protected function _saveOption(Mage_Core_Model_Abstract $object)
 {
     $option = $object->getOption();
     if (is_array($option)) {
         $write = $this->_getWriteAdapter();
         $optionTable = $this->getTable('attribute_option');
         $optionValueTable = $this->getTable('attribute_option_value');
         $stores = Mage::getModel('core/store')->getResourceCollection()->setLoadDefault(true)->load();
         if (isset($option['value'])) {
             $attributeDefaultValue = array();
             if (!is_array($object->getDefault())) {
                 $object->setDefault(array());
             }
             foreach ($option['value'] as $optionId => $values) {
                 $intOptionId = (int) $optionId;
                 if (!empty($option['delete'][$optionId])) {
                     if ($intOptionId) {
                         $condition = $write->quoteInto('option_id=?', $intOptionId);
                         $write->delete($optionTable, $condition);
                     }
                     continue;
                 }
                 if (!$intOptionId) {
                     $data = array('attribute_id' => $object->getId(), 'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0);
                     $write->insert($optionTable, $data);
                     $intOptionId = $write->lastInsertId();
                 } else {
                     $data = array('sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0);
                     $write->update($optionTable, $data, $write->quoteInto('option_id=?', $intOptionId));
                 }
                 $attributeId = $object->getId();
                 $optionData = array();
                 if (isset($option['url_key'][$optionId])) {
                     $urlKey = preg_replace('/[^\\w]/ui', '', $option['url_key'][$optionId]);
                     $urlKey = trim($urlKey);
                     if ($urlKey) {
                         $optionData['url_key'] = $urlKey;
                     } else {
                         $optionData['url_key'] = trim(preg_replace('/[^\\w]/ui', '', strtolower($option['value'][$optionId][0])));
                     }
                     $optionExist = $write->fetchOne($write->select()->from(Mage::getSingleton('core/resource')->getTableName('ecommerceteam_sln/attribute'), 'attribute_id')->where('attribute_id != ? ', $attributeId)->where('url_key = ? ', $optionData['url_key']));
                     if ($optionExist) {
                         $optionData['url_key'] = $attributeId . '_' . $optionData['url_key'];
                     }
                 }
                 if (isset($option['remove_image'][$intOptionId])) {
                     $optionData['image'] = '';
                     $ioObject = new Varien_Io_File();
                     $targetDirectory = Mage::getBaseDir('media') . DS . 'catalog' . DS . 'attribute' . DS . $attributeId . DS . $intOptionId;
                     $ioObject->rmdir($targetDirectory, true);
                 }
                 if (isset($option['image'][$optionId])) {
                     $imageInfo = Mage::helper('core')->jsonDecode($option['image'][$optionId]);
                     if (is_array($imageInfo)) {
                         //$imageInfo = array_shift($imageInfo);
                         if (!empty($imageInfo) && isset($imageInfo['status']) && $imageInfo['status'] == 'new') {
                             $image = Mage::helper('ecommerceteam_sln')->moveImageFromTemp($imageInfo['file'], $attributeId, $intOptionId);
                             $optionData['image'] = $image;
                         }
                     }
                 }
                 if (!empty($optionData)) {
                     $optionData['attribute_id'] = $attributeId;
                     $optionData['option_id'] = $intOptionId;
                     $table = Mage::getSingleton('core/resource')->getTableName('ecommerceteam_sln/attribute');
                     $write->insertOnDuplicate($table, $optionData);
                 }
                 if (in_array($optionId, $object->getDefault())) {
                     if ($object->getFrontendInput() == 'multiselect') {
                         $attributeDefaultValue[] = $intOptionId;
                     } else {
                         if ($object->getFrontendInput() == 'select') {
                             $attributeDefaultValue = array($intOptionId);
                         }
                     }
                 }
                 // Default value
                 if (!isset($values[0])) {
                     Mage::throwException(Mage::helper('eav')->__('Default option value is not defined.'));
                 }
                 $write->delete($optionValueTable, $write->quoteInto('option_id=?', $intOptionId));
                 foreach ($stores as $store) {
                     if (isset($values[$store->getId()]) && (!empty($values[$store->getId()]) || $values[$store->getId()] == "0")) {
                         $data = array('option_id' => $intOptionId, 'store_id' => $store->getId(), 'value' => $values[$store->getId()]);
                         $write->insert($optionValueTable, $data);
                     }
                 }
             }
             $write->update($this->getMainTable(), array('default_value' => implode(',', $attributeDefaultValue)), $write->quoteInto($this->getIdFieldName() . '=?', $object->getId()));
         }
     }
     return $this;
 }
开发者ID:xiaoguizhidao,项目名称:devfashion,代码行数:93,代码来源:Attribute.php

示例5: _saveOption

 protected function _saveOption(Mage_Core_Model_Abstract $object)
 {
     $option = $object->getOption();
     $swatchOnLayeredEnabled = Mage::helper('weltpixel_productswatch')->isColorSwatchEnabledOnLayeredNavigation();
     $swatchOnProductEnabled = Mage::helper('weltpixel_layerednavigation')->isColorSwatchEnabledOnProduct();
     if (is_array($option)) {
         $adapter = $this->_getWriteAdapter();
         $optionTable = $this->getTable('eav/attribute_option');
         $optionValueTable = $this->getTable('eav/attribute_option_value');
         $stores = Mage::app()->getStores(true);
         if (isset($option['value'])) {
             $attributeDefaultValue = array();
             if (!is_array($object->getDefault())) {
                 $object->setDefault(array());
             }
             foreach ($option['value'] as $optionId => $values) {
                 $intOptionId = (int) $optionId;
                 if (!empty($option['delete'][$optionId])) {
                     if ($intOptionId) {
                         $adapter->delete($optionTable, array('option_id = ?' => $intOptionId));
                         if ($swatchOnProductEnabled) {
                             Mage::helper('weltpixel_productswatch/image')->clearCache($object->getId(), $intOptionId);
                         }
                         if ($swatchOnLayeredEnabled) {
                             Mage::helper('weltpixel_layerednavigation/image')->clearCache($object->getId(), $intOptionId);
                         }
                     }
                     continue;
                 }
                 $sortOrder = !empty($option['order'][$optionId]) ? $option['order'][$optionId] : 0;
                 /**
                  * Customization - adding image options
                  */
                 $navigationImage = !empty($option['navigation_image'][$optionId]) ? $option['navigation_image'][$optionId] : '';
                 $productImage = !empty($option['product_image'][$optionId]) ? $option['product_image'][$optionId] : '';
                 if (!$intOptionId) {
                     $data = array('attribute_id' => $object->getId(), 'sort_order' => $sortOrder);
                     if ($swatchOnProductEnabled) {
                         $data['product_image'] = $productImage;
                     }
                     if ($swatchOnLayeredEnabled) {
                         $data['navigation_image'] = $navigationImage;
                     }
                     $adapter->insert($optionTable, $data);
                     $intOptionId = $adapter->lastInsertId($optionTable);
                     if ($swatchOnProductEnabled) {
                         Mage::helper('weltpixel_productswatch/image')->clearCache($object->getId(), $intOptionId);
                     }
                     if ($swatchOnLayeredEnabled) {
                         Mage::helper('weltpixel_layerednavigation/image')->clearCache($object->getId(), $intOptionId);
                     }
                 } else {
                     $data = array('sort_order' => $sortOrder);
                     if ($swatchOnProductEnabled) {
                         $data['product_image'] = $productImage;
                     }
                     if ($swatchOnLayeredEnabled) {
                         $data['navigation_image'] = $navigationImage;
                     }
                     $where = array('option_id =?' => $intOptionId);
                     $wasThereUpdate = $adapter->update($optionTable, $data, $where);
                     if ($wasThereUpdate) {
                         ///delete swatch images
                         if ($swatchOnProductEnabled) {
                             Mage::helper('weltpixel_productswatch/image')->clearCache($object->getId(), $intOptionId);
                         }
                         if ($swatchOnLayeredEnabled) {
                             Mage::helper('weltpixel_layerednavigation/image')->clearCache($object->getId(), $intOptionId);
                         }
                     }
                 }
                 /**
                  * End Of Customization - adding image options
                  */
                 if (in_array($optionId, $object->getDefault())) {
                     if ($object->getFrontendInput() == 'multiselect') {
                         $attributeDefaultValue[] = $intOptionId;
                     } elseif ($object->getFrontendInput() == 'select') {
                         $attributeDefaultValue = array($intOptionId);
                     }
                 }
                 // Default value
                 if (!isset($values[0])) {
                     Mage::throwException(Mage::helper('eav')->__('Default option value is not defined'));
                 }
                 $adapter->delete($optionValueTable, array('option_id =?' => $intOptionId));
                 foreach ($stores as $store) {
                     if (isset($values[$store->getId()]) && (!empty($values[$store->getId()]) || $values[$store->getId()] == "0")) {
                         $data = array('option_id' => $intOptionId, 'store_id' => $store->getId(), 'value' => $values[$store->getId()]);
                         $adapter->insert($optionValueTable, $data);
                     }
                 }
             }
             $bind = array('default_value' => implode(',', $attributeDefaultValue));
             $where = array('attribute_id =?' => $object->getId());
             $adapter->update($this->getMainTable(), $bind, $where);
         }
     }
     return $this;
 }
开发者ID:aayushKhandpur,项目名称:aayush-renting,代码行数:100,代码来源:Attribute.php

示例6: _saveOption

 protected function _saveOption(Mage_Core_Model_Abstract $object)
 {
     $option = $object->getOption();
     if (is_array($option)) {
         $write = $this->_getWriteAdapter();
         $optionTable = $this->getTable('attribute_option');
         $optionValueTable = $this->getTable('attribute_option_value');
         $stores = Mage::getModel('core/store')->getResourceCollection()->setLoadDefault(true)->load();
         if (isset($option['value'])) {
             $attributeDefaultValue = array();
             if (!is_array($object->getDefault())) {
                 $object->setDefault(array());
             }
             foreach ($option['value'] as $optionId => $values) {
                 $intOptionId = (int) $optionId;
                 if (!empty($option['delete'][$optionId])) {
                     if ($intOptionId) {
                         $condition = $write->quoteInto('option_id=?', $intOptionId);
                         $write->delete($optionTable, $condition);
                     }
                     continue;
                 }
                 if (!$intOptionId) {
                     $data = array('attribute_id' => $object->getId(), 'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0);
                     $write->insert($optionTable, $data);
                     $intOptionId = $write->lastInsertId();
                 } else {
                     $data = array('sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0);
                     $write->update($optionTable, $data, $write->quoteInto('option_id=?', $intOptionId));
                 }
                 $attribute_id = $object->getId();
                 $table = Mage::getSingleton('core/resource')->getTableName('gomage_navigation_attribute_option');
                 $connection = $this->_getReadAdapter();
                 if (isset($option['remove_image'][$intOptionId]) && $option['remove_image'][$intOptionId] > 0) {
                     $connection->query("DELETE FROM {$table} WHERE `attribute_id` = {$attribute_id} AND `option_id` = {$intOptionId}; ");
                 }
                 if (isset($option['image'][$optionId])) {
                     $imageInfo = Zend_Json::decode($option['image'][$optionId]);
                     if (isset($imageInfo[0])) {
                         $imageInfo = $imageInfo[0];
                     } else {
                         $imageInfo = null;
                     }
                     if (!empty($imageInfo) && isset($imageInfo['status']) && $imageInfo['status'] == 'new') {
                         $image = Mage::getSingleton('gomage_navigation/observer')->moveImageFromTmp($imageInfo['file']);
                         $name = $imageInfo['name'];
                         $size = (double) $imageInfo['size'];
                         if ($connection->fetchOne("SELECT COUNT(*) FROM {$table} WHERE `attribute_id` = {$attribute_id} AND `option_id` = {$intOptionId};") > 0) {
                             $connection->query("UPDATE {$table} SET `filename` = '{$image}', `name` = '{$name}', `size` = {$size} WHERE `attribute_id` = {$attribute_id} AND `option_id` = {$intOptionId}; ");
                         } else {
                             $connection->query("INSERT INTO {$table} VALUES ({$attribute_id},{$intOptionId},'{$image}','{$name}',{$size});");
                         }
                     }
                 }
                 if (in_array($optionId, $object->getDefault())) {
                     if ($object->getFrontendInput() == 'multiselect') {
                         $attributeDefaultValue[] = $intOptionId;
                     } else {
                         if ($object->getFrontendInput() == 'select') {
                             $attributeDefaultValue = array($intOptionId);
                         }
                     }
                 }
                 // Default value
                 if (!isset($values[0])) {
                     Mage::throwException(Mage::helper('eav')->__('Default option value is not defined.'));
                 }
                 $write->delete($optionValueTable, $write->quoteInto('option_id=?', $intOptionId));
                 foreach ($stores as $store) {
                     if (isset($values[$store->getId()]) && (!empty($values[$store->getId()]) || $values[$store->getId()] == "0")) {
                         $data = array('option_id' => $intOptionId, 'store_id' => $store->getId(), 'value' => $values[$store->getId()]);
                         $write->insert($optionValueTable, $data);
                     }
                 }
             }
             $write->update($this->getMainTable(), array('default_value' => implode(',', $attributeDefaultValue)), $write->quoteInto($this->getIdFieldName() . '=?', $object->getId()));
         }
     }
     return $this;
 }
开发者ID:evinw,项目名称:project_bloom_magento,代码行数:80,代码来源:Attribute.php


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