當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ps_product::parent_has_children方法代碼示例

本文整理匯總了PHP中ps_product::parent_has_children方法的典型用法代碼示例。如果您正苦於以下問題:PHP ps_product::parent_has_children方法的具體用法?PHP ps_product::parent_has_children怎麽用?PHP ps_product::parent_has_children使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ps_product的用法示例。


在下文中一共展示了ps_product::parent_has_children方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: vmGet

 /**
  * Lists all child/sister products of the given product
  *
  * @param int $product_id
  * @return string HTML code with Items, attributes & price
  */
 function list_attribute_list($product_id, $display_use_parent, $child_link, $display_type, $cls_sfuffix, $child_ids, $dw, $aw, $display_header, $product_list_type, $product_list)
 {
     global $CURRENCY_DISPLAY, $mm_action_url;
     require_once CLASSPATH . 'ps_product.php';
     $ps_product = new ps_product();
     require_once CLASSPATH . 'ps_product_type.php';
     $ps_product_type = new ps_product_type();
     $Itemid = vmGet($_REQUEST, 'Itemid', "");
     $category_id = vmGet($_REQUEST, 'category_id', "");
     $curr_product = vmGet($_REQUEST, 'product_id', "");
     $db = new ps_DB();
     $db_sku = new ps_DB();
     $db_item = new ps_DB();
     $tpl = vmTemplate::getInstance();
     $price = $ps_product->get_adjusted_attribute_price($product_id);
     $tpl->set("cls_suffix", $cls_sfuffix);
     $tpl->set("product_id", $product_id);
     $tpl->set("display_header", $display_header);
     $tpl->set("display_product_type", $product_list_type);
     $tpl->set("product_price", $price['product_price']);
     $html = '';
     // Get list of children
     $pp = $ps_product->parent_has_children($product_id);
     if ($pp) {
         $q = "SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock,product_full_image,product_thumb_image FROM #__{vm}_product WHERE product_publish='Y' AND product_parent_id='{$product_id}'  ";
     } else {
         $q = "SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock,product_full_image,product_thumb_image FROM #__{vm}_product WHERE product_publish='Y' AND product_id='{$product_id}'  ";
     }
     if ($child_ids) {
         $ids = explode(",", $child_ids);
         $child_array = array();
         $parent_array = array();
         foreach ($ids as $extra_id) {
             if ($ps_product->parent_has_children($extra_id)) {
                 $parent_array[] = $extra_id;
             } else {
                 $child_array[] = $extra_id;
             }
         }
         $parent_ids = implode(',', $parent_array);
         $child_ids = implode(',', $child_array);
         if ($child_ids) {
             $q .= "UNION ALL SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock,product_full_image,product_thumb_image FROM #__{vm}_product WHERE product_publish='Y' AND  product_id IN ({$child_ids}) ";
         }
         if ($parent_ids) {
             $q .= "UNION ALL SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock,product_full_image,product_thumb_image FROM #__{vm}_product WHERE product_publish='Y' AND  product_parent_id IN ({$parent_ids})";
         }
     }
     $db->query($q);
     if ($pp) {
         $master_id = $product_id;
     } else {
         $master_id = $db->f("product_id");
     }
     $main_master = $master_id;
     $master_child_count = 0;
     if ($db->num_rows() < 1) {
         // Try to Get list of sisters & brothers
         $q = "SELECT product_parent_id FROM #__{vm}_product WHERE product_id='{$product_id}'";
         $db->setQuery($q);
         $db->query();
         $child_id = $product_id;
         $product_id = $db->f("product_parent_id") ? $db->f("product_parent_id") : $product_id;
         $parent_id = $db->f("product_parent_id");
         $q = "SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock FROM #__{vm}_product WHERE product_parent_id='" . $db->f("product_parent_id") . "' AND product_parent_id<>0 AND product_publish='Y'";
         $db->query($q);
     }
     if ($db->num_rows() > 0) {
         $products = array();
         $headings = array();
         $i = 0;
         $attrib_heading = array();
         $ci = 0;
         while ($db->next_record()) {
             $parent_id = $db->f("product_parent_id");
             if ($db->f("product_id") != $curr_product && @$child_id) {
                 continue;
             }
             // Start row for this child
             $q = "SELECT product_id, attribute_name FROM #__{vm}_product_attribute_sku ";
             $q .= "WHERE product_id='" . $db->f("product_parent_id") . "' ORDER BY attribute_list ASC";
             $db_sku->query($q);
             $attrib_value = array();
             while ($db_sku->next_record()) {
                 $q = "SELECT attribute_name,attribute_value ";
                 $q .= "FROM #__{vm}_product_attribute WHERE ";
                 $q .= "product_id='" . $db->f("product_id") . "' AND ";
                 $q .= "attribute_name='" . $db_sku->f("attribute_name") . "'";
                 $db_item->setQuery($q);
                 $db_item->query();
                 while ($db_item->next_record()) {
                     if ($ci == 0) {
                         $attrib_heading[] = $db_item->f("attribute_name");
                         $tpl->set('headings', $attrib_heading);
//.........這裏部分代碼省略.........
開發者ID:albertobraschi,項目名稱:Hab,代碼行數:101,代碼來源:ps_product_attribute.php


注:本文中的ps_product::parent_has_children方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。