本文整理汇总了PHP中Mage_Core_Model_Config_Data类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Config_Data类的具体用法?PHP Mage_Core_Model_Config_Data怎么用?PHP Mage_Core_Model_Config_Data使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Core_Model_Config_Data类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkConfigUnique
/**
* @param Mage_Core_Model_Config_Data $object
* @return Mage_Core_Model_Config_Data
*/
protected function checkConfigUnique(Mage_Core_Model_Config_Data $object)
{
/** @var $collection Mage_Core_Model_Mysql4_Config_Data_Collection | Mage_Core_Model_Resource_Config_Data_Collection */
$collection = $this->getFactory()->getModelCoreConfigData()->getCollection();
$collection->addFieldToFilter('scope', $object->getScope());
$collection->addFieldToFilter('scope_id', $object->getScopeId());
$collection->addFieldToFilter('path', $object->getPath());
$collection->load();
if ($collection->count() > 0) {
/** @var $config Mage_Core_Model_Config_Data */
$config = $collection->getFirstItem();
$object->setId($config->getId());
}
return $object;
}
示例2: save
public function save()
{
$enabled = $this->getValue();
//get the value from our config
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$writeConnection = $resource->getConnection('core_write');
//die($enabled);
$query = 'SELECT attribute_id FROM eav_attribute WHERE `attribute_code` = \'telephone\'';
$attribute_id = $readConnection->fetchOne($query);
$query = 'UPDATE eav_attribute SET `is_required` = \'' . $enabled . '\' WHERE `attribute_code` = \'telephone\'';
$writeConnection->query($query);
if ($enabled == 1) {
$validationRules = 'a:2:{s:15:"max_text_length";i:255;s:15:"min_text_length";i:1;}';
$query = 'UPDATE customer_eav_attribute SET `validate_rules` = \'' . $validationRules . '\' WHERE `attribute_id` = \'' . $attribute_id . '\'';
$writeConnection->query($query);
} else {
$query = 'UPDATE customer_eav_attribute SET `validate_rules` = NULL WHERE `attribute_id` = \'' . $attribute_id . '\'';
$writeConnection->query($query);
}
//die($attribute_id);
return parent::save();
//call original save method so whatever happened
//before still happens (the value saves)
}
示例3: save
/**
* Check request for errors found by Helper and Observer. It will print error messages if errors found and
* in that case set value to 0.
*
* @return FACTFinder_Core_Model_System_Config_Backend_Enabled
*/
public function save()
{
parent::save();
Mage::app()->cleanCache();
$this->_checkConfiguration();
return $this;
}
示例4: _beforeSave
protected function _beforeSave()
{
$value = $this->getValue();
if (is_array($value)) {
unset($value['$ROW']);
$rHlp = Mage::getResourceSingleton('udropship/helper');
$conn = $rHlp->getWriteConnection();
$dtTable = $rHlp->getTable('udtiership/delivery_type');
$fieldsData = $rHlp->myPrepareDataForTable($dtTable, array(), true);
$fields = array_keys($fieldsData);
$existing = $rHlp->loadDbColumns(Mage::getModel('udtiership/deliveryType'), true, $fields);
$insert = array();
foreach ($value as $v) {
if (empty($v['delivery_title'])) {
continue;
}
if (!empty($v['delivery_type_id'])) {
unset($existing[$v['delivery_type_id']]);
} else {
$v['delivery_type_id'] = null;
}
$insert[] = $rHlp->myPrepareDataForTable($dtTable, $v, true);
}
if (!empty($insert)) {
$rHlp->multiInsertOnDuplicate($dtTable, $insert);
}
if (!empty($existing)) {
$conn->delete($dtTable, array('delivery_type_id in (?)' => array_keys($existing)));
}
}
$this->setValue('');
return parent::_beforeSave();
}
示例5: _afterload
protected function _afterload()
{
if (!is_array($this->getValue())) {
$this->setValue(explode(",", $this->getValue()));
}
return parent::_afterload();
}
示例6: _afterSave
/**
* Cleanup blocks HTML cache if value has been changed
*
* @return Enterprise_WebsiteRestriction_Model_System_Config_Backend_Active
*/
protected function _afterSave()
{
if ($this->isValueChanged()) {
Mage::dispatchEvent('clean_cache_by_tags', array('tags' => array(Mage_Core_Model_Store::CACHE_TAG, Mage_Cms_Model_Block::CACHE_TAG)));
}
return parent::_afterSave();
}
示例7: _beforeSave
/**
* Clean the project code of unicode characters.
*
* @return Mage_Core_Model_Abstract|void
*/
protected function _beforeSave()
{
$script = $this->getValue();
$script = preg_replace('/[^(\\x20-\\x7F)]*/', '', $script);
$this->setValue($script);
return parent::_beforeSave();
}
示例8: _beforeSave
/**
* Checks to see if we have a new and valid Site Id Checksum Entered
* @return self
*/
protected function _beforeSave()
{
$helper = Mage::helper('eems_display');
// We need this helper several times herein
$newChecksum = $this->getValue();
list($oldHash, $oldSiteId) = $helper->splitSiteIdChecksumField($this->getOldValue());
if (empty($newChecksum) && empty($oldHash)) {
// If both old and new checksums are still empty, prompt with some help info.
$this->_dataSaveAllowed = false;
Mage::getSingleton(self::SESSION_KEY)->addWarning('Please note that tracking is not enabled. Site Id Checksum is empty. ' . self::CONTACT_INFO);
return $this;
}
$storeId = $helper->getStoreIdForCurrentAdminScope();
$formFields = $this->getFieldsetData();
$newSiteId = $formFields['site_id'];
// Not allowed to change the Checksum unless we previously had a hash and we are changing the Site Id
if (!empty($oldHash) && $oldSiteId === $newSiteId) {
$this->_dataSaveAllowed = false;
return $this;
}
// Check that the value provided in newCheckSum matches what we calculate for ourHash.
$url = parse_url($helper->getProductFeedUrl($storeId), PHP_URL_HOST);
$ourHash = md5($newSiteId . $url);
if ($ourHash === $newChecksum) {
// Upon success, we save the hash and the newSiteId. In the frontend at runtime,
// we just have make sure that the siteId matches the runtime siteId
$this->setValue($newChecksum . self::FIELD_SEP . $newSiteId);
parent::_beforeSave();
} else {
$this->setValue(self::FIELD_SEP);
Mage::getSingleton(self::SESSION_KEY)->addError('Failed to validate the Site Id. ' . self::CONTACT_INFO);
}
return $this;
}
示例9: _beforeSave
/**
* Processing object before save data
*
* @return Mage_Core_Model_Abstract
*/
protected function _beforeSave()
{
$path = $this->getPath();
$realpath = str_replace('-', '/', array_pop(explode('/', $path)));
$this->_saveConfigData($realpath, $this->getValue());
parent::_beforeSave();
}
示例10: save
/**
* Perform API call to Amazon to validate Client ID/Secret
*
*/
public function save()
{
$data = $this->getFieldsetData();
$isEnabled = $this->getValue();
if ($data['client_id'] && $data['client_secret']) {
$_api = Mage::getModel('amazon_login/api');
// REST API params
$params = array('grant_type' => 'authorization_code', 'code' => 'SplxlOBeZQQYbYS6WxSbIA', 'client_id' => trim($data['client_id']), 'client_secret' => trim($data['client_secret']));
$response = $_api->request('auth/o2/token', $params);
if (!$response) {
Mage::getSingleton('core/session')->addError('Error: Unable to perform HTTP request to Amazon API.');
} else {
if ($response && isset($response['error'])) {
if ($response['error'] == 'invalid_client') {
Mage::getSingleton('core/session')->addError('Client authentication failed. Please verify your Client ID and Client Secret.');
$this->setValue(0);
// Set "Enabled" to "No"
} else {
Mage::getSingleton('core/session')->addSuccess('Successfully connected to Amazon API with Client ID and Client Secret.');
}
}
}
}
return parent::save();
}
示例11: _beforeSave
/**
* Validate minimum product qty value
*
* @return Mage_CatalogInventory_Model_System_Config_Backend_Minqty
*/
protected function _beforeSave()
{
parent::_beforeSave();
$minQty = (int) $this->getValue() >= 0 ? (int) $this->getValue() : (int) $this->getOldValue();
$this->setValue((string) $minQty);
return $this;
}
示例12: _afterSave
protected function _afterSave()
{
if ($this->isValueChanged()) {
Mage::getModel('enterprise_giftcardaccount/pool')->cleanupFree();
}
parent::_afterSave();
}
示例13: _afterLoad
/**
* if we dont' have a value yet retrieve a starting value from
* the default config xml configuration
*
* @return Fooman_PdfCustomiser_Model_Backend_Pdftotal
*/
protected function _afterLoad()
{
if ($this->getValue() == '') {
$this->setValue((string) Mage::getConfig()->getNode($this->_getGlobalConfigPath()));
}
return parent::_afterLoad();
}
示例14: save
public function save()
{
$fdata = array();
foreach ($this->groups['account']['fields'] as $name => $field) {
$fdata[$name] = $field['value'];
}
if ($fdata['embed']) {
$obj = json_decode($fdata['embed']);
$fdata['embed'] = $obj->embed;
$fdata['guid'] = $obj->guid;
}
include_once dirname(__FILE__) . '/JustunoAccess.php';
$params = array('apiKey' => JUSTUNO_KEY, 'email' => $fdata['email'], 'domain' => $fdata['domain'], 'guid' => $fdata['guid']);
if ($fdata['password']) {
$params['password'] = $fdata['password'];
}
$jAccess = new JustunoAccess($params);
try {
$justuno = $jAccess->getWidgetConfig();
$jusdata = array();
$jusdata['dashboard'] = (string) $jAccess->getDashboardLink();
$jusdata['guid'] = (string) $justuno['guid'];
$jusdata['embed'] = (string) $justuno['embed'];
$this->setValue((string) json_encode($jusdata));
} catch (JustunoAccessException $e) {
Mage::throwException($e->getMessage());
}
return parent::save();
}
示例15: _beforeSave
/**
* @return Bronto_Common_Model_System_Config_Backend_Token
*/
protected function _beforeSave()
{
$commonHelper = Mage::helper('bronto_common');
$value = $this->getValue();
if (!empty($value)) {
if ($commonHelper->validApiToken($value) === false) {
// reset the verified status
Mage::helper('bronto_verify/apitoken')->setStatus(Mage::helper('bronto_verify/apitoken')->getPath('token_status'), '2', $this->getScope(), $this->getScopeId());
Mage::throwException($commonHelper->__('The Bronto API Token you have entered appears to be invalid.'));
}
// reset the verified status
Mage::helper('bronto_verify/apitoken')->setStatus(Mage::helper('bronto_verify/apitoken')->getPath('token_status'), '1', $this->getScope(), $this->getScopeId());
// Enable Common Module
Mage::getModel('core/config_data')->load(Bronto_Common_Helper_Data::XML_PATH_ENABLED, 'path')->setValue(1)->setPath(Bronto_Common_Helper_Data::XML_PATH_ENABLED)->setScope($this->getScope())->setScopeId($this->getScopeId())->save();
// API key is new and doesn't match existing API key
$currentApiKey = $commonHelper->getApiToken();
if (!empty($currentApiKey) && $currentApiKey !== $value) {
Mage::getSingleton('adminhtml/session')->addNotice($commonHelper->__('You have changed your Bronto API Token so all Bronto modules have been disabled for this configuration scope.' . '<br />Please proceed to each module and reconfigure all available options to avoid undesired behavior.'));
$this->_disableAndUnlink();
}
} else {
Mage::getSingleton('adminhtml/session')->addNotice($commonHelper->__('You have removed your Bronto API Token so all Bronto modules have been disabled for this configuration scope.'));
// reset the verified status
Mage::helper('bronto_verify/apitoken')->setStatus(Mage::helper('bronto_verify/apitoken')->getPath('token_status'), '0', $this->getScope(), $this->getScopeId());
$this->_disableAndUnlink(true);
}
return parent::_beforeSave();
}