本文整理汇总了PHP中Mage_Eav_Model_Entity_Attribute_Abstract::getAttributeCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Eav_Model_Entity_Attribute_Abstract::getAttributeCode方法的具体用法?PHP Mage_Eav_Model_Entity_Attribute_Abstract::getAttributeCode怎么用?PHP Mage_Eav_Model_Entity_Attribute_Abstract::getAttributeCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Eav_Model_Entity_Attribute_Abstract
的用法示例。
在下文中一共展示了Mage_Eav_Model_Entity_Attribute_Abstract::getAttributeCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _isAllowedAttribute
/**
* Check is attribute allowed
*
* @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
* @param array $attributes
* @return boolean
*/
protected function _isAllowedAttribute($attribute, array $filter = null)
{
if (!is_null($filter) && !(in_array($attribute->getAttributeCode(), $filter) || in_array($attribute->getAttributeId(), $filter))) {
return false;
}
return !in_array($attribute->getFrontendInput(), $this->_ignoredAttributeTypes) && !in_array($attribute->getAttributeCode(), $this->_ignoredAttributeCodes);
}
示例2: _isAttributeIndexable
protected function _isAttributeIndexable(Mage_Eav_Model_Entity_Attribute_Abstract $attribute)
{
if ($attribute->getFrontendInput() != 'price') {
return false;
}
if ($attribute->getAttributeCode() == 'tier_price') {
return false;
}
if ($attribute->getAttributeCode() == 'minimal_price') {
return false;
}
return true;
}
示例3: callbackFilterPartsCompatibilityAttribute
public function callbackFilterPartsCompatibilityAttribute(Varien_Data_Collection_Db $collection, $column)
{
$value = $column->getFilter()->getValue();
if (is_null($value)) {
return;
}
if (!$this->partsCompatibilityAttribute) {
return;
}
if ($value == 1) {
$attributeCode = $this->partsCompatibilityAttribute->getAttributeCode();
$collection->addFieldToFilter($attributeCode, array('notnull' => true));
$collection->addFieldToFilter($attributeCode, array('neq' => ''));
$collection->addFieldToFilter('is_parts_compatibility_attribute_in_product_attribute_set', array('notnull' => true));
} else {
$attributeId = $this->partsCompatibilityAttribute->getId();
$storeId = $this->getListing()->getStoreId();
$joinCondition = 'eaa.entity_id = e.entity_id and eaa.attribute_id = ' . $attributeId;
if (!$this->partsCompatibilityAttribute->isScopeGlobal()) {
$joinCondition .= ' and eaa.store_id = ' . $storeId;
}
$collection->getSelect()->joinLeft(array('eaa' => Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text')), $joinCondition, array('value'));
$collection->getSelect()->orWhere('eaa.value IS NULL');
$collection->getSelect()->orWhere('eaa.value = \'\'');
$collection->getSelect()->orWhere('eea.entity_attribute_id IS NULL');
}
}
示例4: prepareExistingMotorsData
private function prepareExistingMotorsData()
{
$motorsHelper = Mage::helper('M2ePro/Component_Ebay_Motors');
$products = $this->getCollection()->getItems();
$productsMotorsData = array();
$items = array();
$filters = array();
$groups = array();
foreach ($products as $product) {
if (!$product->getData('is_motors_attribute_in_product_attribute_set')) {
continue;
}
$productId = $product->getData('listing_product_id');
$attributeCode = $this->motorsAttribute->getAttributeCode();
$attributeValue = $product->getData($attributeCode);
$productsMotorsData[$productId] = $motorsHelper->parseAttributeValue($attributeValue);
$items = array_merge($items, array_keys($productsMotorsData[$productId]['items']));
$filters = array_merge($filters, $productsMotorsData[$productId]['filters']);
$groups = array_merge($groups, $productsMotorsData[$productId]['groups']);
}
//-------------------------------
$typeIdentifier = $motorsHelper->getIdentifierKey($this->getMotorsType());
$select = Mage::getResourceModel('core/config')->getReadConnection()->select()->from($motorsHelper->getDictionaryTable($this->getMotorsType()), array($typeIdentifier))->where('`' . $typeIdentifier . '` IN (?)', $items);
$existedItems = $select->query()->fetchAll(PDO::FETCH_COLUMN);
//-------------------------------
//-------------------------------
$filtersTable = Mage::getSingleton('core/resource')->getTableName('m2epro_ebay_motor_filter');
$select = Mage::getResourceModel('core/config')->getReadConnection()->select()->from($filtersTable, array('id'))->where('`id` IN (?)', $filters);
$existedFilters = $select->query()->fetchAll(PDO::FETCH_COLUMN);
//-------------------------------
//-------------------------------
$groupsTable = Mage::getSingleton('core/resource')->getTableName('m2epro_ebay_motor_group');
$select = Mage::getResourceModel('core/config')->getReadConnection()->select()->from($groupsTable, array('id'))->where('`id` IN (?)', $groups);
$existedGroups = $select->query()->fetchAll(PDO::FETCH_COLUMN);
//-------------------------------
foreach ($productsMotorsData as $productId => $productMotorsData) {
foreach ($productMotorsData['items'] as $item => $itemData) {
if (!in_array($item, $existedItems)) {
unset($productsMotorsData[$productId]['items'][$item]);
}
}
foreach ($productMotorsData['filters'] as $key => $filterId) {
if (!in_array($filterId, $existedFilters)) {
unset($productsMotorsData[$productId]['filters'][$key]);
}
}
foreach ($productMotorsData['groups'] as $key => $groupId) {
if (!in_array($groupId, $existedGroups)) {
unset($productsMotorsData[$productId]['groups'][$key]);
}
}
}
$this->productsMotorsData = $productsMotorsData;
return $this;
}
示例5: getFlatUpdateSelect
/**
* Retrieve Select for update Flat data
*
* @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
* @param int $store
* @param bool $hasValueField flag which require option value
* @return Varien_Db_Select
*/
public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $store, $hasValueField = true)
{
$attributeTable = $attribute->getBackend()->getTable();
$attributeCode = $attribute->getAttributeCode();
$valueExpr = new Zend_Db_Expr("IFNULL(t2.value, t1.value)");
$select = $this->_getReadAdapter()->select()->joinLeft(array('t1' => $attributeTable), "`e`.`entity_id`=`t1`.`entity_id` AND `e`.`child_id`=`t1`.`entity_id`", array())->joinLeft(array('t2' => $attributeTable), "`t2`.`entity_id`=`t1`.`entity_id`" . " AND `t1`.`entity_type_id`=`t2`.`entity_type_id`" . " AND `t1`.`attribute_id`=`t2`.`attribute_id`" . " AND `t2`.`store_id`={$store}", array($attributeCode => $valueExpr));
if ($attribute->getFrontend()->getInputType() != 'multiselect' && $hasValueField) {
$select->joinLeft(array('to1' => $this->getTable('eav/attribute_option_value')), "`to1`.`option_id`={$valueExpr}" . " AND `to1`.`store_id`='0'", array())->joinLeft(array('to2' => $this->getTable('eav/attribute_option_value')), "`to2`.`option_id`={$valueExpr}" . " AND `to2`.`store_id`='{$store}'", array($attributeCode . '_value' => "IFNULL(`to2`.`value`, `to1`.`value`)"));
}
$select->where('t1.entity_type_id=?', $attribute->getEntityTypeId())->where('t1.attribute_id=?', $attribute->getId())->where('t1.store_id=?', 0);
return $select;
}
示例6: callbackFilterMotorsSpecificsAttribute
public function callbackFilterMotorsSpecificsAttribute(Varien_Data_Collection_Db $collection, $column)
{
$value = $column->getFilter()->getValue();
if ($value == null) {
return;
}
if (!$this->motorsSpecificsAttribute) {
return;
}
$attributeCode = $this->motorsSpecificsAttribute->getAttributeCode();
if ($value == 1) {
$collection->addFieldToFilter($attributeCode, array('notnull' => true));
$collection->addFieldToFilter($attributeCode, array('neq' => '\'\''));
$collection->addFieldToFilter('is_motors_attribute_in_product_attribute_set', array('notnull' => true));
} else {
$collection->addFieldToFilter(array(array('attribute' => $attributeCode, 'null' => true), array('attribute' => $attributeCode, 'eq' => '\'\''), array('attribute' => 'is_motors_attribute_in_product_attribute_set', 'null' => true)));
}
}
示例7: getFlatUpdateSelect
/**
* Retrieve Select for update Flat data
*
* @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
* @param int $store
* @param bool $hasValueField flag which require option value
* @return Varien_Db_Select
*/
public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $store, $hasValueField = true)
{
$attributeTable = $attribute->getBackend()->getTable();
$attributeCode = $attribute->getAttributeCode();
$joinConditionTemplate = "`e`.`entity_id`=`%s`.`entity_id`" . " AND `%s`.`entity_type_id` = " . $attribute->getEntityTypeId() . " AND `%s`.`attribute_id` = " . $attribute->getId() . " AND `%s`.`store_id` = %d";
$joinCondition = sprintf($joinConditionTemplate, 't1', 't1', 't1', 't1', Mage_Core_Model_App::ADMIN_STORE_ID);
if ($attribute->getFlatAddChildData()) {
$joinCondition .= " AND `e`.`child_id`=`t1`.`entity_id`";
}
$valueExpr = new Zend_Db_Expr("IF(t2.value_id>0, t2.value, t1.value)");
$select = $this->_getReadAdapter()->select()->joinLeft(array('t1' => $attributeTable), $joinCondition, array())->joinLeft(array('t2' => $attributeTable), sprintf($joinConditionTemplate, 't2', 't2', 't2', 't2', $store), array($attributeCode => $valueExpr));
if ($attribute->getFrontend()->getInputType() != 'multiselect' && $hasValueField) {
$select->joinLeft(array('to1' => $this->getTable('eav/attribute_option_value')), "`to1`.`option_id`={$valueExpr}" . " AND `to1`.`store_id`='0'", array())->joinLeft(array('to2' => $this->getTable('eav/attribute_option_value')), "`to2`.`option_id`={$valueExpr}" . " AND `to2`.`store_id`='{$store}'", array($attributeCode . '_value' => "IFNULL(`to2`.`value`, `to1`.`value`)"));
}
if ($attribute->getFlatAddChildData()) {
$select->where("e.is_child=?", 0);
}
return $select;
}
示例8: createIndexData
public function createIndexData(Mage_Catalog_Model_Product $object, Mage_Eav_Model_Entity_Attribute_Abstract $attribute = null)
{
$data = array();
$data['store_id'] = $attribute->getStoreId();
$data['entity_id'] = $object->getId();
$data['attribute_id'] = $attribute->getId();
$data['value'] = $object->getData($attribute->getAttributeCode());
if ($attribute->getFrontendInput() == 'multiselect') {
$origData = $data;
$data = array();
$value = explode(',', $origData['value']);
foreach ($value as $item) {
$row = $origData;
$row['value'] = $item;
$data[] = $row;
}
}
//return $this->_spreadDataForStores($object, $attribute, $data);
return $data;
}
示例9: getFlatUpdateSelect
/**
* Retrieve Select for update Flat data
*
* @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
* @param int $store
* @param bool $hasValueField flag which require option value
* @return Varien_Db_Select
*/
public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $store, $hasValueField = true)
{
$adapter = $this->_getReadAdapter();
$attributeTable = $attribute->getBackend()->getTable();
$attributeCode = $attribute->getAttributeCode();
$joinConditionTemplate = "%s.entity_id = %s.entity_id" . " AND %s.entity_type_id = " . $attribute->getEntityTypeId() . " AND %s.attribute_id = " . $attribute->getId() . " AND %s.store_id = %d";
$joinCondition = sprintf($joinConditionTemplate, 'e', 't1', 't1', 't1', 't1', Mage_Core_Model_App::ADMIN_STORE_ID);
if ($attribute->getFlatAddChildData()) {
$joinCondition .= ' AND e.child_id = t1.entity_id';
}
$valueExpr = $adapter->getCheckSql('t2.value_id > 0', 't2.value', 't1.value');
/** @var $select Varien_Db_Select */
$select = $adapter->select()->joinLeft(array('t1' => $attributeTable), $joinCondition, array())->joinLeft(array('t2' => $attributeTable), sprintf($joinConditionTemplate, 'e', 't2', 't2', 't2', 't2', $store), array($attributeCode => $valueExpr));
if ($attribute->getFrontend()->getInputType() != 'multiselect' && $hasValueField) {
$valueIdExpr = $adapter->getCheckSql('to2.value_id > 0', 'to2.value', 'to1.value');
$select->joinLeft(array('to1' => $this->getTable('eav/attribute_option_value')), "to1.option_id = {$valueExpr} AND to1.store_id = 0", array())->joinLeft(array('to2' => $this->getTable('eav/attribute_option_value')), $adapter->quoteInto("to2.option_id = {$valueExpr} AND to2.store_id = ?", $store), array($attributeCode . '_value' => $valueIdExpr));
}
if ($attribute->getFlatAddChildData()) {
$select->where("e.is_child = ?", 0);
}
return $select;
}
示例10: isAttributeStatic
/**
* Check whether the attribute is a real field in entity table
* Rewrited for EAV Collection
*
* @param integer|string|Mage_Eav_Model_Entity_Attribute_Abstract $attribute
* @return bool
*/
public function isAttributeStatic($attribute)
{
$attributeCode = null;
if ($attribute instanceof Mage_Eav_Model_Entity_Attribute_Interface) {
$attributeCode = $attribute->getAttributeCode();
} elseif (is_string($attribute)) {
$attributeCode = $attribute;
} elseif (is_numeric($attribute)) {
$attributeCode = $this->getAttribute($attribute)->getAttributeCode();
}
if ($attributeCode) {
$columns = $this->getAllTableColumns();
if (in_array($attributeCode, $columns)) {
return true;
}
}
return false;
}
示例11: getAttributeOptions
/**
* Returns attributes all values in label-value or value-value pairs form. Labels are lower-cased.
*
* @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
* @return array
*/
public function getAttributeOptions(Mage_Eav_Model_Entity_Attribute_Abstract $attribute)
{
$options = array();
if ($attribute->usesSource()) {
// should attribute has index (option value) instead of a label?
$index = in_array($attribute->getAttributeCode(), $this->_indexValueAttributes) ? 'value' : 'label';
// only default (admin) store values used
$attribute->setStoreId(Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID);
try {
foreach ($attribute->getSource()->getAllOptions(false) as $option) {
foreach (is_array($option['value']) ? $option['value'] : array($option) as $innerOption) {
if (strlen($innerOption['value'])) {
// skip ' -- Please Select -- ' option
$options[$innerOption['value']] = $innerOption[$index];
}
}
}
} catch (Exception $e) {
// ignore exceptions connected with source models
}
}
return $options;
}
示例12: getFlatUpdateSelect
/**
* Retrieve Select For Flat Attribute update
*
* @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
* @param int $storeId
* @return Varien_Db_Select
*/
public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $storeId)
{
$adapter = $this->_getReadAdapter();
$joinConditionTemplate = "%s.entity_id=%s.entity_id" . " AND %s.entity_type_id = " . $attribute->getEntityTypeId() . " AND %s.attribute_id = " . $attribute->getId() . " AND %s.store_id = %d";
$joinCondition = sprintf($joinConditionTemplate, 'e', 't1', 't1', 't1', 't1', Mage_Core_Model_App::ADMIN_STORE_ID);
if ($attribute->getFlatAddChildData()) {
$joinCondition .= ' AND e.child_id = t1.entity_id';
}
$valueExpr = $adapter->getCheckSql('t2.value_id > 0', 't2.value', 't1.value');
/** @var $select Varien_Db_Select */
$select = $adapter->select()->joinLeft(array('t1' => $attribute->getBackend()->getTable()), $joinCondition, array())->joinLeft(array('t2' => $attribute->getBackend()->getTable()), sprintf($joinConditionTemplate, 't1', 't2', 't2', 't2', 't2', $storeId), array($attribute->getAttributeCode() => $valueExpr));
if ($attribute->getFlatAddChildData()) {
$select->where("e.is_child = ?", 0);
}
return $select;
}
示例13: _isAllowedAttribute
/**
* Check if attribute is allowed
*
* @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
* @param array $attributes
* @return boolean
*/
protected function _isAllowedAttribute($attribute, $attributes = null)
{
$isAllowed = true;
if (is_array($attributes) && !(in_array($attribute->getAttributeCode(), $attributes) || in_array($attribute->getAttributeId(), $attributes))) {
$isAllowed = false;
}
return $isAllowed;
}
示例14: _setAttribute
/**
* Set entity attribute value
*
* Collect for mass save
*
* @param Mage_Core_Model_Abstract $object
* @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
* @param mixed $value
* @return Mage_Eav_Model_Entity_Abstract
*/
protected function _setAttribute($object, $attribute, $value)
{
$this->_attributeValuesToSave['$set'][$attribute->getAttributeCode()] = $this->_prepareValueForSave($value, $attribute);
return $this;
}
示例15: checkAttributeUniqueValue
/**
* Enter description here...
*
* @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
* @param Varien_Object $object
* @return boolean
*/
public function checkAttributeUniqueValue(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $object)
{
if ($attribute->getBackend()->getType() === 'static') {
$select = $this->_getWriteAdapter()->select()->from($this->getEntityTable(), $this->getEntityIdField())->where('entity_type_id=?', $this->getTypeId())->where($attribute->getAttributeCode() . '=?', $object->getData($attribute->getAttributeCode()));
} else {
$value = $object->getData($attribute->getAttributeCode());
if ($attribute->getBackend()->getType() == 'datetime') {
$date = new Zend_Date($value);
$value = $date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
}
$select = $this->_getWriteAdapter()->select()->from($attribute->getBackend()->getTable(), $attribute->getBackend()->getEntityIdField())->where('entity_type_id=?', $this->getTypeId())->where('attribute_id=?', $attribute->getId())->where('value=?', $value);
}
$data = $this->_getWriteAdapter()->fetchCol($select);
if ($object->getId()) {
if (isset($data[0])) {
return $data[0] == $object->getId();
}
return true;
} else {
return !count($data);
}
}