当前位置: 首页>>代码示例>>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;未经允许,请勿转载。