本文整理汇总了PHP中Mage_Core_Model_Abstract::getFrontendLabel方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Abstract::getFrontendLabel方法的具体用法?PHP Mage_Core_Model_Abstract::getFrontendLabel怎么用?PHP Mage_Core_Model_Abstract::getFrontendLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Model_Abstract
的用法示例。
在下文中一共展示了Mage_Core_Model_Abstract::getFrontendLabel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _beforeSave
/**
* Set required fields before saving model
*
* @param Mage_Core_Model_Abstract $object
* @return $this
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getDisplayName()) {
if (!$object->getFrontendLabel()) {
throw new Exception(Mage::helper('attributeSplash')->__('Splash object must have a name'));
} else {
$object->setDisplayName($object->getFrontendLabel());
}
}
if ($object->getCategoryId()) {
$category = Mage::getModel('catalog/category')->load($object->getCategoryId());
if (!$category->getId()) {
$object->setCategoryId(null);
}
} else {
$object->setCategoryId(null);
}
if (!$object->getUrlKey()) {
$object->setUrlKey($object->getname());
}
$object->setUrlKey($this->formatUrlKey($object->getUrlKey()));
$object->setUpdatedAt(now());
if (!$object->getCreatedAt()) {
$object->setCreatedAt(now());
}
return parent::_beforeSave($object);
}
示例2: _beforeSave
/**
* Set required fields before saving model
*
* @param Mage_Core_Model_Abstract $object
* @return $this
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getDisplayName()) {
if (!$object->getFrontendLabel()) {
throw new Exception(Mage::helper('attributeSplash')->__('Splash object must have a name'));
} else {
$object->setDisplayName($object->getFrontendLabel());
}
}
if ($object->getCategoryId()) {
$category = Mage::getModel('catalog/category')->load($object->getCategoryId());
if (!$category->getId()) {
$object->setCategoryId(null);
}
} else {
$object->setCategoryId(null);
}
if (!$object->getUrlKey()) {
$object->setUrlKey($object->getname());
}
$object->setUrlKey($this->formatUrlKey($object->getUrlKey()));
$object->setUpdatedAt(now());
if (!$object->getCreatedAt()) {
$object->setCreatedAt(now());
}
if (is_array($object->getCustomFields())) {
$customFields = array();
foreach ($object->getCustomFields() as $field => $value) {
if (trim($value) !== '') {
$customFields[$field] = $value;
}
}
if (count($customFields) > 0) {
$object->setCustomFields(serialize($customFields));
} else {
$object->setCustomFIelds('');
}
}
return parent::_beforeSave($object);
}
示例3: _beforeSave
/**
* Validate attribute data before save
*
* @param Mage_Eav_Model_Entity_Attribute|Mage_Core_Model_Abstract $object
* @return Mage_Eav_Model_Resource_Entity_Attribute
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
$frontendLabel = $object->getFrontendLabel();
if (is_array($frontendLabel)) {
if (!isset($frontendLabel[0]) || is_null($frontendLabel[0]) || $frontendLabel[0] == '') {
Mage::throwException($this->_helper('Mage_Eav_Helper_Data')->__('Frontend label is not defined'));
}
$object->setFrontendLabel($frontendLabel[0])->setStoreLabels($frontendLabel);
}
/**
* @todo need use default source model of entity type !!!
*/
if (!$object->getId()) {
if ($object->getFrontendInput() == 'select') {
$object->setSourceModel('Mage_Eav_Model_Entity_Attribute_Source_Table');
}
}
return parent::_beforeSave($object);
}
示例4: loadFromAttribute
public function loadFromAttribute(Mage_Core_Model_Abstract $object, $attribute_code = null, $option_id = null, $store_id = null)
{
$read = $this->_getReadAdapter();
if ($read && !is_null($attribute_code)) {
$select = $read->select()->from(array('main_table' => $this->getMainTable()))->joinRight(array('aov' => $this->getTable('eav/attribute_option_value')), 'aov.option_id = main_table.attribute_option_id AND aov.store_id = main_table.attribute_value_store_id', array('value_id', 'value', 'store_id', 'option_id'))->join(array('ao' => $this->getTable('eav/attribute_option')), 'ao.option_id = aov.option_id', array())->join(array('a' => $this->getTable('eav/attribute')), 'a.attribute_id = ao.attribute_id', array('attribute_code', 'frontend_label'))->where('a.attribute_code = ?', $attribute_code)->where('ao.option_id = ?', $option_id)->where('aov.store_id in (0, ?)', $store_id)->order('aov.store_id DESC');
$data = $read->fetchRow($select);
if ($data) {
$object->setData($data);
//set the default values for the new info page, extracted from the attribute values
if (!$object->getData('name')) {
$object->setData('name', __('Products by %s: %s', $object->getFrontendLabel(), $object->getValue()));
}
if (!$object->getData('external_url_label')) {
$object->setData('external_url_label', __('Visit %s on the web', $object->getValue()));
}
if (!$object->getData('identifier')) {
$object->setData('identifier', $this->formatUrlKey($object->getValue()));
}
}
}
$this->_afterLoad($object);
return $this;
}
示例5: _beforeSave
/**
* Enter description here...
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Eav_Model_Mysql4_Entity_Attribute
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
$frontendLabel = $object->getFrontendLabel();
if (is_array($frontendLabel)) {
if (!isset($frontendLabel[0]) || is_null($frontendLabel[0]) || $frontendLabel[0] == '') {
AO::throwException(AO::helper('eav')->__('Frontend label is not defined'));
}
$object->setFrontendLabel($frontendLabel[0]);
if ($object->getData('modulePrefix')) {
$str = $object->getData('modulePrefix') . Mage_Core_Model_Translate::SCOPE_SEPARATOR . $frontendLabel[0];
} else {
$str = $frontendLabel[0];
}
AO::getModel('core/translate_string')->setString($str)->setTranslate($frontendLabel[0])->setStoreTranslations($frontendLabel)->save();
}
$applyTo = $object->getApplyTo();
if (is_array($applyTo)) {
$object->setApplyTo(implode(',', $applyTo));
}
/**
* @todo need use default source model of entity type !!!
*/
if (!$object->getId()) {
if ($object->getFrontendInput() == 'select') {
$object->setSourceModel('eav/entity_attribute_source_table');
}
}
return parent::_beforeSave($object);
}