2013-01-04 68 views
2

我正在使用magento 1.7。我有问题,我不知道为什么会发生这种情况。然后我在后台的编辑只开放式产品点击复制然后,我就当我尝试下面的代码调试文件下列错误尝试复制产品时出现Magento错误

Warning: Illegal string offset 'new_file' in D:\wamp\www\easyshop\app\code\core\Mage\Catalog\Model\Product\Attribute\Backend\Media.php on line 158 

print_r($newImages); 
die; 

然后我得到这个以下数据

Array 
(
    [/s/a/samsung_galaxy_s2_front1.jpg] => /s/a/samsung_galaxy_s2_front1_4.jpg 
    [/s/g/sgs2p1.jpg] => /s/g/sgs2p1_4.jpg 
    [/s/g/sgs2_11.jpg] => /s/g/sgs2_11_4.jpg 
    [/s/g/sgs2-4386.jpg] => /s/g/sgs2-4386_4.jpg 
) 

我东西阵列键是错的,请你给解决方案来解决这个问题

+0

也许是因为你在Windows上运行它,而Magento在Windows上不受支持? – Kenny

+0

我可以确认这发生在OS X上。 – Dayson

回答

7

我在1.7.02有同样的问题。我找到的解决方案是改变Magento(IMHO)窃听代码。

在Mage_Catalog_Model_Product_Attribute_Backend_Media我已经改变了线路,你发现:

 // For duplicating we need copy original images. 
     $duplicate = array(); 
     foreach ($value['images'] as &$image) { 
      if (!isset($image['value_id'])) { 
       continue; 
      } 
      $duplicate[$image['value_id']] = $this->_copyImage($image['file']); 
      $newImages[$image['file']] = $duplicate[$image['value_id']]; 
     } 

为:

 // For duplicating we need copy original images. 
     $duplicate = array(); 
     foreach ($value['images'] as &$image) { 
      if (!isset($image['value_id'])) { 
       continue; 
      } 
      $duplicate[$image['value_id']] = $this->_copyImage($image['file']); 
      $newImages[$image['file']] = array(); 
      $newImages[$image['file']]['new_file'] = $duplicate[$image['value_id']]; 
      $newImages[$image['file']]['label'] = $image['label']; 
     } 

它为我做的伎俩...图片已被正确地复制并启用了新产品。

+1

你救了我的屁股谢谢!写作它作为原始类的延伸! :) – koramaiku

+0

这对我有用:在5.3.15下使用magento 1.7.0.2没有问题。升级到php 5.5.9后出现错误。 magento 1.7.0.2的php 5.4补丁也无法运行。 –

+0

这工作对我1.6.2.0 –