Magento - 500内部服务器错误 - 用于导入颜色的自定义脚本

时间:2015-01-28 13:18:16

标签: php magento

我的脚本有点像这样

$csv_array  = array();
    while ($row = fgetcsv($fp)) {
        $csv_array[trim($row[0])] = trim($row[1]);
    }

     $productModel = Mage::getModel('catalog/product');
    $attr = $productModel->getResource()->getAttribute("color");

    $csv_array = array_chunk($csv_array, 100, true);

    foreach($csv_array as $key => $chunk_arr) {

        foreach ($chunk_arr as $sku => $color) {
    unset($product);
    $color_id = null;

            //check sku is not empty
            if (empty($sku) && !isset($sku)) {
                continue;
            }


            //check if sku exists in Magento
            $product = $productModel->loadByAttribute('sku', $sku);


            if (!$product) {
                echo $sku . 'not found';
                continue;
            }

            //Set vendor item id to product object
            try {

                if ($attr->usesSource()) {
                    $color_id = $attr->getSource()->getOptionId($color);
                }

                Mage::getSingleton('catalog/product_action')->updateAttributes(array($product->getId()), array('color' => $color_id), $storeId);

                Mage::log($sku, null, 'import.log');

                echo 'Sku ' . $sku . ' updated!!!!<br/>';

            } catch (Exception $e) {

                echo 'Sku ' . $sku . ' not updated!!!!<br/>';
            }

        }
        unset($chunk_arr);
    }

我的脚本在执行循环100次后中断并抛出500服务器内部错误。如果您有任何建议,请帮助我。 我已经尝试了所有内容,例如内存限制,最大执行时间,上传文件大小,发布最大大小等等。

0 个答案:

没有答案