致命错误:未捕获错误:无法将stdClass类型的对象用作数组

时间:2019-05-04 20:05:51

标签: php

我对php不太熟悉,但是需要解决下一个问题/

在运行php文件时,出现带有以下文本的错误消息:

"Fatal error: Uncaught Error: Cannot use object of type stdClass as array in /home/darico00/darico.com.ua/www/system/storage/modification/admin/model/catalog/product.php:136
Stack trace:
#0 /home/darico00/darico.com.ua/www/system/storage/modification/admin/model/catalog/product.php(769): ModelCatalogProduct->addOctProductFilterData(5994, Array)
#1 /home/darico00/darico.com.ua/www/system/storage/modification/system/engine/loader.php(178): ModelCatalogProduct->addProduct(Array)
#2 /home/darico00/darico.com.ua/www/system/engine/proxy.php(25): Loader->{closure}(Array, Array)
#3 /home/darico00/darico.com.ua/www/admin/controller/extension/module/import1c.php(510): Proxy->__call('addProduct', Array)
#4 /home/darico00/darico.com.ua/www/admin/controller/extension/module/import1c.php(159): ControllerExtensionModuleImport1c->syncProducts(Array)
#5 /home/darico00/darico.com.ua/www/system/storage/modification/system/engine/action.php(51): ControllerExtensionModuleImport1c->sync()
#6 /home/darico00/darico.com.ua/www/system/engine/front. in /home/darico00/darico.com.ua/www/system/storage/modification/admin/model/catalog/product.php on line 136"

这是用于将商品和类别从xml文件导入到openCart管理面板中

如果我理解正确的数字136、769、178、510、159、51、136是出现错误的行。

  if (!isset($products[$productId])) {
                $products[$productId] = [
                    'product_id' => $productId,
                    'category_id' => (int) $xmlItem->categoryId,
                    'name' => (string) $xmlItem->productName,
                    'sku' => (string) $xmlItem->article,
                    'attributes' => $attributes,
                    'price' => (string) $xmlItem->price,
                    'brand' => $brand,
                    'quantity' => $quantity,
   'dimensions'=>isset($xmlItem->dimensions)?(string)$xmlItem->dimensions : 0,
               'weight'=>isset($xmlItem->weight)?(string)$xmlItem->weight : 0,
line 136 is here---> 'offers' => [
                        [
                            'offer_id' => $offerId,
                            'xml_id' => (string) $xmlItem->xmlId,
                            'size' => trim($size),
                            'quantity' => $quantity,
                        ],
                    ]
                ];
            } else {
                $products[$productId]['quantity'] += $quantity;
                $products[$productId]['offers'][] = [
                    'offer_id' => $offerId,
                    'xml_id' => (string) $xmlItem->xmlId,
                    'size' => $size,
                    'quantity' => $quantity,
                ];
            }

预期结果:导入到openCart管理面板中的商品和类别

实际结果:进程在添加好消息时卡住了。

下一行来自日志文件。

2019-05-04 19:10:01 SYNC : START 
2019-05-04 19:10:01 Parsed categories : 7 
2019-05-04 19:10:01 Category found, updating : 100001 
2019-05-04 19:10:01 Category found, updating : 100105 
2019-05-04 19:10:01 Category found, updating : 100136 
2019-05-04 19:10:01 Category found, updating : 100211 
2019-05-04 19:10:01 Category found, updating : 100226 
2019-05-04 19:10:01 Category found, updating : 100212 
2019-05-04 19:10:01 Category found, updating : 100213 
2019-05-04 19:10:01 Product, updating : 100307 
2019-05-04 19:10:01 Product, adding : 100308

0 个答案:

没有答案