本文整理汇总了PHP中Mage_Catalog_Model_Abstract::getData方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Abstract::getData方法的具体用法?PHP Mage_Catalog_Model_Abstract::getData怎么用?PHP Mage_Catalog_Model_Abstract::getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Abstract
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Abstract::getData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterSave
/**
* After Save Attribute manipulation
*
* @param Mage_Catalog_Model_Abstract $object
* @return $this
*/
public function afterSave($object)
{
// var_dump($object);exit;
$hasChanges = $object->dataHasChangedFor($this->getAttribute()->getName());
if (!$hasChanges) {
return $this;
}
$data = $object->getData($this->getAttribute()->getName());
return $this;
}
示例2: testUnsetData
public function testUnsetData()
{
$data = array('key1' => 'value1', 'key2' => 'value2');
$this->_model->setData($data);
// unset one locked
$this->_model->lockAttribute('key1')->unsetData('key1');
$this->assertEquals($data, $this->_model->getData());
// unset all with read only
$this->_model->setIsReadonly(true)->unsetData();
$this->assertEquals($data, $this->_model->getData());
// unset all
$this->_model->unlockAttributes()->setIsReadonly(false)->unsetData();
$this->assertEquals(array(), $this->_model->getData());
}
示例3: _generateNextUrlKeySuffix
/**
* Generate unique url key if current url key already occupied
*
* @param Mage_Catalog_Model_Abstract $object
* @return Mage_Catalog_Model_Abstract
*/
protected function _generateNextUrlKeySuffix(Mage_Catalog_Model_Abstract $object)
{
$prefixValue = $object->getData($this->getAttribute()->getAttributeCode());
$requestPathField = new Zend_Db_Expr($this->_connection->quoteIdentifier('value'));
//select increment part of request path and cast expression to integer
$urlIncrementPartExpression = $this->_eavHelper->getCastToIntExpression($this->_connection->getSubstringSql($requestPathField, strlen($prefixValue) + 1, $this->_connection->getLengthSql($requestPathField) . ' - ' . strlen($prefixValue)));
$prefixRegexp = preg_quote($prefixValue);
$orCondition = $this->_connection->select()->orWhere($this->_connection->prepareSqlCondition('value', array('regexp' => '^' . $prefixRegexp . '$')))->orWhere($this->_connection->prepareSqlCondition('value', array('regexp' => '^' . $prefixRegexp . '-[0-9]*$')))->getPart(Zend_Db_Select::WHERE);
$select = $this->_connection->select();
$select->from($this->getAttribute()->getBackendTable(), new Zend_Db_Expr('MAX(ABS(' . $urlIncrementPartExpression . '))'))->where('value LIKE :url_key')->where('entity_id <> :entity_id')->where(implode('', $orCondition));
$bind = array('url_key' => $prefixValue . '%', 'entity_id' => (int) $object->getId());
$suffix = $this->_connection->fetchOne($select, $bind);
if (!is_null($suffix)) {
$suffix = (int) $suffix;
$object->setData($this->getAttribute()->getAttributeCode(), sprintf('%s-%s', $prefixValue, ++$suffix));
}
return $object;
}
示例4: isEntityVisible
public function isEntityVisible(Mage_Catalog_Model_Abstract $entity, $customerGroupId = null)
{
// if the module is deactivated or a store view all entities are visible
if (!$this->isModuleActive($entity->getStoreId())) {
return true;
}
$cachedState = $entity->getData(self::HIDE_GROUPS_ATTRIBUTE_STATE_CACHE);
if (!is_null($cachedState)) {
return $cachedState;
}
// Default to the current customer group id
if (is_null($customerGroupId)) {
$customerGroupId = $this->getCustomerGroupId();
}
$groupIds = $entity->getData(self::HIDE_GROUPS_ATTRIBUTE);
if (!is_array($groupIds) && !is_string($groupIds)) {
// If the value isn't set on the entity mode fall back to querying the db index table
$visibility = Mage::getResourceSingleton('netzarbeiter_groupscatalog2/filter')->isEntityVisible($entity, $customerGroupId);
$entity->setData(self::HIDE_GROUPS_ATTRIBUTE_STATE_CACHE, $visibility);
return $visibility;
}
/* @var $entityType string The entity type code for the specified entity */
$entityType = $this->getEntityTypeCodeFromEntity($entity);
if (is_string($groupIds)) {
if ('' === $groupIds) {
// This case will not happen in production:
// at least USE_DEFAULT or USE_NONE should be in the value array.
// Just your average paranoia...
$groupIds = array();
} else {
$groupIds = explode(',', $groupIds);
}
}
if (in_array(self::USE_NONE, $groupIds)) {
$groupIds = array();
} elseif (in_array(self::USE_DEFAULT, $groupIds)) {
// Get the default settings for this entity type without applying the mode settings
$groupIds = $this->getEntityVisibleDefaultGroupIds($entityType, $entity->getStore(), false);
}
// If the configured mode is 'show' the list of group ids must be inverse
$groupIds = $this->applyConfigModeSettingByStore($groupIds, $entityType, $entity->getStore());
$visibility = in_array($customerGroupId, $groupIds);
$entity->setData(self::HIDE_GROUPS_ATTRIBUTE_STATE_CACHE, $visibility);
return $visibility;
}
示例5: _lockAttributes
/**
* Lock the attributes of a product/category so that it can not be overwritten using Magento's backend.
* @param Mage_Catalog_Model_Abstract $model
*/
protected function _lockAttributes(Mage_Catalog_Model_Abstract $model)
{
// Is product assigned to import profile.
if (!($profiles = $model->getData('ho_import_profile'))) {
return;
}
foreach ($profiles as $profileData) {
$profile = $profileData['profile'];
// Is lock attributes functionality enabled.
$lockAttributes = sprintf('global/ho_import/%s/import_options/lock_attributes', $profile);
$fieldMapNode = Mage::getConfig()->getNode($lockAttributes);
if (!$fieldMapNode || !$fieldMapNode->asArray()) {
continue;
}
// Get the mapper.
/** @var Ho_Import_Model_Mapper $mapper */
$mapper = Mage::getModel('ho_import/mapper');
$mapper->setProfileName($profile);
$storeCode = $model->getStore()->getCode();
// Check if attributes need to be locked.
$attributes = $model->getAttributes();
foreach ($attributes as $attribute) {
/** @var Mage_Catalog_Model_Resource_Eav_Attribute $attribute */
$mapper->setStoreCode($attribute->isScopeStore() || $attribute->isScopeWebsite() ? $storeCode : 'admin');
$fieldConfig = $mapper->getFieldConfig($attribute->getAttributeCode());
if (isset($fieldConfig['@'])) {
$this->_lockAttribute($attribute, $model, $profile);
}
}
}
}