Jump to content

Custom products importer - Fatal error while calculating price


Recommended Posts

Hi, I'm creating custom products importer (external PHP script) fetching data from CSV.

 

Quick overview of code:

1. Import prestashop/config/config.inc.php

2. Iterate CSV rows

2.1 Add categories (works fine)

2.2 Add product or update and add category if exists

[...]

 

I'm trying to find product by reference. The problem is, code triggers fatal error if something is found. Unfortunately, I can see "Fatal error" only.

 

I created stack trace:

1. Product::searchByName():3376

2. Product::getPriceStatic()

 

In line 2505 there is the code, which kills my script:

if (!$id_cart && !isset($context->employee))
die(Tools::displayError());

Can somebody give a hint what could I have done wrong? I'm fairly new to PrestaShop.

 

Link to comment
Share on other sites

SearchByName() is definitly not your candidate ...

SearchByName is a fuzzy search.

 

The old 1.3 depreciated getIdByReference() would have been your friend ... but alas ...

 

Get inspiration from this legacy search function, adapt it for yoour need (product_shop, product_attribute_shop)...

 

Despite this if still you want to use SearchByName() you need to fake an id_employee on the Context...

Edited by doekia (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...