function getParentCats($cats, &$parent_cats)
{
    if (empty($cats)) {
        return $parent_cats;
    }
    $parent_cats[] = array("cat_id" => (int) $cats->category["category_id"], "name" => (string) $cats->category->name);
    if (isset($cats->category->child_categories)) {
        getParentCats($cats->category->child_categories, $parent_cats);
    }
    return $parent_cats;
}
Ejemplo n.º 2
0
 //     $brandRespObj = simplexml_load_string($xml);
 if (!$brandRespObj instanceof SimpleXMLElement) {
     print $brandRespObj;
     exit;
 }
 $brandProduct =& $brandRespObj->product;
 /* print_r($brandProduct); */
 /*
 if(empty($brandProduct))
 {
     print "no product";
     exit;
 }
 */
 $parent_cats = array(0 => array("cat_id" => 0, "name" => "Product Categories"));
 getParentCats($brandProduct->category_ancestry, $parent_cats);
 /**
  * Check product retailers
  * 
  * If product has only one retailer and that retailer is the default distributor center, 
  * then this product doesn't have any associated retailers. 
  * Do not display the zip code lookup...display product configs/options
  */
 $has_retailers = count($brandProduct->retailers->retailer) === 1 && $brandProduct->retailers->retailer->is_default == "yes" ? false : true;
 $current_retailer_selection = $has_retailers ? !empty($retailer_info["retailer_name"]) ? $retailer_info["retailer_name"] : "" : $brandProduct->retailers->retailer->name;
 /**
  * this product is ready to query for configs and display add to cart button
  * 
  * - The product doesn't have any associated retailers
  * OR
  * - We already have a reatiler selected from a previous query
Ejemplo n.º 3
0
<body>

<div class="container">
<?php 
// Submit request to MWRC
$xmlobj = curl_get($mwrc_domain, $mwrc_lang_abbrev, "category.xml.php", implode("&", $params));
if (!$xmlobj instanceof SimpleXMLElement) {
    print $xmlobj;
    exit;
}
$category =& $xmlobj->category;
//print_r($category->products->product);
//exit;
$parent_cats = array(0 => array("cat_id" => 0, "name" => "Product Categories"));
getParentCats($category->category_ancestry, $parent_cats);
if ((int) $category["category_id"] > 0) {
    array_push($parent_cats, array("cat_id" => (int) $category["category_id"], "name" => (string) $category->name));
}
?>

<h1>Channel Islands Catalog</h1>

<?php 
if (count($parent_cats)) {
    ?>
<ul class="bread_crumbs">
<?php 
    foreach ((array) $parent_cats as $cat) {
        ?>
<li>