Merging content from Shopify

Hej, I am trying to fetch products from Shopify to show in the panel, and to be able to add more content (like blocks) to them.

Since the kirby-shopify plugin is not ready for v5, I copied the fundamentals for fetching the products and everything is working so far. But, when I add a block to a product and hit save, the blocks field is empty again and nothing is saved. Also, there is no txt file being created in the content folder. The site is also a multi-language setup, in case it matters.

Here’s my code:

class ShopifyProductsPage extends Page {
  static $subpages = null;

  public function subpages() {
    if (static::$subpages) {
      return static::$subpages;
    }

    return static::$subpages = Pages::factory($this->inventory()['children'], $this);
  }

  public function children(): Pages {
    if ($this->children instanceof Pages) {
      return $this->children;
    }

    $products = KirbyShopify::getProducts();

    $children = array_map(function ($product) {
      $slug = Str::slug($product['handle']);
      $page = $this->subpages()->find($slug);

      ray($page); // is always null…

      return [
        'slug' => $slug,
        'num' => 0,
        'template' => 'shopify.product',
        'model' => 'shopify.product',
        'content' => [
          'title' => $product['title'],
          'shopifyTitle' => $product['title'],
          'shopifyID' => $product['id'],
          'shopifyCreatedAt' => $product['created_at'],
          'shopifyUpdatedAt' => $product['updated_at'],
          'shopifyPublishedAt' => $product['published_at'],
          'shopifyHandle' => $product['handle'],
          'shopifyVendor' => $product['vendor'],
          'shopifyFeaturedImage' => count($product['images']) > 0 ? Yaml::encode([$product['images'][0]]) : '',
          'shopifyImages' => Yaml::encode($product['images']),
          'shopifyDescriptionHTML' => $product['body_html'],
          'shopifyPrice' => count($product['variants']) > 0 ? $product['variants'][0]['price'] : '',
          'shopifyCompareAtPrice' => count($product['variants']) > 0 ? $product['variants'][0]['compare_at_price'] : '',
          'shopifyType' => $product['product_type'],
          'shopifyTags' => $product['tags'],
          'shopifyVariants' => Yaml::encode($product['variants']),
          'blocks' => $page ? $page->blocks()->value() : null // …hence never saves anything
        ]
      ];
    }, $products);

    return $this->children = Pages::factory($children, $this);
  }
}

What am I missing? Thank you so much for any help

Probably same as/related to Content loss on pages with virtual data - #2 by bastianallgeier it seems to me.

Yes, that seems to be the same issue. Thank you for the hint—somehow I did not see the other topic

I’ve just posted a potential solution in the other thread.