3

当您调用Mage::getModel('catalog/category')or时,是从平面数据还是表格Mage::getModel('catalog/product')中加载?_entity

管理员中有一个选项可以让您“使用平面”数据,我想知道这是否与::getModel()通话有关。

4

1 回答 1

3

The catalog/category model is an EAV model. In a default Magento configuration, its data is stored in

catalog_category_entity
catalog_category_entity_datetime
catalog_category_entity_decimal
catalog_category_entity_int
catalog_category_entity_text
catalog_category_entity_varchar

The catalog/category model also has a "flat catalog" feature in System -> Configuration -> Catalog -> Use Flat Catalog Category. With this enabled the catalog/category model will pull data from one of the flat categories

catalog_category_flat_store_*

Either way, you can use the catalog/category collection object to query this data any way you see fit, including the addAttributeToFilter method.

$collection = Mage::getModel('catalog/category')
    ->getCollection()
    ->addAttributeToSelect('*');

$collection->addAttributeToFilter(
    'url_path', array('like' => 'apparel%')
);

foreach($collection as $item)
{
    var_dump($item->getData());
}
于 2013-04-19T17:55:43.493 回答