dsjxgu4759 2013-06-20 19:29
浏览 28
已采纳

从Magento中的自定义PHP脚本访问产品和类别信息

What I'm trying to do is gain access to all of my product and category information in a particular store from a custom PHP script in Magento. I have already included Mage.php, and can access the store info, but I'm not sure how to proceed from here

 <?php 
 include '../../../../app/Mage.php';

 $allStores = Mage::app()->getStore(6);

 var_dump($allStores);
  ?>

This gives me access to the store information, but if i try to call ->getProduct() it throws an error

  • 写回答

1条回答 默认 最新

  • douningchang3610 2013-06-20 20:24
    关注

    You are most likely looking for a product collection, which is a Magento data structure that contains a grouping of products:

    $collection = Mage::getModel('catalog/product')->getCollection();
    $collection->addAttributeToSelect('*');
    $collection->addStoreFilter(8);
    
    foreach ($collection as $product) {
        Zend_Debug::dump($product->getData());
    }
    
    $categories = Mage::getModel('catalog/category')->getCollection();
    
    foreach ($categories as $category) {
        Zend_Debug::dump($category)
    }
    

    The product object in Magento is fairly complex, given Magento's EAV data structure.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?