shop_template_factory = $shop_template_factory; $this->shop_template_repository = $shop_template_repository; } /** * Migrate the shop templates posts to taxonomy terms. * * @since 0.8 */ public function migrate() { $posts = get_posts(array( 'post_type' => 'aff_shop_template', 'status' => 'publish' )); foreach ($posts as $post) { $shop_template = $this->shop_template_factory->create( new Name($post->post_title), new Slug($post->post_name) ); $provider_id = carbon_get_post_meta($post->ID, '_affilicious_shop_template_provider'); if(!empty($provider_id)) { $shop_template->set_provider_id(new Provider_Id($provider_id)); } $thumbnail_id = carbon_get_post_meta($post->ID, '_thumbnail_id'); if(!empty($thumbnail_id)) { $shop_template->set_thumbnail(new Image($thumbnail_id)); } try { $this->shop_template_repository->store($shop_template); } catch (\Exception $e) { } finally { wp_delete_post($post->ID); } } } }