本文整理汇总了PHP中Mage_Catalog_Model_Resource_Eav_Attribute::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Resource_Eav_Attribute::getId方法的具体用法?PHP Mage_Catalog_Model_Resource_Eav_Attribute::getId怎么用?PHP Mage_Catalog_Model_Resource_Eav_Attribute::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Resource_Eav_Attribute
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Resource_Eav_Attribute::getId方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFilterModel
protected function getFilterModel()
{
$settings = $this->_getDataHelper()->getAttributesSettings();
$attributeId = $this->attribute->getId();
/** @var Amasty_Shopby_Model_Filter $model */
$model = isset($settings[$attributeId]) ? $settings[$attributeId] : null;
return $model;
}
示例2: 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();
}
}
}
示例3: _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;
}
示例4: array
* 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 license@magentocommerce.com 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 Test
* @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)
*/
/* Create attribute */
$installer = new Mage_Catalog_Model_Resource_Setup('catalog_setup');
$attribute = new Mage_Catalog_Model_Resource_Eav_Attribute();
$attribute->setData(array('attribute_code' => 'attribute_with_option', 'entity_type_id' => $installer->getEntityTypeId('catalog_product'), 'is_global' => 1, 'frontend_input' => 'select', 'is_filterable' => 1, 'option' => array('value' => array('option_0' => array(0 => 'Option Label'))), 'backend_type' => 'int'));
$attribute->save();
/* Assign attribute to attribute set */
$installer->addAttributeToGroup('catalog_product', 'Default', 'General', $attribute->getId());
/* Create simple products per each option */
$options = new Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection();
$options->setAttributeFilter($attribute->getId());
foreach ($options as $option) {
$product = new Mage_Catalog_Model_Product();
$product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default'))->setWebsiteIds(array(1))->setName('Simple Product ' . $option->getId())->setSku('simple_product_' . $option->getId())->setPrice(10)->setCategoryIds(array(2))->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->setStockData(array('use_config_manage_stock' => 1, 'qty' => 5, 'is_in_stock' => 1))->save();
Mage::getSingleton('Mage_Catalog_Model_Product_Action')->updateAttributes(array($product->getId()), array($attribute->getAttributeCode() => $option->getId()), $product->getStoreId());
}
示例5: getAttributeOptions
/**
* Loads attribute options by option ids
*
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
* @param array $optionIds
* @return array
*/
public function getAttributeOptions($attribute, $optionIds)
{
$collection = Mage::getResourceModel('eav/entity_attribute_option_collection')->setPositionOrder('asc')->setAttributeFilter($attribute->getId())->setStoreFilter($attribute->getStoreId())->addFieldToFilter('main_table.option_id', array('in' => $optionIds))->load();
return $collection->toOptionArray();
}
示例6: array
* 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) 2011 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/* Create attribute */
$installer = new Mage_Catalog_Model_Resource_Setup('catalog_setup');
$attribute = new Mage_Catalog_Model_Resource_Eav_Attribute();
$attribute->setData(array('attribute_code' => 'test_configurable', 'entity_type_id' => $installer->getEntityTypeId('catalog_product'), 'is_global' => 1, 'is_user_defined' => 1, 'frontend_input' => 'select', 'is_unique' => 0, 'is_required' => 1, 'is_configurable' => 1, 'is_searchable' => 0, 'is_visible_in_advanced_search' => 0, 'is_comparable' => 0, 'is_filterable' => 0, 'is_filterable_in_search' => 0, 'is_used_for_promo_rules' => 0, 'is_html_allowed_on_front' => 1, 'is_visible_on_front' => 0, 'used_in_product_listing' => 0, 'used_for_sort_by' => 0, 'frontend_label' => array(0 => 'Test Configurable'), 'option' => array('value' => array('option_0' => array(0 => 'Option 1'), 'option_1' => array(0 => 'Option 2')), 'order' => array('option_0' => 1, 'option_1' => 2)), 'backend_type' => 'int'));
$attribute->save();
/* Assign attribute to attribute set */
$installer->addAttributeToGroup('catalog_product', 'Default', 'General', $attribute->getId());
/* Create simple products per each option */
$options = new Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection();
$options->setAttributeFilter($attribute->getId());
$attributeValues = array();
$productsData = array();
foreach ($options as $option) {
$product = new Mage_Catalog_Model_Product();
$product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)->setId($option->getId() * 10)->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default'))->setWebsiteIds(array(1))->setName('Configurable Option' . $option->getId())->setSku('simple_' . $option->getId())->setPrice(10)->setTestConfigurable($option->getId())->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE)->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->setStockData(array('use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1))->save();
$dataOption = array('label' => 'test', 'attribute_id' => $attribute->getId(), 'value_index' => $option->getId(), 'is_percent' => false, 'pricing_value' => 5);
$productsData[$product->getId()] = array($dataOption);
$attributeValues[] = $dataOption;
}
$product = new Mage_Catalog_Model_Product();
$product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE)->setId(1)->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default'))->setWebsiteIds(array(1))->setName('Configurable Product')->setSku('configurable')->setPrice(100)->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->setStockData(array('use_config_manage_stock' => 1, 'is_in_stock' => 1))->setConfigurableProductsData($productsData)->setConfigurableAttributesData(array(array('attribute_id' => $attribute->getId(), 'attribute_code' => $attribute->getAttributeCode(), 'frontend_label' => 'test', 'values' => $attributeValues)))->save();
示例7: getInsertValues
/**
* Retrieve data to be insterted after processing attribute
*
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
* @param int $storeId
* @return array
*/
protected function getInsertValues($attribute, $storeId)
{
$collection = Mage::getResourceModel('eav/entity_attribute_option_collection')->setStoreFilter($storeId)->setPositionOrder('asc')->setAttributeFilter($attribute->getId())->load();
$options = $collection->toOptionArray();
$data = array();
foreach ($options as $option) {
// Generate url value
$urlValue = $this->getHelper()->transliterate($option['label']);
// Check if this url key is taken and add -{count}
$count = 0;
$origUrlValue = $urlValue;
do {
$found = false;
foreach ($data as $line) {
if ($line['url_value'] == $urlValue) {
$found = true;
}
}
if ($found) {
$urlValue = $origUrlValue . '-' . ++$count;
}
} while ($found);
$data[] = array('attribute_code' => $attribute->getAttributeCode(), 'attribute_id' => $attribute->getId(), 'store_id' => $storeId, 'option_id' => $option['value'], 'url_key' => $this->getHelper()->transliterate($attribute->getStoreLabel($storeId)), 'url_value' => $urlValue);
}
return $data;
}
示例8: getPriceRangeFromAttribute
/**
* Retrieve array with products counts per price range
*
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
* @return array
*/
public function getPriceRangeFromAttribute($attribute)
{
$ret = 0;
if (!$attribute) {
return $ret;
}
// hook, it is need for 'union' and this attribute defined in the 'price' field
if ($attribute->getAttributeCode() == 'price') {
$label = 'price';
} else {
$label = 'attribute_' . $attribute->getId();
}
$vals = array();
$res = $this->getSearchResult();
if (!empty($res['facets'])) {
foreach ($res['facets'] as $facet) {
if ($facet['attribute'] == $label) {
if (!empty($facet['buckets'])) {
foreach ($facet['buckets'] as $bucket) {
// Example
//~ [value] => 1000-2000
//~ [title] => 1000 - 2000
//~ [from] => 1000
//~ [to] => 2000
//~ [count] => 2
return $bucket['to'] - $bucket['from'];
}
}
}
}
}
return $ret;
}
示例9: getPriceRangeFromAttribute
/**
* Retrieve array with products counts per price range
*
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
* @return array
*/
public function getPriceRangeFromAttribute($attribute)
{
$ret = 0;
if (!$attribute) {
return $ret;
}
$label = 'attribute_' . $attribute->getId();
$vals = array();
$res = $this->getSearchResult();
if (!empty($res['facets'])) {
foreach ($res['facets'] as $facet) {
if ($facet['attribute'] == $label) {
if (!empty($facet['buckets'])) {
foreach ($facet['buckets'] as $bucket) {
// Example
//~ [value] => 1000-2000
//~ [title] => 1000 - 2000
//~ [from] => 1000
//~ [to] => 2000
//~ [count] => 2
return $bucket['to'] - $bucket['from'];
}
}
}
}
}
return $ret;
}