Hi!
I'm trying to run a few queries when a product is deleted,edited or added from the perch_shop. I have no problem for the add/edit, but the delete event seems to never be triggered. This is what I'm doing :
Posts by gustavobica
-
-
Can you confirm you're using Runway and not trying to do this in Perch?
You probably didn't see my edit, I'm not using perch runway. That is the problem then.
Thank you for the feedback -
Hi, thank you for the response. I should have specified those topics beforehand.
1 - The php error is enabled and returns nothing.
2 - No, I'm using react for the frontend, so I'm using Perch has a headless cms (Via API)
3 - I would say yes, because I added manually a product so I'm guessing that yes, although I didn't set any category.
4 -Yes, I could see where it stopped within the addProducts function (by using var_dumps) it stopped in this line
$Importer = $API->get('PerchShopProductImporter');
Also, the block try catch returns nothing (if I place a var_dump inside the try it wont print anything and the same thing goes for the catch part).
(I'm not using the perch runway, is the importer something exclusive for the runway ? )
My file looks something like this (I removed the other functions)PHP- error_reporting(E_ALL);
- ini_set('display_errors', 1);
- header('Access-Control-Allow-Origin: *');
- header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS');
- header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token');
- include('../cms/runtime.php');
- include('php_libs/ReallySimpleJWT/index.php');
- include('php_libs/phpspreadsheet/index.php');
- include('php_libs/mpdf_mpdf_8_0_0_0/index.php');
- include('php_libs/phpmailer_phpmailer_6_0_7_0/index.php');
- include('PerchAPI/PerchMembers_Auth_API.class.php');
- include('PerchAPI/PerchMembers_Members_API.class.php');
- function addProducts($items)
- {
- $API = new PerchAPI(1.0, 'perch_shop_importer');
- $Importer = $API->get('PerchShopProductImporter');
- try
- {
- $Importer->add_item([
- 'sku' => '5555',
- 'title' => 'My first t-shirt',
- 'slug' => 'my-first-t-shirt',
- 'description' => 'This is a really smashing t-shirt.',
- 'image_assetID' => 630,
- 'img_desc' => 'An image of the product',
- 'status' => true,
- 'brand' => 1,
- 'category' => 'products/clothes/',
- 'catalog_only' => false,
- 'price' => ['gbp' => 10, 'eur'=>12, 'usd'=>13],
- 'sale_price' => ['gbp' => 8, 'eur'=>10, 'usd'=>11],
- 'trade_price' => ['gbp' => 7, 'eur'=>9, 'usd'=>10],
- 'on_sale' => false,
- 'tax_group' => 1,
- 'stock_status' => '1',
- 'stock_level' => '199',
- 'stock_location' => true,
- 'max_in_cart' => 10,
- 'requires_shipping' => true,
- 'weight' => 100,
- 'width' => 20,
- 'height' => 15,
- 'depth' => 30,
- ]);
- } catch (Exception $e)
- {
- var_dump($e);
- //die('Error: '.$e->getMessage());
- var_dump('Error: '.$e->getMessage());
- }
- }
- addProducts([]);
-
Hi!
I'm currently working on a new website that will have a lot of products so I'm trying to automate the adding/updating of the products. That being said, by looking at the docs I found this: importing products . But so for I wasn't able to use it successfully, What I am doing wrong ? The page doesn't provide any errors, but it wont get past the line:
$Importer = $API->get('PerchShopProductImporter');
I leave it here the function responsible for the importing (currently I'm using static content, but then I will move to an array of items):PHP- function addProducts($items)
- {
- $API = new PerchAPI(1.0, 'perch_shop_importer');
- $Importer = $API->get('PerchShopProductImporter');
- try
- {
- $Importer->add_item([
- 'sku' => '5555',
- 'title' => 'My first t-shirt',
- 'slug' => 'my-first-t-shirt',
- 'description' => 'This is a really smashing t-shirt.',
- 'image_assetID' => 630,
- 'img_desc' => 'An image of the product',
- 'status' => true,
- 'brand' => 1,
- 'category' => 'products/clothes/',
- 'catalog_only' => false,
- 'price' => ['gbp' => 10, 'eur'=>12, 'usd'=>13],
- 'sale_price' => ['gbp' => 8, 'eur'=>10, 'usd'=>11],
- 'trade_price' => ['gbp' => 7, 'eur'=>9, 'usd'=>10],
- 'on_sale' => false,
- 'tax_group' => 1,
- 'stock_status' => '1',
- 'stock_level' => '199',
- 'stock_location' => true,
- 'max_in_cart' => 10,
- 'requires_shipping' => true,
- 'weight' => 100,
- 'width' => 20,
- 'height' => 15,
- 'depth' => 30,
- ]);
- } catch (Exception $e)
- {
- var_dump($e);
- //die('Error: '.$e->getMessage());
- var_dump('Error: '.$e->getMessage());
- }
- }