本文整理汇总了PHP中Mage_Catalog_Model_Resource_Eav_Attribute::getAttributeId方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Resource_Eav_Attribute::getAttributeId方法的具体用法?PHP Mage_Catalog_Model_Resource_Eav_Attribute::getAttributeId怎么用?PHP Mage_Catalog_Model_Resource_Eav_Attribute::getAttributeId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Resource_Eav_Attribute
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Resource_Eav_Attribute::getAttributeId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addIndexableAttributeFilter
/**
* Add filter by indexable attribute
*
* @param Mage_CatalogSearch_Model_Advanced $object
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
* @param string|array $value
*/
public function addIndexableAttributeFilter($object, $attribute, $value)
{
if (is_string($value) && strlen($value) == 0) {
return false;
}
if ($attribute->getIndexType() == 'decimal') {
$table = $this->getTable('catalog/product_index_eav_decimal');
} else {
$table = $this->getTable('catalog/product_index_eav');
}
$tableAlias = 'ast_' . $attribute->getAttributeCode();
$storeId = Mage::app()->getStore()->getId();
$select = $object->getProductCollection()->getSelect();
$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;
}
示例2: 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;
}
示例3: addCustomIndexableAttributeModifiedFilter
/**
* 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 addCustomIndexableAttributeModifiedFilter($collection, $attribute, $value)
{
if ($attribute->getIndexType() == 'decimal') {
$table = $this->getTable('catalog/product_index_eav_decimal');
} else {
$table = $this->getTable('catalog/product_entity_int');
}
$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), "cp.child_id={$tableAlias}.entity_id " . " AND {$tableAlias}.attribute_id={$attribute->getAttributeId()}" . " AND {$tableAlias}.store_id={$storeId}", array());
/*$select->joinLeft(
array( 'catalog_product_entity_int'),
"catalog_product_entity_int.attribute_id={$attribute->getAttributeId()} ",
array()
);
$select->join(
array( 'catalog_product_bundle_selection'),
"catalog_product_entity_int.entity_id=catalog_product_bundle_selection.product_id "
. " AND e.entity_id=catalog_product_bundle_selection.parent_product_id",
array("other_product_id"=>"catalog_product_bundle_selection.product_id")
); */
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", $value);
return true;
}