Skip to content

Instantly share code, notes, and snippets.

@izayoi256
Created July 4, 2016 03:00
Show Gist options
  • Save izayoi256/1a513358f4697c3887715c54f9505b79 to your computer and use it in GitHub Desktop.
Save izayoi256/1a513358f4697c3887715c54f9505b79 to your computer and use it in GitHub Desktop.
// /data/class/SC_Product.php
/**
* 商品IDに紐づく商品規格を自分自身に設定する.
*
* 引数の商品IDの配列に紐づく商品規格を取得し, 自分自身のフィールドに
* 設定する.
*
* @param array $arrProductId 商品ID の配列
* @param boolean $has_deleted 削除された商品規格も含む場合 true; 初期値 false
* @return void
*/
public function setProductsClassByProductIds($arrProductId, $has_deleted = false)
{
foreach ($arrProductId as $productId) {
$arrProductClasses = $this->getProductsClassFullByProductId($productId, $has_deleted);
// 追加
SC_Utils::sfPrintR($arrProductClasses);
// 商品名など隠したい場合は代わりに下記を追加
SC_Utils::sfPrintR(array_map(function($v){return array_intersect_key($v, array_flip(array('stock', 'stock_unlimited')));}, $arrProductClasses));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment