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.

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

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!