o::getRelatedProducts

概要

指定した商品の関連商品情報を全て取得します。
 

使い方

<?php 
$getRelatedProducts  = o::getRelatedProducts($pid, $isSeo = 'false'); 
print_r($getRelatedProducts);
?>

 

引数の内容

  • $pid : 商品IDを指定します。
  • $isSeo : デフォルトは空でも可。SEO URLを有効にしたい場合は trueを指定します。

 

返り値

array

  • product_id : 商品ID
  • product_name : 商品名
  • product_image : 商品画像ファイル名
  • product_description : 商品説明
  • product_href : 商品ページのURL
// 出力結果
Array
(
    [0] => Array
        (
            [product_id] => 230
            [product_name] => 花
            [product_image] => src="resources/upload/products/thumbnail3/no_image.gif" width="46" height="46"
            [product_description] => 
            [product_href] => http://www.sample.com/category/select/pid/230
        )

    [1] => Array
        (
            [product_id] => 105
            [product_name] => 和歌山産 小梅 等級A 2Lサイズ 約4K
            [product_image] => src="resources/upload/products/thumbnail3/02892870.jpg" width="46" height="35"
            [product_description] => 和歌山産 等級A 2Lサイズ 約4K         3143  
            [product_href] => http://www.sample.com/category/select/pid/105
        )

    [2] => Array
        (
            [product_id] => 70
            [product_name] => 北海道産他 サヤ A品 約1K x1
            [product_image] => src="resources/upload/products/thumbnail3/02887593.jpg" width="46" height="35"
            [product_description] => 北海道産他 A品 約1K入           
            [product_href] => http://www.sample.com/category/select/pid/70
        )

    [3] => Array
        (
            [product_id] => 69
            [product_name] => 千葉産・山形産 いんげん 等級A Mサイズ 約2K x1
            [product_image] => src="resources/upload/products/thumbnail3/02887579.jpg" width="46" height="35"
            [product_description] => 千葉産・山形産 等級A Mサイズ 約2K入          
            [product_href] => http://www.sample.com/category/select/pid/69
        )

)

 

使用例

<?php
    $relatedProducts = c::executeCacheForFunction('related_products', 'o::getRelatedProducts' , array($this->p_id,
                                                                                                      c::executeCacheForFunction('configuration', 'o::_', array('SEO_URL'))));
 
 if ($relatedProducts) :
?>
<!--Related products-->
<div class="itemtable">
  <div class="title">
    <h2><?php echo TEXT_RELATED_PRODUCTS; ?></h2>
  </div>
  <div class="box">
    <?php foreach ($relatedProducts as $rprow) : ?>
    <h3 class="top"><?php echo $rprow['product_name']; ?></h3>
    <div class="clearfix">
      <p class="images"><img <?php echo $rprow['product_image']; ?>/</p>
      <p class="text"><?php echo $rprow['product_description']; ?></p>
    </div>
    <?php endforeach; ?>
  </div>
</div>