Forum
Perch Shop import - assets not imported
Hi,
When importing using the following code, no asset is attached to the product:
$Importer->add_item([
'sku' => slugify($title),
'title' => $title,
'slug' => slugify($title),
'description' => $content,
'image_assetID' => 1786,
'price' => ['gbp' => 0],
'on_sale' => false,
'status' => true,
'requires_shipping' => true,
'tax_group' => 1,
'stock_status' => '1',
]);
Running latest Runway and Shop apps. The asset is a valid asset ID also.
Perch Runway: 3.0.14, PHP: 7.1.8, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: b396954eeb2d1d9ed7902b8bae237b287f21ad9e $, with PDO
Server OS: Darwin, apache2handler
Installed apps: content (3.0.14), assets (3.0.14), categories (3.0.14), perch_blog (5.6.1), perch_forms (1.9), perch_shop_orders (1.2.5), perch_shop_products (1.2.5), perch_shop (1.2.5), perch_members (1.6.2)
App runtimes: <?php $apps_list = [ 'perch_members', 'perch_shop', 'perch_forms', 'perch_blog' ];
PERCH_LOGINPATH: /admin
PERCH_PATH: /Users/ryangittings/Builds/client/admin
PERCH_CORE: /Users/ryangittings/Builds/client/admin/core
PERCH_RESFILEPATH: /Users/ryangittings/Builds/client/admin/resources
Image manipulation: GD
PHP limits: Max upload 32M, Max POST 32M, Memory: 256M, Total max file upload: 32M
F1: 3b606135b33e6a102526838f4152a807
Resource folder writeable: Yes
HTTP_HOST: client.local
DOCUMENT_ROOT: /Users/ryangittings/Builds/client
REQUEST_URI: /admin/core/settings/diagnostics/
SCRIPT_NAME: /admin/core/settings/diagnostics/index.php
Thanks, Ryan.
How are you adding the asset? Is there a field called
image
in your template?I'm using the Asset Importer but tried using a static ID for testing purposes.
$imageAsset = $AssetImporter->add_item([ 'type' => 'image', 'bucket' => 'default', 'path' => $directory ]);
The asset imports perfectly, I get my ID and then pass to the Shop importer, but no dice.
Yeah the
image
field is in my product template, like so:<perch:shop id="image" type="image" label="Image" width="600" height="400" crop="true" order="4" help="1200 x 800px" /> <perch:shop id="image" type="image" label="Image" width="600" height="400" crop="true" density="2" />
Have you checked the debug?
Yeah, no obvious errors there. The
INSERT INTO perch3_shop_products
has no mention of image whatsoever.Could you show me an example of it?
Of the insert sql?
INSERT INTO perch3_shop_products(title,sku,productDynamicFields,productCreated) VALUES('Black Basalt','black-basalt','{\"description\":{\"_flang\":\"markdown\",\"raw\":\"6mm and 14mm.\",\"processed\":\"<p>6mm and 14mm.<\\/p>\"},\"slug\":\"black-basalt\",\"status\":\"1\",\"category\":[\"12\"],\"price\":{\"47\":0,\"_default\":0},\"on_sale\":\"\",\"tax_group\":1,\"stock_status\":\"1\",\"requires_shipping\":\"1\"}','2018-02-09 10:20:15')
And the context, yes.
It's a PHP script that just imports from a scraper, from the client's old site. I've validated all the data and that the asset uploads and imports okay. It's just that it doesn't seem to get applied to the product.
Can you please show me the debug output? This would be so much easier.
Also to note, the product doesn't get indexed but that's a separate issue.
Try this:
Perfect! Worked a charm.
Thanks Drew!