本文整理汇总了PHP中Mage_Catalog_Model_Resource_Eav_Attribute类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Resource_Eav_Attribute类的具体用法?PHP Mage_Catalog_Model_Resource_Eav_Attribute怎么用?PHP Mage_Catalog_Model_Resource_Eav_Attribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Catalog_Model_Resource_Eav_Attribute类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setScope
/**
* Redefine Attribute scope
*
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
* @return Mage_Catalog_Model_Product_Attribute_Backend_Price
*/
public function setScope($attribute)
{
if (Mage::helper('catalog')->isPriceGlobal()) {
$attribute->setIsGlobal(Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL);
} else {
$attribute->setIsGlobal(Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE);
}
return $this;
}
开发者ID:nshiff,项目名称:magento-example,代码行数:15,代码来源:Price.php
示例2: testSaveActionApplyToData
/**
* @magentoDataFixture Mage/Catalog/controllers/_files/attribute_system_with_applyto_data.php
*/
public function testSaveActionApplyToData()
{
$postData = $this->_getAttributeData() + array('attribute_id' => '3');
unset($postData['apply_to']);
$this->getRequest()->setPost($postData);
$this->dispatch('backend/admin/catalog_product_attribute/save');
$model = new Mage_Catalog_Model_Resource_Eav_Attribute(new Mage_Core_Model_Event_Manager(), new Mage_Core_Model_Cache());
$model->load($postData['attribute_id']);
$this->assertEquals(array('simple', 'configurable'), $model->getApplyTo());
}
开发者ID:,项目名称:,代码行数:13,代码来源:
示例3: getGcontentAttributeType
/**
* Return Google Content Attribute Type By Product Attribute
*
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
* @return string Google Content Attribute Type
*/
public function getGcontentAttributeType($attribute)
{
$typesMapping = array('price' => self::ATTRIBUTE_TYPE_FLOAT, 'decimal' => self::ATTRIBUTE_TYPE_INT);
if (isset($typesMapping[$attribute->getFrontendInput()])) {
return $typesMapping[$attribute->getFrontendInput()];
} elseif (isset($typesMapping[$attribute->getBackendType()])) {
return $typesMapping[$attribute->getBackendType()];
} else {
return self::ATTRIBUTE_TYPE_TEXT;
}
}
开发者ID:shakhawat4g,项目名称:MagentoExtensions,代码行数:17,代码来源:Default.php
示例4: overrideAttribute
public function overrideAttribute(Mage_Catalog_Model_Resource_Eav_Attribute $attribute)
{
if (!empty($this->_attributeOverrides[$attribute->getAttributeCode()])) {
$data = $this->_attributeOverrides[$attribute->getAttributeCode()];
if (isset($data['options_method']) && method_exists($this, $data['options_method'])) {
$data['filter_options'] = $this->{$data['options_method']}();
}
$attribute->addData($data);
return true;
}
return false;
}
开发者ID:Inchoo,项目名称:Inchoo_PHP7,代码行数:12,代码来源:Configurable.php
示例5: loadProductPrices
/**
* Load product tier prices
*
* @param Mage_Catalog_Model_Product $product
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
* @return array
*/
public function loadProductPrices($product, $attribute)
{
$select = $this->_getReadAdapter()->select()->from($this->getMainTable(), array('website_id', 'all_groups', 'cust_group' => 'customer_group_id', 'price_qty' => 'qty', 'price' => 'value'))->where('entity_id=?', $product->getId())->order('qty');
if ($attribute->isScopeGlobal()) {
$select->where('website_id=?', 0);
} else {
if ($storeId = $product->getStoreId()) {
$select->where('website_id IN (?)', array(0, Mage::app()->getStore($storeId)->getWebsiteId()));
}
}
return $this->_getReadAdapter()->fetchAll($select);
}
开发者ID:jauderho,项目名称:magento-mirror,代码行数:19,代码来源:Tierprice.php
示例6: addPriceFilter
/**
* Add filter by attribute price
*
* @param Mage_CatalogSearch_Model_Advanced $object
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
* @param string|array $value
*/
public function addPriceFilter($object, $attribute, $value)
{
if (empty($value['from']) && empty($value['to'])) {
return false;
}
if (Mage::helper('solr')->isEnabled()) {
$typeConverter = new DMC_Solr_Model_SolrServer_Adapter_Product_TypeConverter();
$code = $attribute->getAttributeCode();
$items = $typeConverter->getItems();
$select = $object->getProductCollection()->getSelect();
$rate = 1;
if (!empty($value['currency'])) {
$rate = Mage::app()->getStore()->getBaseCurrency()->getRate($value['currency']);
}
if (strlen($value['from']) > 0) {
$from = $value['from'] * $rate;
} else {
$from = 0;
}
if (strlen($value['to']) > 0) {
$to = $value['to'] * $rate;
} else {
$to = 99999999;
}
$select->where($items[$attribute->getFrontend()->getInputType()]['solr_index_prefix'] . $typeConverter::SUBPREFIX_INDEX . 'price:[' . $from . ' TO ' . $to . ']');
} else {
$adapter = $this->_getReadAdapter();
$conditions = array();
if (strlen($value['from']) > 0) {
$conditions[] = $adapter->quoteInto('price_index.min_price %s * %s >= ?', $value['from']);
}
if (strlen($value['to']) > 0) {
$conditions[] = $adapter->quoteInto('price_index.min_price %s * %s <= ?', $value['to']);
}
if (!$conditions) {
return false;
}
$object->getProductCollection()->addPriceData();
$select = $object->getProductCollection()->getSelect();
$response = $this->_dispatchPreparePriceEvent($select);
$additional = join('', $response->getAdditionalCalculations());
$rate = 1;
if (!empty($value['currency'])) {
$rate = Mage::app()->getStore()->getBaseCurrency()->getRate($value['currency']);
}
foreach ($conditions as $condition) {
$select->where(sprintf($condition, $additional, $rate));
}
}
return true;
}
开发者ID:kevinrademan,项目名称:Magento-Solr,代码行数:58,代码来源:Advanced.php
示例7: _prepareCondition
/**
* Prepare search condition for attribute
*
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
* @param string|array $value
* @return mixed
*/
protected function _prepareCondition($attribute, $value)
{
$condition = false;
if (is_array($value)) {
if (!empty($value['from']) || !empty($value['to'])) {
// range
$condition = $value;
} else {
if ($attribute->getBackendType() == 'varchar') {
// multiselect
$condition = array('in_set' => $value);
} else {
if (!isset($value['from']) && !isset($value['to'])) {
// select
$condition = array('in' => $value);
}
}
}
} else {
if (strlen($value) > 0) {
if (in_array($attribute->getBackendType(), array('varchar', 'text', 'static'))) {
$condition = array('like' => '%' . $value . '%');
// text search
} else {
$condition = $value;
}
}
}
return $condition;
}
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:37,代码来源:Advanced.php
示例8: addSearchParams
/**
* Append search params to the form
*
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute Attribute currently edited
* @param Varien_Data_Form $form Form the
*
* @return Smile_ElasticSearch_Model_Adminhtml_Catalog_Product_Attribute_Edit_Form_Search
*/
public function addSearchParams($attribute, $form)
{
$fieldset = $this->_getFieldset($form);
$fieldset->addField('search_weight', 'text', array('name' => 'search_weight', 'label' => Mage::helper('smile_elasticsearch')->__('Search Weight'), 'class' => 'validate-number validate-greater-than-zero', 'default' => 1), 'is_searchable');
$fieldset->addField('is_used_in_autocomplete', 'select', array('name' => 'is_used_in_autocomplete', 'label' => Mage::helper('smile_elasticsearch')->__('Used in autocomplete'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()), 'search_weight');
$fieldset->addField('is_snowball_used', 'select', array('name' => 'is_snowball_used', 'label' => Mage::helper('smile_elasticsearch')->__('Use language analysis'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()), 'is_used_in_autocomplete');
$fieldset->addField('is_fuzziness_enabled', 'select', array('name' => 'is_fuzziness_enabled', 'label' => Mage::helper('smile_elasticsearch')->__('Enable fuzziness'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()), 'is_snowball_used');
$fieldset->addField('fuzziness_value', 'text', array('name' => 'fuzziness_value', 'label' => Mage::helper('smile_elasticsearch')->__('Fuzziness'), 'class' => 'validate-number validate-number-range number-range-0-1', 'note' => implode('</br>', array(Mage::helper('smile_elasticsearch')->__('A number between 0 and 1.'), Mage::helper('smile_elasticsearch')->__('See doc at <a href="%s" target="_blank">here</a> for more information', 'http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/common-options.html#_string_fields')))), 'is_fuzziness_enabled');
$fieldset->addField('fuzziness_prefix_length', 'text', array('name' => 'fuzziness_prefix_length', 'label' => Mage::helper('smile_elasticsearch')->__('Fuzzy prefix range'), 'class' => 'validate-digits validate-digits-range digits-range-0-9', 'note' => implode('</br>', array(Mage::helper('smile_elasticsearch')->__('A number between 0 and 9.'), Mage::helper('smile_elasticsearch')->__('Min.common prefix between original term and fuzzy matched one.')))), 'fuzziness_value');
if ($attribute->getAttributeCode() == 'name') {
$form->getElement('is_searchable')->setDisabled(1);
$form->getElement('is_used_in_autocomplete')->setDisabled(1);
$form->getElement('is_used_in_autocomplete')->setValue(1);
}
return $this;
}
开发者ID:ngocdb,项目名称:smile-magento-elasticsearch,代码行数:24,代码来源:Search.php
示例9: _getSearchParam
/**
* Retrieve filter array
*
* @param Enterprise_Search_Model_Resource_Collection $collection
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
* @param string|array $value
* @return array
*/
protected function _getSearchParam($collection, $attribute, $value)
{
if (empty($value) || isset($value['from']) && empty($value['from']) && isset($value['to']) && empty($value['to'])) {
return false;
}
$localeCode = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE);
$languageCode = Mage::helper('enterprise_search')->getLanguageCodeByLocaleCode($localeCode);
$languageSuffix = $languageCode ? '_' . $languageCode : '';
$field = $attribute->getAttributeCode();
$backendType = $attribute->getBackendType();
$frontendInput = $attribute->getFrontendInput();
if ($frontendInput == 'multiselect') {
$field = 'attr_multi_' . $field;
} elseif ($frontendInput == 'select' || $frontendInput == 'boolean') {
$field = 'attr_select_' . $field;
} elseif ($backendType == 'decimal') {
$field = 'attr_decimal_' . $field;
} elseif ($backendType == 'datetime') {
$field = 'attr_datetime_' . $field;
if (is_array($value)) {
foreach ($value as &$val) {
if (!is_empty_date($val)) {
$date = new Zend_Date($val, Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
$val = $date->toString(Zend_Date::ISO_8601) . 'Z';
}
}
} else {
if (!is_empty_date($value)) {
$date = new Zend_Date($value, Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
$value = $date->toString(Zend_Date::ISO_8601) . 'Z';
}
}
} elseif (in_array($backendType, $this->_textFieldTypes)) {
$field .= $languageSuffix;
}
if ($attribute->usesSource()) {
$attribute->setStoreId(Mage::app()->getStore()->getId());
foreach ($value as &$val) {
$val = $attribute->getSource()->getOptionText($val);
}
}
if (empty($value)) {
return array();
} else {
return array($field => $value);
}
}
开发者ID:jpbender,项目名称:mage_virtual,代码行数:55,代码来源:Advanced.php
示例10: _afterDeleteCommit
/**
* Init indexing process after catalog eav attribute delete commit
*
* @return Mage_Catalog_Model_Resource_Eav_Attribute
*/
protected function _afterDeleteCommit()
{
parent::_afterDeleteCommit();
$magerpsync = Mage::getModel('magerpsync/attribute')->load($this->getId(), "mage_attribute_id");
$magerpsync->delete();
Mage::getModel('magerpsync/attribute')->deleteAttributeMapping($this->getId());
return $this;
}
开发者ID:babycarenl,项目名称:360,代码行数:13,代码来源:Attribute.php
示例11: _isAttributeVisible
/**
* Define if attribute should be visible for passed user type
*
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
* @param string $userType
* @return bool
*/
protected function _isAttributeVisible(Mage_Catalog_Model_Resource_Eav_Attribute $attribute, $userType)
{
$isAttributeVisible = false;
if ($userType == Mage_Api2_Model_Auth_User_Admin::USER_TYPE) {
$isAttributeVisible = $attribute->getIsVisible();
} else {
$systemAttributesForNonAdmin = array('sku', 'name', 'short_description', 'description', 'tier_price', 'meta_title', 'meta_description', 'meta_keyword');
if ($attribute->getIsUserDefined()) {
$isAttributeVisible = $attribute->getIsVisibleOnFront();
} else {
if (in_array($attribute->getAttributeCode(), $systemAttributesForNonAdmin)) {
$isAttributeVisible = true;
}
}
}
return (bool) $isAttributeVisible;
}
开发者ID:chucky515,项目名称:Magento-CE-Mirror,代码行数:24,代码来源:Product.php
示例12: addSearchParams
/**
* Append search params to the form
*
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute Attribute currently edited
* @param Varien_Data_Form $form Form the
*
* @return Smile_ElasticSearch_Model_Adminhtml_Catalog_Product_Attribute_Edit_Form_Search
*/
public function addSearchParams($attribute, $form)
{
$fieldset = $this->_getFieldset($form);
$fieldset->addField('search_weight', 'text', array('name' => 'search_weight', 'label' => Mage::helper('smile_elasticsearch')->__('Search Weight'), 'class' => 'validate-number validate-greater-than-zero', 'value' => '1', 'default' => 1), 'is_searchable');
$fieldset->addField('is_used_in_autocomplete', 'select', array('name' => 'is_used_in_autocomplete', 'label' => Mage::helper('smile_elasticsearch')->__('Used in autocomplete'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()), 'search_weight');
$fieldset->addField('is_displayed_in_autocomplete', 'select', array('name' => 'is_displayed_in_autocomplete', 'label' => Mage::helper('smile_elasticsearch')->__('Display in autocomplete'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()), 'is_used_in_autocomplete');
$fieldset->addField('is_snowball_used', 'select', array('name' => 'is_snowball_used', 'label' => Mage::helper('smile_elasticsearch')->__('Use language analysis'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()), 'is_displayed_in_autocomplete');
$fieldset->addField('is_fuzziness_enabled', 'select', array('name' => 'is_fuzziness_enabled', 'label' => Mage::helper('smile_elasticsearch')->__('Enable fuzziness'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()), 'is_snowball_used');
$fieldset->addField('facet_min_coverage_rate', 'text', array('name' => 'facet_min_coverage_rate', 'label' => Mage::helper('smile_elasticsearch')->__('Facet coverage rate'), 'class' => 'validate-digits validate-digits-range digits-range-0-100', 'value' => '90', 'note' => Mage::helper('smile_elasticsearch')->__('Ex: Brand facet will be displayed only if 90% of the product have a brand.')), 'is_fuzziness_enabled');
$fieldset->addField('facets_max_size', 'text', array('name' => 'facets_max_size', 'label' => Mage::helper('smile_elasticsearch')->__('Facet max. size'), 'class' => 'validate-digits validate-greater-than-zero', 'value' => '10', 'note' => implode('</br>', array(Mage::helper('smile_elasticsearch')->__('Max number of values returned by a facet query.')))), 'facet_min_coverage_rate');
$fieldset->addField('facets_sort_order', 'select', array('name' => 'facets_sort_order', 'label' => Mage::helper('smile_elasticsearch')->__('Facet sort order'), 'values' => array(array('value' => Smile_ElasticSearch_Model_Catalog_Layer_Filter_Attribute::SORT_ORDER_COUNT, 'label' => Mage::helper('smile_elasticsearch')->__('Result count')), array('value' => Smile_ElasticSearch_Model_Catalog_Layer_Filter_Attribute::SORT_ORDER_TERM, 'label' => Mage::helper('smile_elasticsearch')->__('Name')), array('value' => Smile_ElasticSearch_Model_Catalog_Layer_Filter_Attribute::SORT_ORDER_RELEVANCE, 'label' => Mage::helper('smile_elasticsearch')->__('Relevance')))), 'facets_max_size');
if ($attribute->getAttributeCode() == 'name') {
$form->getElement('is_searchable')->setDisabled(1);
$form->getElement('is_used_in_autocomplete')->setDisabled(1);
$form->getElement('is_used_in_autocomplete')->setValue(1);
}
return $this;
}
开发者ID:diglin,项目名称:smile-magento-elasticsearch,代码行数:26,代码来源:Search.php
示例13: addSearchParams
/**
* Append search params to the form
*
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute Attribute currently edited
* @param Varien_Data_Form $form Form the
*
* @return Smile_ElasticSearch_Model_Adminhtml_Catalog_Product_Attribute_Edit_Form_Search
*/
public function addSearchParams($attribute, $form)
{
$fieldset = $this->_getFieldset($form);
$fieldset->addField('search_weight', 'text', array('name' => 'search_weight', 'label' => Mage::helper('smile_elasticsearch')->__('Search Weight'), 'class' => 'validate-number validate-greater-than-zero', 'value' => '1', 'default' => 1), 'is_searchable');
$fieldset->addField('is_used_in_autocomplete', 'select', array('name' => 'is_used_in_autocomplete', 'label' => Mage::helper('smile_elasticsearch')->__('Used in autocomplete'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()), 'search_weight');
$fieldset->addField('is_snowball_used', 'select', array('name' => 'is_snowball_used', 'label' => Mage::helper('smile_elasticsearch')->__('Use language analysis'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()), 'is_used_in_autocomplete');
$fieldset->addField('is_fuzziness_enabled', 'select', array('name' => 'is_fuzziness_enabled', 'label' => Mage::helper('smile_elasticsearch')->__('Enable fuzziness'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()), 'is_snowball_used');
$fieldset->addField('fuzziness_value', 'text', array('name' => 'fuzziness_value', 'label' => Mage::helper('smile_elasticsearch')->__('Fuzziness'), 'class' => 'validate-number validate-number-range number-range-0-1', 'value' => '0.75', 'note' => implode('</br>', array(Mage::helper('smile_elasticsearch')->__('A number between 0 and 1.'), Mage::helper('smile_elasticsearch')->__('See doc at <a href="%s" target="_blank">here</a> for more information', 'http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/common-options.html#_string_fields')))), 'is_fuzziness_enabled');
$fieldset->addField('fuzziness_prefix_length', 'text', array('name' => 'fuzziness_prefix_length', 'label' => Mage::helper('smile_elasticsearch')->__('Fuzzy prefix range'), 'class' => 'validate-digits validate-digits-range digits-range-0-9', 'value' => '2', 'note' => implode('</br>', array(Mage::helper('smile_elasticsearch')->__('A number between 0 and 9.'), Mage::helper('smile_elasticsearch')->__('Min.common prefix between original term and fuzzy matched one.')))), 'fuzziness_value');
$fieldset->addField('facet_min_coverage_rate', 'text', array('name' => 'facet_min_coverage_rate', 'label' => Mage::helper('smile_elasticsearch')->__('Facet coverage rate'), 'class' => 'validate-digits validate-digits-range digits-range-0-100', 'value' => '90', 'note' => Mage::helper('smile_elasticsearch')->__('Ex: Brand facet will be displayed only if 90% of the product have a brand.')), 'fuzziness_prefix_length');
$fieldset->addField('facets_max_size', 'text', array('name' => 'facets_max_size', 'label' => Mage::helper('smile_elasticsearch')->__('Facets Max Size'), 'class' => 'validate-digits validate-greater-than-zero', 'value' => '1000', 'note' => implode('</br>', array(Mage::helper('smile_elasticsearch')->__('Max number of values returned by a facet query.')))), 'facet_min_coverage_rate');
$fieldset->addField('facets_sort_order', 'select', array('name' => 'facets_sort_order', 'label' => Mage::helper('smile_elasticsearch')->__('Facet sort order'), 'values' => array(array('value' => Smile_ElasticSearch_Model_Resource_Engine_Elasticsearch_Query_Facet_Terms::SORT_ORDER_COUNT, 'label' => Mage::helper('smile_elasticsearch')->__('By results number')), array('value' => Smile_ElasticSearch_Model_Resource_Engine_Elasticsearch_Query_Facet_Terms::SORT_ORDER_TERM, 'label' => Mage::helper('smile_elasticsearch')->__('By name')))), 'facets_max_size');
if ($attribute->getAttributeCode() == 'name') {
$form->getElement('is_searchable')->setDisabled(1);
$form->getElement('is_used_in_autocomplete')->setDisabled(1);
$form->getElement('is_used_in_autocomplete')->setValue(1);
}
return $this;
}
开发者ID:anndream,项目名称:smile-magento-elasticsearch,代码行数:27,代码来源:Search.php
示例14: getAttributeLabel
/**
* Return Product Attribute Store Label
* Set attribute name like frontend lable for custom attributes (which wasn't defined by Google)
*
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
* @param int $storeId Store View Id
* @return string Attribute Store View Label or Attribute code
*/
public function getAttributeLabel($attribute, $storeId)
{
$attributeId = $attribute->getId();
$frontendLabel = $attribute->getFrontend()->getLabel();
if (is_array($frontendLabel)) {
$frontendLabel = array_shift($frontendLabel);
}
if (!isset($this->_attributeLabels[$attributeId])) {
$this->_attributeLabels[$attributeId] = $attribute->getStoreLabels();
}
if (isset($this->_attributeLabels[$attributeId][$storeId])) {
return $this->_attributeLabels[$attributeId][$storeId];
} else {
if (!empty($frontendLabel)) {
return $frontendLabel;
} else {
return $attribute->getAttributeCode();
}
}
}
开发者ID:shakhawat4g,项目名称:MagentoExtensions,代码行数:28,代码来源:Product.php
示例15: _getCountForConfigurable
/** Get counts from index by configurable attributes if applicable
*
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
* @param Varien_Db_Select $select
*/
protected function _getCountForConfigurable($attribute, Varien_Db_Select $select, Varien_Db_Select $baseSelect)
{
/* @var $versionHelper AdjustWare_Nav_Helper_Version */
$versionHelper = Mage::helper('adjnav/version');
if (!$versionHelper->hasConfigurableFix()) {
return false;
}
/* @var $configurableSelect Varien_Db_Select */
$configurableSelect = clone $baseSelect;
$configurableSelect->reset(Zend_Db_Select::COLUMNS);
$configurableSelect->reset(Zend_Db_Select::ORDER);
$configurableSelect->reset(Zend_Db_Select::LIMIT_COUNT);
$configurableSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
$configurableFrom = $configurableSelect->getPart(Zend_Db_Select::FROM);
$attributeJoins = array();
foreach ($configurableFrom as $alias => $tableInfo) {
if (0 === strpos($alias, 'attr_index_')) {
$tableInfo['tableName'] = $this->getTable('adjnav/catalog_product_index_configurable');
$tableInfo['joinCondition'] = str_replace('e.entity_id', 'l.' . $versionHelper->getProductIdChildColumn(), $tableInfo['joinCondition']);
$attributeJoins[$alias] = $tableInfo;
unset($configurableFrom[$alias]);
}
}
if (count($attributeJoins)) {
$configurableSelect->setPart(Zend_Db_Select::FROM, $configurableFrom);
}
$configurableSelect->join(array('l' => $this->getTable($versionHelper->getProductRelationTable())), 'e.entity_id = l.parent_id', array());
$configurableFrom = $configurableSelect->getPart(Zend_Db_Select::FROM);
foreach ($attributeJoins as $alias => $tableInfo) {
$configurableFrom[$alias] = $tableInfo;
}
$configurableSelect->setPart(Zend_Db_Select::FROM, $configurableFrom);
$select->where('e.type_id != ?', Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE);
$fields = array('count' => 'COUNT(DISTINCT(e.entity_id))', 'index.value', 'type_id' => '("configurable")');
$configurableSelect->columns($fields)->join(array('index' => $this->getTable('adjnav/catalog_product_index_configurable')), 'index.entity_id = l.' . $versionHelper->getProductIdChildColumn(), array())->where('index.store_id = ?', $this->getStoreId())->where('index.attribute_id = ?', $attribute->getId())->where('e.type_id = ?', Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE)->group('index.value');
return $configurableSelect;
}
开发者ID:sagmahajan,项目名称:aswan_release,代码行数:42,代码来源:CatalogIndexMysql4Attribute.php
示例16: _initProduct
/**
* Initialize product from request parameters
*
* @return Mage_Catalog_Model_Product
*/
protected function _initProduct()
{
$productId = (int) $this->getRequest()->getParam('id');
$product = Mage::getModel('catalog/product')->setStoreId($this->getRequest()->getParam('store', 0));
if (!$productId) {
if ($setId = (int) $this->getRequest()->getParam('set')) {
$product->setAttributeSetId($setId);
}
if ($typeId = $this->getRequest()->getParam('type')) {
$product->setTypeId($typeId);
}
}
if ($productId) {
$product->load($productId);
}
$attributes = $this->getRequest()->getParam('attributes');
if ($attributes && $product->isConfigurable() && (!$productId || !$product->getTypeInstance()->getUsedProductAttributeIds())) {
$product->getTypeInstance()->setUsedProductAttributeIds(explode(",", base64_decode(urldecode($attributes))));
}
// Init attribute label names for store selected in dropdown
Mage_Catalog_Model_Resource_Eav_Attribute::initLabels($product->getStoreId());
// Required attributes of simple product for configurable creation
if ($this->getRequest()->getParam('popup') && ($requiredAttributes = $this->getRequest()->getParam('required'))) {
$requiredAttributes = explode(",", $requiredAttributes);
foreach ($product->getAttributes() as $attribute) {
if (in_array($attribute->getId(), $requiredAttributes)) {
$attribute->setIsRequired(1);
}
}
}
if ($this->getRequest()->getParam('popup') && $this->getRequest()->getParam('product') && !is_array($this->getRequest()->getParam('product')) && $this->getRequest()->getParam('id', false) === false) {
$configProduct = Mage::getModel('catalog/product')->setStoreId(0)->load($this->getRequest()->getParam('product'))->setTypeId($this->getRequest()->getParam('type'));
/* @var $configProduct Mage_Catalog_Model_Product */
$data = array();
foreach ($configProduct->getTypeInstance()->getEditableAttributes() as $attribute) {
/* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
if (!$attribute->getIsUnique() && $attribute->getFrontend()->getInputType() != 'gallery' && $attribute->getAttributeCode() != 'required_options' && $attribute->getAttributeCode() != 'has_options' && $attribute->getAttributeCode() != $configProduct->getIdFieldName()) {
$data[$attribute->getAttributeCode()] = $configProduct->getData($attribute->getAttributeCode());
}
}
$product->addData($data)->setWebsiteIds($configProduct->getWebsiteIds());
}
$product->setData('_edit_mode', true);
Mage::register('product', $product);
Mage::register('current_product', $product);
return $product;
}
开发者ID:brentwpeterson,项目名称:magento_cart_promo,代码行数:52,代码来源:GroupedController.php
示例17: getGbaseAttributeType
/**
* Return Google Base Attribute Type By Product Attribute
*
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
* @return string Google Base Attribute Type
*/
public function getGbaseAttributeType($attribute)
{
$typesMapping = array('price' => 'floatUnit', 'decimal' => 'numberUnit');
if (isset($typesMapping[$attribute->getFrontendInput()])) {
return $typesMapping[$attribute->getFrontendInput()];
} elseif (isset($typesMapping[$attribute->getBackendType()])) {
return $typesMapping[$attribute->getBackendType()];
} else {
return Mage_GoogleBase_Model_Service_Item::DEFAULT_ATTRIBUTE_TYPE;
}
}
开发者ID:hazaeluz,项目名称:magento_connect,代码行数:17,代码来源:Attribute.php
示例18: addIndexableAttributeModifiedFilter
/**
* Add filter by indexable attribute
*
* @param Mage_CatalogSearch_Model_Resource_Advanced_Collection $collection
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
* @param string|array $value
* @return bool
*/
public function addIndexableAttributeModifiedFilter($collection, $attribute, $value)
{
if ($attribute->getIndexType() == 'decimal') {
$table = $this->getTable('catalog/product_index_eav_decimal');
} else {
$table = $this->getTable('catalog/product_index_eav');
}
$tableAlias = 'a_' . $attribute->getAttributeId();
$storeId = Mage::app()->getStore()->getId();
$select = $collection->getSelect();
if (is_array($value)) {
if (isset($value['from']) && isset($value['to'])) {
if (empty($value['from']) && empty($value['to'])) {
return false;
}
}
}
$select->distinct(true);
$select->join(array($tableAlias => $table), "e.entity_id={$tableAlias}.entity_id " . " AND {$tableAlias}.attribute_id={$attribute->getAttributeId()}" . " AND {$tableAlias}.store_id={$storeId}", array());
if (is_array($value) && (isset($value['from']) || isset($value['to']))) {
if (isset($value['from']) && !empty($value['from'])) {
$select->where("{$tableAlias}.value >= ?", $value['from']);
}
if (isset($value['to']) && !empty($value['to'])) {
$select->where("{$tableAlias}.value <= ?", $value['to']);
}
return true;
}
$select->where("{$tableAlias}.value IN(?)", $value);
return true;
}
开发者ID:hientruong90,项目名称:ee_14_installer,代码行数:39,代码来源:Advanced.php
示例19: _getAttributeLabel
/**
* Return Product Attribute Store Label
*
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
* @param int $storeId Store View Id
* @return string Attribute Store View Label or Attribute code
*/
protected function _getAttributeLabel($attribute, $storeId)
{
$frontendLabel = $attribute->getFrontend()->getLabel();
if (is_array($frontendLabel)) {
$frontendLabel = array_shift($frontendLabel);
}
if (!$this->_translations) {
$moduleName = Mage_Catalog_Model_Entity_Attribute::MODULE_NAME;
$separator = Mage_Core_Model_Translate::SCOPE_SEPARATOR;
$this->_translations = Mage::getModel('core/translate_string')->load($moduleName . $separator . $frontendLabel)->getStoreTranslations();
}
if (isset($this->_translations[$storeId])) {
return $this->_translations[$storeId];
} else {
return $attribute->getAttributeCode();
}
}
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:24,代码来源:Item.php
示例20: Mage_Catalog_Model_Resource_Setup
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Magento
* @package Mage_Catalog
* @subpackage integration_tests
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
$installer = new Mage_Catalog_Model_Resource_Setup('catalog_setup');
$attributeSetId = $installer->getAttributeSetId('catalog_product', 'Default');
$entityModel = new Mage_Eav_Model_Entity();
$entityTypeId = $entityModel->setType(Mage_Catalog_Model_Product::ENTITY)->getTypeId();
$groupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$attribute = new Mage_Catalog_Model_Resource_Eav_Attribute();
$attribute->setAttributeCode('filterable_attribute_a')->setEntityTypeId($entityTypeId)->setAttributeGroupId($groupId)->setAttributeSetId($attributeSetId)->setIsFilterable(1)->setIsUserDefined(1)->save();
$attribute = new Mage_Catalog_Model_Resource_Eav_Attribute();
$attribute->setAttributeCode('filterable_attribute_b')->setEntityTypeId($entityTypeId)->setAttributeGroupId($groupId)->setAttributeSetId($attributeSetId)->setIsFilterable(1)->setIsUserDefined(1)->save();
开发者ID:nemphys,项目名称:magento2,代码行数:31,代码来源:filterable_attributes.php
注:本文中的Mage_Catalog_Model_Resource_Eav_Attribute类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论