Sorry I haven't got much time today to look for you. Maybe you could try importing one product with manual data, see if that works. Like so.
Posts by Mxkert
-
-
My guess is that the fields you are importing are not matching the fields in your product.html template.
So change this piece of code to suite your product template:
You can find more options here
-
What do you see if you run the following code:
PHP- <?php
- include($_SERVER['DOCUMENT_ROOT'].'/perch/runtime.php');
- $API = new PerchAPI(1.0, 'my_importer');
- $ProductImporter = $API->get('PerchShopProductImporter');
- // Set template to use when importing products
- $Template = $API->get('Template');
- $Template->set('shop/products/product.html', 'shop');
- $ProductImporter->set_template($Template);
- try {
- $row = 1;
- if (($handle = fopen($_SERVER['DOCUMENT_ROOT']."/products.csv", "r")) !== FALSE) {
- while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
- if ($row == 1) { $row++; continue; }
- print_r($data);
- echo '<br><br><br>';
- }
- }
- }
- catch (Exception $e) {
- die('Error: '.$e->getMessage());
- }
-
It is possible. I will look for you when I have time, maybe today, maybe tomorrow.
EDIT: I guess you would have to have the images hosted somewhere, so you can use the URL to the image to import them.
-
Here is some sample code for you to try (and edit to suit your needs)
PHP- <?php
- include($_SERVER['DOCUMENT_ROOT'].'/perch/runtime.php');
- $API = new PerchAPI(1.0, 'my_importer');
- $ProductImporter = $API->get('PerchShopProductImporter');
- // Set template to use when importing products
- $Template = $API->get('Template');
- $Template->set('shop/products/product.html', 'shop');
- $ProductImporter->set_template($Template);
- try {
- $row = 1;
- // Open the CSV file. Change the path and FILE_NAME to the location of your desired CSV file.
- if (($handle = fopen("../[FILE_NAME].csv", "r")) !== FALSE) {
- // Loop through each row in the CSV file
- while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
- // I use this to skip the first row in my CSV file, which contains de column headings
- if ($row == 1) { $row++; continue; }
- // Run product importer
- // Use $data[index] to use data from the CSV file, for example: $data[0] will be the first cell in your excel file for this row. $data[1] = second cell, $data[2] = third cell etc.
- // I have left some sample code from my importer.
- $product = $ProductImporter->add_item([
- 'status' => true,
- 'stock_status' => '0',
- 'on_sale' => false,
- 'tax_group' => 1,
- 'sku' => $data[0],
- 'title' => $data[2],
- 'slug' => $data[1],
- 'price' => ['eur' => $data[17]],
- ]);
- $Products = new PerchShop_Products();
- // Automatically index the product, you need to include this.
- if ($product) {
- $newProduct = $Products->find($product['id']);
- $newProduct->index($Template);
- }
- }
- }
- }
- catch (Exception $e) {
- die('Error: '.$e->getMessage());
- }
Do you also need to import images?
-
Isn't it orderInvoiceNumber or invoiceID from the top of my head?
-
Have you tried republishing the pages as Byron Fitzgerald suggested?
-
-
Have you tried saving the regions after changing the templates?
-
Check the debug messages to see why it isn't finding your template.
-
-
In your ../perch/config/config.php file you can enter the details for your local database. If set up correctly you will log in with the same credentials as the live website.
Edit: too late.
-
I am not really sure how to do that.
-
Quote
"You normally only want to index fields that you need to filter and/or sort by. The more fields you index, the more likely your queries going to be slower (though this depends on other factors too)."
As taken from this article from Hussein. I believe it should also work for products.
-
Are you indexing all the fields in the product template? You can use the no-index attribute on the fields you don't have to index. I'm not sure if this will solve your problem but you could always try.
-
When you turn on debug, by placing define('PERCH_DEBUG', true); in the /perch/config/config.php file, and outputting the debug on the bottom of your page, you can see exactly which template is being used.
-
perch_blog_author_for_post(); uses the /perch/templates/blog/author.html template.
perch_blog_post(perch_get('s')); uses the /perch/templates/blog/post.html template.
perch_blog_post_categories(perch_get('s')); uses the /perch/templates/blog/post_category_link.html template.
You can always create your own template and use it. For the blog post, you have to use perch_blog_custom as follows:
-
You could turn on debug and check what error message is thrown on the bottom of the screen.
-
-
This should be fairly easy to accomplish.