请让我先解释一下我的问题。我有一个网上商店,里面有很多产品,但也有很多类别。产品图片是从openicecat.biz导入的,它也是一个内容提供者。当某个产品没有可用的描述或图像时,将显示 noimage.jpg
有人制作了一个代码,它从产品列表中选择一张图片并将其用作该类别的图片。(如果可用)当一个类别有一个带有图像的子类别和一个没有图像的子类别时,问题就来了。将显示 noimage.jpg,而不是显示来自带有图像的子类别的图像。
例如
catelog -> components -> card readers (no image) -> internal card reader (image)
-> external card reader (no image)
代码片段的设计方式,当内部和外部读卡器都有图片时,只显示图像,而不是当一个子类别没有图像时。
我想要的是,例如,当子类别内部读卡器有带有图像的产品,而子类别外部读卡器没有图像时,外部读卡器的图像显示为读卡器的类别图像.
例子
catelog -> components -> card readers (image of internal card reader, instead of no image)
-> internal card reader (image)
-> external card reader (no image)
我希望你能明白我的意思。
这是代码片段:
// Start auto fetch category image from product
if($categories['categories_image'] == "") {
$categories_img_query = tep_db_query("select products_image from " . TABLE_PRODUCTS . " p, products_to_categories pc WHERE p.products_id = pc.products_id AND pc.categories_id = '{$categories['categories_id']}' AND p.products_image IS NOT NULL order by p.products_id ASC");
if(tep_db_num_rows($categories_img_query) > 0) {
$categories_img = tep_db_fetch_array($categories_img_query);
$categories['categories_image'] = $categories_img['products_image'];
}
else {
$categories_img_parent_query = tep_db_query("select categories_id from categories WHERE parent_id = '{$categories['categories_id']}'");
while($categories_img_parent = tep_db_fetch_array($categories_img_parent_query)) {
$categories_img_query = tep_db_query("select products_image from " . TABLE_PRODUCTS . " p, products_to_categories pc WHERE p.products_id = pc.products_id AND pc.categories_id = '{$categories_img_parent['categories_id']}' AND p.products_image IS NOT NULL order by p.products_id ASC");
if(tep_db_num_rows($categories_img_query) > 0) {
$categories_img = tep_db_fetch_array($categories_img_query);
$categories['categories_image'] = $categories_img['products_image'];
}
}
}
}
// End auto fetch category image from product
谁能帮我完成这个片段?
顺便说一句,它是为 oscommerce 的。
顺便说一句,我的天啊,我几乎花了 40 分钟来解释和输入这个问题,这也值得一枚奖章吗(永恒耐心勋章);-)