MagentoとPHPを初めて使用していて、オブジェクトから値を取得しようとしています。Magento - Mage_Catalog_Model_Resource_Product_Collectionオブジェクトの値にアクセスする
$_productCollection=$this->getLoadedProductCollection();
私は
Mage_Catalog_Model_Resource_Product_Collection Object
(
[_flatEnabled:protected] => Array
(
[1] =>
)
[_productWebsiteTable:protected] => sn_catalog_product_website
[_productCategoryTable:protected] => sn_catalog_category_product
[_addUrlRewrite:protected] => 1
[_urlRewriteCategory:protected] => 3
[_addMinimalPrice:protected] =>
[_addFinalPrice:protected] =>
[_allIdsCache:protected] =>
[_addTaxPercents:protected] => 1
[_productLimitationFilters:protected] => Array
(
[category_id] => 3
[category_is_anchor] => 1
[store_id] => 1
[use_price_index] => 1
[customer_group_id] => 0
[website_id] => 1
[visibility] => Array
(
[0] => 2
[1] => 4
)
)
)
以下のようなものをprint_r()
を取得していないと私は、この中に、カテゴリIDを取得する必要があります。 は、誰かがあなたが取得しようとすると、この最初の
$_productCollection=$this->getLoadedProductCollection();
foreach($_productCollection as $product){
//display data that object contains
//print_r($product->getData());
//display category id's that product is associated with
//print_r($product->getCategoryIds());
}
FYI:Magentoでは、コレクションはデータモデルのコレクションを含む可能性のある反復可能なリソースオブジェクトです。閉じ込められたアイテムのデータについて知るために、 'foreach($ collection as $ item)'と内部で '$ item-> debug()'を使うことができます。 – benmarks