Help for integrating the Laravel package
Forum rules: Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#3530 by George Horvath
17 Oct 2016, 10:23
Hi !
I found some issue and need some help to resolve.

My csv import works well, but when im trying to import the same csv (for test or for update some products) it stops with error message on first csv line:
local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Call to a member function fromArray() on null' in C:\xampp\htdocs\fundango\ext\ai-controller-jobs\controller\common\src\Controller\Common\Product\Import\Csv\Processor\Price\Standard.php:110

Im diggind about the error and found this in the standard php: from line 99 to line 111

Code: Select allif( ( $listItem = array_shift( $listItems ) ) !== null ) {
               $refItem = $listItem->getRefItem();
            } else {
               $listItem = $listManager->createItem();
               $refItem = $manager->createItem();
            }

            $typecode = ( isset( $list['price.type'] ) ? $list['price.type'] : 'default' );
            $list['price.typeid'] = $this->getTypeId( 'price/type', 'product', $typecode );
            $list['price.domain'] = 'product';

            $refItem->fromArray( $this->addItemDefaults( $list ) );
            $manager->saveItem( $refItem );

I think there is a mistake because the $refItem doesn exists, because you want to call any method on an Array:
$listItem = array_shift( $listItems ) ---this allways return false or an Array !!!
How can we solve this issue???

Thanks for any help, if i can fix this on your help i will request a pull on github aout this issue.

(some other info): this issue same on some text field (long text, short texts)
if I empty this fields (only change name or size attribute) it works for update... so i think the same errors on that standard.php too...

George
#3540 by aimeos
19 Oct 2016, 14:08
According to the PHP docs (http://php.net/manual/en/function.array-shift.php), array_shift() returns either the value or null but never false.

According to your thrown error, it seems that $listitem->getRefItem() returns null which means there's a list entry in mshop_product_list available but not the referenced item in mshop_price, hence a dangling reference. Can you confirm that?
#3550 by alfredlaggner
19 Oct 2016, 18:22
I put a print_r to display listItem. I my case it returned this:
Code: Select allAimeos\MShop\Common\Item\Lists\Standard Object
(
    [prefix:Aimeos\MShop\Common\Item\Lists\Standard:private] => product.lists.
    [values:Aimeos\MShop\Common\Item\Lists\Standard:private] => Array
        (
            [product.lists.id] => 1591
            [product.lists.parentid] => 2791
            [product.lists.siteid] => 1
            [product.lists.typeid] => 10
            [product.lists.domain] => price
            [product.lists.refid] => 820
            [product.lists.datestart] =>
            [product.lists.dateend] =>
            [product.lists.config] => Array
                (
                )

            [product.lists.position] => 0
            [product.lists.status] => 1
            [product.lists.mtime] => 2016-10-18 23:08:38
            [product.lists.editor] => aimeos:jobs
            [product.lists.ctime] => 2016-10-18 22:57:25
            [product.lists.type] => default
            [product.lists.typename] => Standard
        )

    [refItem:Aimeos\MShop\Common\Item\Lists\Standard:private] =>
    [modified:Aimeos\MShop\Common\Item\Base:private] =>
    [prefix:Aimeos\MShop\Common\Item\Base:private] => product.lists.
    [values:Aimeos\MShop\Common\Item\Base:private] => Array
        (
            [product.lists.id] => 1591
            [product.lists.parentid] => 2791
            [product.lists.siteid] => 1
            [product.lists.typeid] => 10
            [product.lists.domain] => price
            [product.lists.refid] => 820
            [product.lists.datestart] =>
            [product.lists.dateend] =>
            [product.lists.config] => Array
                (
                )

            [product.lists.position] => 0
            [product.lists.status] => 1
            [product.lists.mtime] => 2016-10-18 23:08:38
            [product.lists.editor] => aimeos:jobs
            [product.lists.ctime] => 2016-10-18 22:57:25
            [product.lists.type] => default
            [product.lists.typename] => Standard
        )

)


I have trouble understanding that but it may help to decipher the problem.
Also $refItem returned null.
#3551 by aimeos
19 Oct 2016, 21:35
Can you have a look why there's no price item with ID 820 (product.lists.refid) in your database? It must have been created during the first import, the big question is why it's now missing ...
#3553 by George Horvath
20 Oct 2016, 09:26
aimeos wrote:According to the PHP docs (http://php.net/manual/en/function.array-shift.php), array_shift() returns either the value or null but never false.

According to your thrown error, it seems that $listitem->getRefItem() returns null which means there's a list entry in mshop_product_list available but not the referenced item in mshop_price, hence a dangling reference. Can you confirm that?

You're right sir... mistake.. value or null.
#3555 by alfredlaggner
20 Oct 2016, 17:05
1)I created a new database according to your suggesteions
2)I imported 1 product without error
3) I created one product manually
4) I attempted to import 100 products
I crashed with this error:
Code: Select allvagrant@homestead:~/Code/aimeos$ php artisan aimeos:jobs product/import/csv
Executing the Aimeos jobs for "default"
Aimeos\MShop\Common\Item\Lists\Standard Object
(
    [prefix:Aimeos\MShop\Common\Item\Lists\Standard:private] => product.lists.
    [values:Aimeos\MShop\Common\Item\Lists\Standard:private] => Array
        (
            [product.lists.id] => 1
            [product.lists.parentid] => 1
            [product.lists.siteid] => 1
            [product.lists.typeid] => 10
            [product.lists.domain] => price
            [product.lists.refid] => 1
            [product.lists.datestart] =>
            [product.lists.dateend] =>
            [product.lists.config] => Array
                (
                )

            [product.lists.position] => 0
            [product.lists.status] => 1
            [product.lists.mtime] => 2016-10-20 14:51:38
            [product.lists.editor] => aimeos:jobs
            [product.lists.ctime] => 2016-10-20 14:51:38
            [product.lists.type] => default
            [product.lists.typename] => Standard
        )

    [refItem:Aimeos\MShop\Common\Item\Lists\Standard:private] =>
    [modified:Aimeos\MShop\Common\Item\Base:private] =>
    [prefix:Aimeos\MShop\Common\Item\Base:private] => product.lists.
    [values:Aimeos\MShop\Common\Item\Base:private] => Array
        (
            [product.lists.id] => 1
            [product.lists.parentid] => 1
            [product.lists.siteid] => 1
            [product.lists.typeid] => 10
            [product.lists.domain] => price
            [product.lists.refid] => 1
            [product.lists.datestart] =>
            [product.lists.dateend] =>
            [product.lists.config] => Array
                (
                )

            [product.lists.position] => 0
            [product.lists.status] => 1
            [product.lists.mtime] => 2016-10-20 14:51:38
            [product.lists.editor] => aimeos:jobs
            [product.lists.ctime] => 2016-10-20 14:51:38
            [product.lists.type] => default
            [product.lists.typename] => Standard
        )

)


  [Symfony\Component\Debug\Exception\FatalThrowableError]
  Call to a member function fromArray() on null




