public function pushAllCategoriesToFbCollections()

in Model/Feed/CategoryCollection.php [242:272]


    public function pushAllCategoriesToFbCollections()
    {
        $resArray = [];
        $access_token = $this->fbeHelper->getAccessToken();
        if ($access_token == null) {
            $this->fbeHelper->log("can't find access token, abort pushAllCategoriesToFbCollections");
            return;
        }
        $this->fbeHelper->log("pushing all categories to fb collections");
        $categories = $this->getAllActiveCategories();
        foreach ($categories as $category) {
            $syncEnabled =$category->getData("sync_to_facebook_catalog");
            if ($syncEnabled === "0") {
                $this->fbeHelper->log("user disabled category sync ".$category->getName());
                continue;
            }
            $this->fbeHelper->log("user enabled category sync ".$category->getName());
            $set_id = $this->getFBProductSetID($category);
            $this->fbeHelper->log("setid for it is:". (string)$set_id);
            if ($set_id) {
                $response = $this->updateCategoryWithFB($category, $set_id);
                $resArray[] = $response;
                continue;
            }
            if (!$category->hasChildren()) {
                $response = $this->pushNewCategoryToFB($category);
                $resArray[] = $response;
            }
        }
        return json_encode($resArray);
    }