post_type) || $post->post_type !== FluentProducts::CPT_NAME) { return $post; } $GLOBALS['fct_product'] = self::getProductModel($post->ID); return $post; } public static function getProductModel($postId) { if (isset(self::$productsCache[$postId])) { return self::$productsCache[$postId]; } $product = Product::query()->find($postId); if ($product) { self::$productsCache[$postId] = $product; } return $product; } public static function setProductsCache($products) { foreach ($products as $product) { self::$productsCache[$product->ID] = $product; } } }