I used these mappings:
Code: Select all    'controller' => [
        'jobs' => [
            'product' => [
                'import' => [
                    'csv' => [
                        'location' => storage_path('secure') . '/public/uploads',
                        'container' => [
                            'type' => 'Directory',
                            'content' => 'CSV',
                        ],
                        'skip-lines' => 1,
                        'mapping' => [
                            'item' => [
                                0 => 'product.code', // e.g. unique EAN code
                                1 => 'product.type', // type of the product, e.g. "default" or "selection"
                                2 => 'product.status', // enabled (1) or disabled (0)
                                3 => 'product.label', // UTF-8 encoded text, also used as product name
                            ],
                            'text' => [
                                4 => 'text.type', // e.g. "short" for short description
                                5 => 'text.content', // UTF-8 encoded text
                                6 => 'text.type', // e.g. "long" for long description
                                7 => 'text.content', // UTF-8 encoded text
                            ],
                            'media' => [
                                8 => 'media.url', // relative URL of the product image on the server
                            ],
                            'price' => [
                                9 => 'price.typeid',
                                10 => 'price.currencyid',
                                11 => 'price.quantity', // the quantity the price is valid from (for block pricing)
                                12 => 'price.value', // price with decimals separated by a dot, no thousand separator

                                13 => 'price.typeid',
                                14 => 'price.currencyid',
                                15 => 'price.quantity', // the quantity the price is valid from (for block pricing)
                                16 => 'price.value', // price with decimals separated by a dot, no thousand separator

                                17 => 'price.typeid',
                                18 => 'price.currencyid',
                                19 => 'price.quantity', // the quantity the price is valid from (for block pricing)
                                20 => 'price.value', // price with decimals separated by a dot, no thousand separator

                                21 => 'price.typeid',
                                22 => 'price.currencyid',
                                23 => 'price.quantity', // the quantity the price is valid from (for block pricing)Call to a me
                                24 => 'price.value', // price with decimals separated by a dot, no thousand separator
                            ],
                            'stock' => [
                                25 => 'product.stock.stocklevel',
                                26 => 'product.stock.warehouseid',
                            ]

                        ],
                    ],
                ],
            ],
        ],
    ],


Output in produc.list
Code: Select allort by key:

+ Options
 Full texts   
id
typeid
parentid
siteid
domain
refid
start
end
config
pos
status
mtime
ctime
editor

Edit Edit
 Copy Copy
 Delete Delete
1
10
1
1
price
1
NULL
NULL
[]
0
1
2016-10-20 14:51:38
2016-10-20 14:51:38
aimeos:jobs

Edit Edit
 Copy Copy
 Delete Delete
2
10
1
1
price
2
NULL
NULL
[]
1
1
2016-10-20 14:51:38
2016-10-20 14:51:38
aimeos:jobs

Edit Edit
 Copy Copy
 Delete Delete
3
10
1
1
price
3
NULL
NULL
[]
2
1
2016-10-20 14:51:38
2016-10-20 14:51:38
aimeos:jobs

Edit Edit
 Copy Copy
 Delete Delete
4
10
1
1
price
4
NULL
NULL
[]
3
1
2016-10-20 14:51:38
2016-10-20 14:51:38
aimeos:jobs

