I have a store with 8k products that I imported with a plugin made by me.
The products, the categories and the variations are all correct.
All shop is correct.
But the problem is the page of each category does not output the products until I give them to manually save one by one.
I have disabled the theme and the plugin and the same thing continues with the originals.
If I change the query manually by overriding the archive-product, all the products are seen, but the pagination and category listing remain the same.
Could it be for some meta-post?
Any solution?
Thank you very much to all.
My function to generate a basic and variant product:
$post = array(
'post_author' => 1,
'post_content' => $this->getDescription(),
'post_status' => 'publish',
'post_title' => $this->getName(),
'post_parent' => '',
'post_type' => 'product'
);
$postId = wp_insert_post($post);
$this->setId($postId);
if ($this->getId()) {
update_post_meta($this->getId(), '_sku', $this->getSku());
update_post_meta($this->getId(), '_visibility', 'visible');
wp_set_object_terms($postId, $this->getCategories(), 'product_cat');
$this->getImageXML();
update_post_meta($this->getId(), '_price', $this->price);
update_post_meta($this->getId(), '_regular_price', $this->price);
wp_set_object_terms($this->getId(), $this->getType(), 'product_type', false);
if ($this->getType() == 'simple') {
update_post_meta($this->getId(), '_manage_stock', 'yes');
update_post_meta($this->getId(), '_stock', $this->getStock());
} else {
$talla = wc_attribute_taxonomy_name('Größe');
$attributes = array(
$talla => array(
'name' => $talla,
'value' => '',
'is_visible' => '1',
'is_variation' => '1',
'is_taxonomy' => '1'
)
);
wp_set_object_terms($this->getId(), $this->getAtributos(), $talla);
update_post_meta($this->getId(), '_product_attributes', $attributes);
foreach ($this->getVariants() as $key => $variant) {
$variation = array(
'post_title' => 'Product #' . $this->getId() . ' Variation',
'post_content' => '',
'post_status' => 'publish',
'post_parent' => $this->getId(),
'post_type' => 'product_variation'
);
$variationId = wp_insert_post($variation);
update_post_meta($variationId, '_sku', $variant['ean']);
update_post_meta($variationId, '_regular_price', $this->price);
update_post_meta($variationId, '_price', $this->price);
update_post_meta($variationId, '_manage_stock', 'yes');
update_post_meta($variationId, '_stock', $variant['stock']);
if ($variant['stock'] > 0) {
update_post_meta($variationId, '_stock_status', 'instock');
} else {
update_post_meta($variationId, '_stock_status', 'outofstock');
}
update_post_meta($variationId, 'attribute_' . $talla, strtolower(str_replace('/', '', $variant['talla'])));
}
WC_Product_Variable::sync($this->getId());
WC_Product_Variable::sync_attributes($this->getId());
}
}