本文整理汇总了PHP中Mage_Catalog_Model_Abstract类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Abstract类的具体用法?PHP Mage_Catalog_Model_Abstract怎么用?PHP Mage_Catalog_Model_Abstract使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Catalog_Model_Abstract类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: _saveAttributeValue
/**
* Insert or Update attribute data
*
* @param Mage_Catalog_Model_Abstract $object
* @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
* @param mixed $value
* @return Mage_Catalog_Model_Resource_Abstract
*/
protected function _saveAttributeValue($object, $attribute, $value)
{
$write = $this->_getWriteAdapter();
//set default store id
$storeId = Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID;
$table = $attribute->getBackend()->getTable();
/**
* If we work in single store mode all values should be saved just
* for default store id
* In this case we clear all not default values
*/
if (Mage::app()->isSingleStoreMode()) {
$storeId = $this->getDefaultStoreId();
$write->delete($table, array('attribute_id = ?' => $attribute->getAttributeId(), 'entity_id = ?' => $object->getEntityId(), 'store_id <> ?' => $storeId));
}
$data = new Varien_Object(array('entity_type_id' => $attribute->getEntityTypeId(), 'attribute_id' => $attribute->getAttributeId(), 'store_id' => $storeId, 'entity_id' => $object->getEntityId(), 'value' => $this->_prepareValueForSave($value, $attribute)));
$bind = $this->_prepareDataForTable($data, $table);
if ($attribute->isScopeStore()) {
/**
* Update attribute value for store
*/
$this->_attributeValuesToSave[$table][] = $bind;
} else {
if ($attribute->isScopeWebsite() && $storeId != $this->getDefaultStoreId()) {
/**
* Update attribute value for website
*/
$storeIds = Mage::app()->getStore($storeId)->getWebsite()->getStoreIds(true);
foreach ($storeIds as $storeId) {
$bind['store_id'] = (int) $storeId;
$this->_attributeValuesToSave[$table][] = $bind;
}
} else {
/**
* Update global attribute value
*/
$bind['store_id'] = $this->getDefaultStoreId();
$this->_attributeValuesToSave[$table][] = $bind;
}
}
return $this;
}
示例3: _updateAttributeForStore
/**
* Update attribute value for specific store
*
* @param Mage_Catalog_Model_Abstract $object
* @param object $attribute
* @param mixed $value
* @param int $storeId
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Abstract
*/
protected function _updateAttributeForStore($object, $attribute, $value, $storeId)
{
$entityIdField = $attribute->getBackend()->getEntityIdField();
$select = $this->_getWriteAdapter()->select()->from($attribute->getBackend()->getTable(), 'value_id')->where('entity_type_id=?', $object->getEntityTypeId())->where("{$entityIdField}=?", $object->getId())->where('store_id=?', $storeId)->where('attribute_id=?', $attribute->getId());
/**
* When value for store exist
*/
if ($valueId = $this->_getWriteAdapter()->fetchOne($select)) {
$this->_getWriteAdapter()->update($attribute->getBackend()->getTable(), array('value' => $this->_prepareValueForSave($value, $attribute)), 'value_id=' . $valueId);
} else {
$this->_getWriteAdapter()->insert($attribute->getBackend()->getTable(), array($entityIdField => $object->getId(), 'entity_type_id' => $object->getEntityTypeId(), 'attribute_id' => $attribute->getId(), 'value' => $this->_prepareValueForSave($value, $attribute), 'store_id' => $storeId));
}
return $this;
}
示例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: isEnabledProduct
/**
* isEnabledProduct
*
* @param Mage_Catalog_Model_Abstract $product
* @return boolean
*/
public function isEnabledProduct(Mage_Catalog_Model_Abstract $product)
{
return Mage_Catalog_Model_Product_Status::STATUS_ENABLED == $product->getStatus();
}
示例6: _setAttributeValue
/**
* Initialize attribute value for object
*
* @param Mage_Catalog_Model_Abstract $object
* @param array $valueRow
* @return Mage_Catalog_Model_Resource_Abstract
*/
protected function _setAttributeValue($object, $valueRow)
{
$attribute = $this->getAttribute($valueRow['attribute_id']);
if ($attribute) {
$attributeCode = $attribute->getAttributeCode();
$isDefaultStore = $valueRow['store_id'] == $this->getDefaultStoreId();
if (isset($this->_attributes[$valueRow['attribute_id']])) {
if ($isDefaultStore) {
$object->setAttributeDefaultValue($attributeCode, $valueRow['value']);
} else {
$object->setAttributeDefaultValue($attributeCode, $this->_attributes[$valueRow['attribute_id']]['value']);
}
} else {
$this->_attributes[$valueRow['attribute_id']] = $valueRow;
}
$value = $valueRow['value'];
$valueId = $valueRow['value_id'];
$object->setData($attributeCode, $value);
if (!$isDefaultStore) {
$object->setExistsStoreValueFlag($attributeCode);
}
// $attribute->getBackend()->setEntityValueId($object, $valueId);
$attribute->getBackend()->setValueId($valueId);
}
return $this;
}
示例7: _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;
}
示例8: testIsReadonly
/**
* @covers Mage_Catalog_Model_Abstract::isReadonly
* @covers Mage_Catalog_Model_Abstract::setIsReadonly
*/
public function testIsReadonly()
{
$this->assertFalse($this->_model->isReadonly());
$this->_model->setIsReadonly(true);
$this->assertTrue($this->_model->isReadonly());
}
示例9: _updateAttributeForStore
/**
* Update attribute value for specific store
*
* @param Mage_Catalog_Model_Abstract $object
* @param object $attribute
* @param mixed $value
* @param int $storeId
* @return Mage_Catalog_Model_Resource_Abstract
*/
protected function _updateAttributeForStore($object, $attribute, $value, $storeId)
{
$adapter = $this->_getWriteAdapter();
$table = $attribute->getBackend()->getTable();
$entityIdField = $attribute->getBackend()->getEntityIdField();
$select = $adapter->select()->from($table, 'value_id')->where('entity_type_id = :entity_type_id')->where("{$entityIdField} = :entity_field_id")->where('store_id = :store_id')->where('attribute_id = :attribute_id');
$bind = array('entity_type_id' => $object->getEntityTypeId(), 'entity_field_id' => $object->getId(), 'store_id' => $storeId, 'attribute_id' => $attribute->getId());
$valueId = $adapter->fetchOne($select, $bind);
/**
* When value for store exist
*/
if ($valueId) {
$bind = array('value' => $this->_prepareValueForSave($value, $attribute));
$where = array('value_id = ?' => (int) $valueId);
$adapter->update($table, $bind, $where);
} else {
$bind = array($idField => (int) $object->getId(), 'entity_type_id' => (int) $object->getEntityTypeId(), 'attribute_id' => (int) $attribute->getId(), 'value' => $this->_prepareValueForSave($value, $attribute), 'store_id' => (int) $storeId);
$adapter->insert($table, $bind);
}
return $this;
}
示例10: _afterSave
/**
* Init indexing process after category save
*
* @return Mage_Catalog_Model_Category
*/
protected function _afterSave()
{
$result = parent::_afterSave();
Mage::getSingleton('Mage_Index_Model_Indexer')->processEntityAction($this, self::ENTITY, Mage_Index_Model_Event::TYPE_SAVE);
return $result;
}
示例11: getCollection
public function getCollection()
{
return parent::getCollection();
}
示例12: afterCommitCallback
/**
* Callback function which called after transaction commit in resource model
*
* @return Mage_Catalog_Model_Product
*/
public function afterCommitCallback()
{
parent::afterCommitCallback();
/** @var \Mage_Index_Model_Indexer $indexer */
$indexer = Mage::getSingleton('index/indexer');
$indexer->processEntityAction($this, self::ENTITY, Mage_Index_Model_Event::TYPE_SAVE);
return $this;
}
示例13: delete
public function delete()
{
parent::delete();
Mage::dispatchEvent($this->_eventPrefix . '_delete_after_done', array($this->_eventObject => $this));
return $this;
}
示例14: _construct
protected function _construct()
{
parent::_construct();
$this->_init('prolabels/index');
}
示例15: getImage
/**
* Sets product image from it's child if possible
*
* @return string
*/
public function getImage()
{
$this->getTypeInstance()->setImageFromChildProduct($this);
return parent::getImage();
}