图像不存在 - Magento SOAP

时间:2014-12-18 08:38:37

标签: php magento soap nginx

将我的Magento安装从apache移动到nginx后,我的soap扩展卡在图像导入时停留。 我已经花了几天时间来解决这个问题,但没有任何解决方案。我希望你能帮助我。

这是我在SOAP终端中遇到的错误:

stack trace:
#0 /data/web/public/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php(274): Mage::throwException('image does not exist')
#1 /data/web/public/app/code/core/Mage/Catalog/Model/Product.php(1042): Mage_Catalog_Model_Product_Attribute_Backend_Media->addImage(Object(Mage_Catalog_Model_Product), '/data/web/publi...', NULL, true, false)
#2 /data/web/public/app/code/local/Ekomurz/KingConnector/controllers/Ekomurz_KingConnector_ApiHandler.php(1284): Mage_Catalog_Model_Product->addImageToMediaGallery('/data/web/publi...', NULL, true, false)
#3 /data/web/public/app/code/local/Ekomurz/KingConnector/controllers/Ekomurz_KingConnector_ApiHandler.php(698): Ekomurz_KingConnector_ApiHandler->_add_product_image(Object(Mage_Catalog_Model_Product), 'Timmsgiol100_gr...', Array)
#4 /data/web/public/app/code/local/Ekomurz/KingConnector/controllers/Ekomurz_KingConnector_ApiHandler.php(640): Ekomurz_KingConnector_ApiHandler->ProcessArticle(Object(DOMElement))
#5 /data/web/public/app/code/local/Ekomurz/KingConnector/controllers/Ekomurz_KingConnector_ApiHandler.php(122): Ekomurz_KingConnector_ApiHandler->processArticles()
#6 /data/web/public/app/code/local/Ekomurz/KingConnector/controllers/Ekomurz_KingConnector_ApiHandler.php(60): Ekomurz_KingConnector_ApiHandler->handlePostData()
#7 /data/web/public/app/code/local/Ekomurz/KingConnector/controllers/Ekomurz_KingConnector_ApiHandler.php(33): Ekomurz_KingConnector_ApiHandler->callApiFunction('<?xml version="...', 'handlePostData')
#8 [internal function]: Ekomurz_KingConnector_ApiHandler->PostData('<?xml version="...')
#9 /data/web/public/app/code/local/Ekomurz/KingConnector/controllers/ApiController.php(18): SoapServer->handle()
#10 /data/web/public/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Ekomurz_KingConnector_ApiController->indexAction()
#11 /data/web/public/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index')
#12 /data/web/public/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#13 /data/web/public/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#14 /data/web/public/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#15 /data/web/public/index.php(84): Mage::run('hertog_hengelsp...', 'store')
#16 {main}

在/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php(274)中说“图片不存在”

 /**
     * Add image to media gallery and return new filename
     *
     * @param Mage_Catalog_Model_Product $product
     * @param string                     $file              file path of image in file system
     * @param string|array               $mediaAttribute    code of attribute with type 'media_image',
     *                                                      leave blank if image should be only in gallery
     * @param boolean                    $move              if true, it will move source file
     * @param boolean                    $exclude           mark image as disabled in product page view
     * @return string
     */
    public function addImage(

    Mage_Catalog_Model_Product $product, $file, $mediaAttribute = null, $move = false, $exclude = true)
    { 
        $file = realpath($file);    

        if (!$file || !file_exists($file)) {

         Mage::throwException("image does not exist");          

        }

这是在API处理程序

中添加图像的包装器
  /**
    * wrapper to add image
    * 
    * @param mixed $product
    * @param mixed $filename
    * @param mixed $filedata
    * @param mixed $mediaAttribute: 'thumbnail', 'small_image' or 'image'
    */
    private function _add_product_image($product, $filename, $filedata, $mediaAttribute) {
        $data = $product->getData();
       if (!empty($data['media_gallery']['images'])) {
            $images = $data['media_gallery']['images'];
            foreach ($images as $index => $image) {
                if (strpos($image['file'], $filename)) {
                // image is already present: bail out to prevent duplicates
                // Note: this means that if the contents of the image are updated, the user has to manually remove the
                // image first
                 return;                
                }
            }
        }


        $tempPath = Mage::getConfig()->getTempVarDir() . "/" . "tempfile";
        $filePath = Mage::getConfig()->getTempVarDir() . '/' . str_ireplace("\\"," ",basename($filename));
        $filePath = str_replace(" ","_",$filePath);
        // print $tempPath . " - " . $filePath; die ("BOEF");
        $file     = fopen($tempPath, 'w');
        fwrite($file, $filedata);
        fclose($file);

        $convert = "/usr/bin/convert";
        $convertString = " -density 72x72 -background white -flatten";
        $testDir  = realpath(Mage::getConfig()->getTempVarDir());
        $fullName = realpath($tempPath);
        $outName  = $testDir . "/" . str_ireplace("\\"," ",basename($filename));
        $outName  = str_replace(" ","_",$outName);

        exec ('"' . $convert . '"' . " -quality 100 " . $convertString . " " . $fullName . " jpg:" . $outName);
        unlink($tempPath);

        // last param is exclude from view in product page - so true or false ; let's try false first
        $product->addImageToMediaGallery($filePath, $mediaAttribute, true, false);
    }

我希望有人可以在这个复杂的问题上帮助我!提前谢谢!

0 个答案:

没有答案