本文整理汇总了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);
//.........这里部分代码省略.........