0

I'm trying to migrate products from Shopify via API. I want the products to be the same ID in woocommerce as they are in Shopify. The Product ID in Shopify consists of 13 digits e.g. 1460581269617 and it looks like wp_insert_post functions the value limit to a 10 digit number only e.g. 1548353657

So when I try to map the Shopify product ID to import_id, it automatically changes the number to some 10 digit value and save it to the database. I need to save the product ID as it is in Shopify. Looking for a way to do this.

Following is the code I'm using.

$post = array(
            'import_id' => $product_id,
            'post_author' => '',
            'post_content' => '',
            'post_excerpt' => $product_content,
            'post_status' => "publish",
            'post_title' => $product_title,
            'post_parent' => '',
            'post_type' => "product",
            'post_date' => $product_created_date,
            );

            //Create post
            $post_id = wp_insert_post( $post );

1 Answers1

0

Okay I find the problem. I'm running xampp on windows so its a 32 bit platform and PHP int only stores a value that's a maximum of 2 billion. When on a 64 bit platform, I could store the ID perfectly. This is the answer I got the information from.

The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits signed). PHP does not support unsigned integers. Integer size can be determined using the constant PHP_INT_SIZE, and maximum value using the constant PHP_INT_MAX since PHP 4.4.0 and PHP 5.0.5.

64-bit platforms usually have a maximum value of about 9E18, except on Windows prior to PHP 7, where it was always 32 bit.

What's the maximum value for an int in PHP?