Edit Edit
 Copy Copy
 Delete Delete
5
8
1
1
media
1
NULL
NULL
[]
0
1
2016-10-20 14:51:39
2016-10-20 14:51:39
aimeos:jobs

Edit Edit
 Copy Copy
 Delete Delete
6
13
1
1
text
1
NULL
NULL
[]
0
1
2016-10-20 14:51:40
2016-10-20 14:51:40
aimeos:jobs

Edit Edit
 Copy Copy
 Delete Delete
7
13
1
1
text
2
NULL
NULL
[]
1
1
2016-10-20 14:51:40
2016-10-20 14:51:40
aimeos:jobs

Edit Edit
 Copy Copy
 Delete Delete
8
13
2
1
text
3
NULL
NULL
[]
0
1
2016-10-20 15:19:55
2016-10-20 15:19:55
admin@aimeos.org

Edit Edit
 Copy Copy
 Delete Delete
9
10
2
1
price
5
NULL
NULL
[]
0
1
2016-10-20 15:26:25
2016-10-20 15:26:25
admin@aimeos.org


I wish I could send you the database but attachments are not allowed.

Also when I try to show products on front end I get this:

Code: Select allWhoops, looks like something went wrong.

1/1
Exception in Standard.php line 518:
Locale item for site "default" not found
in Standard.php line 518
at Standard->bootstrapBase('default', '', '', true, object(Standard), array('1'), array('1')) in Standard.php line 131
at Standard->bootstrap('default', '', '', true)
at call_user_func_array(array(object(Standard), 'bootstrap'), array('default', '', '', true)) in Base.php line 51
at Base->__call('bootstrap', array('default', '', '', true)) in Locale.php line 64
at Locale->get(object(Standard)) in Context.php line 100
at Context->get() in Page.php line 76
at Page->getSections('catalog-list') in CatalogController.php line 62
at CatalogController->listAction()
at call_user_func_array(array(object(CatalogController), 'listAction'), array()) in Controller.php line 55
at Controller->callAction('listAction', array()) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(CatalogController), 'listAction') in Route.php line 189
at Route->runController() in Route.php line 144
at Route->run(object(Request)) in Router.php line 642
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Router.php line 644
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 618
at Router->dispatchToRoute(object(Request)) in Router.php line 596
at Router->dispatch(object(Request)) in Kernel.php line 267
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 149
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
at Kernel->handle(object(Request)) in index.php line 53
#3556 by aimeos
21 Oct 2016, 09:45
You have to enable the default site in the Locale tab of the expert mode admin interface.

If you don't create one product by hand, does it work in this case?
#3557 by alfredlaggner
21 Oct 2016, 15:16
If you don't create one product by hand, does it work in this case?


No it does not.
I created a new database. Imported all my products. The I created a catalog and manually moved all products into the catalog to see the front end.

When I tried to import again import crashed with same error.

Code: Select all  php artisan aimeos:jobs product/import/csv
Executing the Aimeos jobs for "default"
Aimeos\MShop\Common\Item\Lists\Standard Object
(
    [prefix:Aimeos\MShop\Common\Item\Lists\Standard:private] => product.lists.
    [values:Aimeos\MShop\Common\Item\Lists\Standard:private] => Array
        (
            [product.lists.id] => 1
            [product.lists.parentid] => 1
            [product.lists.siteid] => 1
            [product.lists.typeid] => 10
            [product.lists.domain] => price
            [product.lists.refid] => 1
            [product.lists.datestart] =>
            [product.lists.dateend] =>
            [product.lists.config] => Array
                (
                )

            [product.lists.position] => 0
            [product.lists.status] => 1
            [product.lists.mtime] => 2016-10-21 07:47:02
            [product.lists.editor] => aimeos:jobs
            [product.lists.ctime] => 2016-10-21 07:47:02
            [product.lists.type] => default
            [product.lists.typename] => Standard
        )

    [refItem:Aimeos\MShop\Common\Item\Lists\Standard:private] =>
    [modified:Aimeos\MShop\Common\Item\Base:private] =>
    [prefix:Aimeos\MShop\Common\Item\Base:private] => product.lists.
    [values:Aimeos\MShop\Common\Item\Base:private] => Array
        (
            [product.lists.id] => 1
            [product.lists.parentid] => 1
            [product.lists.siteid] => 1
            [product.lists.typeid] => 10
            [product.lists.domain] => price
            [product.lists.refid] => 1
            [product.lists.datestart] =>
            [product.lists.dateend] =>
            [product.lists.config] => Array
                (
                )

            [product.lists.position] => 0
            [product.lists.status] => 1
            [product.lists.mtime] => 2016-10-21 07:47:02
            [product.lists.editor] => aimeos:jobs
            [product.lists.ctime] => 2016-10-21 07:47:02
            [product.lists.type] => default
            [product.lists.typename] => Standard
        )

)


  [Symfony\Component\Debug\Exception\FatalThrowableError]
  Call to a member function fromArray() on null


Also: almost all products showed 0.00 as price even all have prices imported. Only about five products show a price. All import 4 prices. All get imported the same way.The first price for 1 item should show by default.