dongtao1262 2019-02-28 14:50
浏览 85

Mage :: getModel() - > getCollection()不返回产品

I'm trying to retreive the products from one certain shop in magento. The thing is that the script seems only to work when there are no other shops.

error_reporting(E_ALL);
ini_set('display_errors', '1');
chdir ( dirname ( __FILE__ ) );
$my_folder = dirname ( realpath ( __FILE__ ) );
date_default_timezone_set ( 'Europe/Amsterdam' );
define('MAGENTO_ROOT', $my_folder);
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
require_once($mageFilename);
$app = Mage::app();
Mage::app()->setCurrentStore(1);
$url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);

function getMainWithVariantsProducts(){

    $productModel = Mage::getModel('catalog/product')->getCollection()
    ->addAttributeToSelect('*')
    ->addAttributeToFilter('type_id', array('eq' => 'configurable'))
    ->setPageSize(100000);

    $main = array();
    $variants = array();

    foreach ($productModel as $_product) {
        echo "<pre>";
        print_r($_product);
        echo "</pre>";
    }
}


mainProduct();

So When I try with it a Magento server with 1 shop it works, ben when I try it with another Magento server it doesn't work.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 关于大棚监测的pcb板设计
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用
    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入