예제 #1
0
 /**
  * get the articles of the News Blog
  */
 public function getNews()
 {
     $blog = new \erdiko\shopify\models\Blog();
     $blogID = $blog->getBlogIDByName("News");
     $type = "articleInfoPage";
     $this->retrieveBlogArticlesHelper($blogID, $type);
 }
예제 #2
0
 public function testArticleMetafields()
 {
     $blog = new \erdiko\shopify\models\Blog();
     $data = $blog->getBlogs();
     $this->assertTrue(count($data) > 0, "There should be atleast one blog to\n\t\t \tcontinue this test");
     $bId = $data[0]['id'];
     $this->assertTrue(!empty($bId), "Blog id is empty");
     $articles = $blog->getBlogArticles($bId);
     $this->assertTrue(count($data) > 0, "There should be atleast one article to\n\t\t \tcontinue this test");
     $aId = $articles[0]['id'];
     $this->assertTrue(!empty($aId), "Article id is empty");
     // create
     $args = array("article" => array("id" => $aId, "metafields" => array(array("key" => "test_article_key", "value" => "test_article_value", "value_type" => "string", "namespace" => $this->meta->getNamespace()))));
     $this->meta->setBlogArticleMetaField($bId, $aId, $args);
     $articlesMeta = $this->meta->getBlogArticleMetaFields($aId);
     $metaResp = "";
     $metaID = 0;
     foreach ($articlesMeta as $metaResp) {
         if (strcmp($metaResp['key'], "test_article_key") == 0) {
             $metaID = $metaResp['id'];
             $this->assertTrue(strcmp($metaResp['value'], 'test_article_value') == 0);
         }
     }
     $this->assertTrue($metaID != 0, "metafield is not set");
     //update
     $args = array("metafield" => array("id" => $metaID, "value" => "test_article_value_1", "value_type" => "string"));
     $resp = $this->meta->updateBlogArticleMetaField($aId, $metaID, $args);
     $articlesMeta = $this->meta->getBlogArticleMetaFields($aId);
     $metaResp = "";
     $metaID = 0;
     foreach ($articlesMeta as $metaResp) {
         if (strcmp($metaResp['key'], "test_article_key") == 0) {
             $metaID = $metaResp['id'];
             $this->assertTrue(strcmp($metaResp['value'], 'test_article_value_1') == 0);
         }
     }
     $this->assertTrue($metaID != 0, "metafield is not set");
     // delete
     $this->meta->deleteBlogArticleMetaField($bId, $metaID, array());
     $articlesMeta = $this->meta->getBlogArticleMetaFields($aId);
     foreach ($articlesMeta as $data) {
         $this->assertFalse($data['id'] == $metaID, "metafield not deleted !");
     }
 }