dump($v['detail']->sku_price)输出如下:
 
array(1) {
  [0] => object(addons\shopro\model\GoodsSkuPrice)#52 (37) {
    ["name":protected] => string(22) "shopro_goods_sku_price"
    ["autoWriteTimestamp":protected] => bool(true)
    ["createTime":protected] => string(10) "createtime"
    ["updateTime":protected] => string(10) "updatetime"
    ["deleteTime":protected] => string(10) "deletetime"
    ["hidden":protected] => array(3) {
      [0] => string(10) "createtime"
      [1] => string(10) "updatetime"
      [2] => string(10) "deletetime"
    }
    ["append":protected] => array(1) {
      [0] => string(16) "goods_sku_id_arr"
    }
    ["connection":protected] => array(0) {
    }
    ["parent":protected] => object(addons\shopro\model\Goods)#53 (41) {
      ["name":protected] => string(12) "shopro_goods"
      ["autoWriteTimestamp":protected] => string(3) "int"
      ["createTime":protected] => string(10) "createtime"
      ["updateTime":protected] => string(10) "updatetime"
      ["deleteTime":protected] => string(10) "deletetime"
      ["hidden":protected] => array(3) {
        [0] => string(10) "createtime"
        [1] => string(10) "updatetime"
        [2] => string(6) "status"
      }
      ["append":protected] => array(4) {
        [0] => string(17) "dispatch_type_arr"
        [1] => string(7) "service"
        [2] => string(3) "sku"
        [3] => string(7) "coupons"
      }
      ["connection":protected] => array(0) {
      }
      ["parent":protected] => NULL
      ["query":protected] => NULL
      ["table":protected] => NULL
      ["class":protected] => string(25) "addons\shopro\model\Goods"
      ["error":protected] => NULL
      ["validate":protected] => NULL
      ["pk":protected] => NULL
      ["field":protected] => array(0) {
      }
      ["except":protected] => array(0) {
      }
      ["disuse":protected] => array(0) {
      }
      ["readonly":protected] => array(0) {
      }
      ["visible":protected] => array(0) {
      }
      ["data":protected] => array(25) {
        ["id"] => int(3)
        ["type"] => string(6) "normal"
        ["title"] => string(54) "巴马寿乡天然泉水1.4元/瓶(10包起配送)"
        ["subtitle"] => string(33) "1.4元/瓶500毫升,一包24瓶"
        ["status"] => string(2) "up"
        ["weigh"] => int(1)
        ["category_ids"] => string(1) "2"
        ["image"] => string(54) "/uploads/20240515/5ae90e793df8c1aa89aa68e9ceafc7ec.png"
        ["images"] => string(54) "/uploads/20240515/5ae90e793df8c1aa89aa68e9ceafc7ec.png"
        ["params"] => string(56) "[{"title":"一包","content":"24瓶,每瓶500毫升"}]"
        ["content"] => string(139) "<p><img alt="未标题-1-07 1的副本.png" src="/uploads/20240515/35edfd23930cf93036b6642ac1e4b260.png" width="625" height="4096"><br></p>"
        ["price"] => string(5) "34.75"
        ["vip_price"] => string(2) "30"
        ["original_price"] => string(5) "50.00"
        ["is_sku"] => int(0)
        ["likes"] => int(0)
        ["views"] => int(28)
        ["sales"] => int(0)
        ["show_sales"] => int(100)
        ["service_ids"] => string(0) ""
        ["dispatch_type"] => string(7) "express"
        ["dispatch_ids"] => string(1) "2"
        ["createtime"] => int(1715744162)
        ["updatetime"] => int(1715825328)
        ["deletetime"] => NULL
      }
      ["origin":protected] => array(25) {
        ["id"] => int(3)
        ["type"] => string(6) "normal"
        ["title"] => string(54) "巴马寿乡天然泉水1.4元/瓶(10包起配送)"
        ["subtitle"] => string(33) "1.4元/瓶500毫升,一包24瓶"
        ["status"] => string(2) "up"
        ["weigh"] => int(1)
        ["category_ids"] => string(1) "2"
        ["image"] => string(54) "/uploads/20240515/5ae90e793df8c1aa89aa68e9ceafc7ec.png"
        ["images"] => string(54) "/uploads/20240515/5ae90e793df8c1aa89aa68e9ceafc7ec.png"
        ["params"] => string(56) "[{"title":"一包","content":"24瓶,每瓶500毫升"}]"
        ["content"] => string(139) "<p><img alt="未标题-1-07 1的副本.png" src="/uploads/20240515/35edfd23930cf93036b6642ac1e4b260.png" width="625" height="4096"><br></p>"
        ["price"] => string(5) "34.75"
        ["vip_price"] => string(2) "30"
        ["original_price"] => string(5) "50.00"
        ["is_sku"] => int(0)
        ["likes"] => int(0)
        ["views"] => int(28)
        ["sales"] => int(0)
        ["show_sales"] => int(100)
        ["service_ids"] => string(0) ""
        ["dispatch_type"] => string(7) "express"
        ["dispatch_ids"] => string(1) "2"
        ["createtime"] => int(1715744162)
        ["updatetime"] => int(1715825328)
        ["deletetime"] => NULL
      }
      ["relation":protected] => array(1) {
        ["favorite"] => NULL
      }
      ["auto":protected] => array(0) {
      }
      ["insert":protected] => array(0) {
      }
      ["update":protected] => array(0) {
      }
      ["dateFormat":protected] => bool(false)
      ["type":protected] => array(0) {
      }
      ["isUpdate":protected] => bool(true)
      ["replace":protected] => bool(false)
      ["force":protected] => bool(false)
      ["updateWhere":protected] => array(1) {
        ["id"] => array(2) {
          [0] => string(2) "eq"
          [1] => string(1) "3"
        }
      }
      ["failException":protected] => bool(false)
      ["useGlobalScope":protected] => bool(true)
      ["batchValidate":protected] => bool(false)
      ["resultSetType":protected] => string(5) "array"
      ["relationWrite":protected] => NULL
      ["zsetKey":protected] => string(13) "zset-activity"
      ["hashPrefix":protected] => string(14) "hash-activity:"
      ["hashGoodsPrefix":protected] => string(6) "goods-"
      ["hashGrouponPrefix":protected] => string(8) "groupon-"
    }
    ["query":protected] => NULL
    ["table":protected] => NULL
    ["class":protected] => string(33) "addons\shopro\model\GoodsSkuPrice"
    ["error":protected] => NULL
    ["validate":protected] => NULL
    ["pk":protected] => NULL
    ["field":protected] => array(0) {
    }
    ["except":protected] => array(0) {
    }
    ["disuse":protected] => array(0) {
    }
    ["readonly":protected] => array(0) {
    }
    ["visible":protected] => array(0) {
    }
    ["data":protected] => array(16) {
      ["id"] => int(3)
      ["goods_sku_ids"] => NULL
      ["goods_id"] => int(3)
      ["weigh"] => int(0)
      ["image"] => NULL
      ["stock"] => int(1000)
      ["stock_warning"] => NULL
      ["sales"] => int(0)
      ["sn"] => string(0) ""
      ["weight"] => int(0)
      ["price"] => string(5) "34.75"
      ["goods_sku_text"] => NULL
      ["status"] => string(2) "up"
      ["createtime"] => int(1715744162)
      ["updatetime"] => int(1715821756)
      ["deletetime"] => NULL
    }
    ["origin":protected] => array(16) {
      ["id"] => int(3)
      ["goods_sku_ids"] => NULL
      ["goods_id"] => int(3)
      ["weigh"] => int(0)
      ["image"] => NULL
      ["stock"] => int(1000)
      ["stock_warning"] => NULL
      ["sales"] => int(0)
      ["sn"] => string(0) ""
      ["weight"] => int(0)
      ["price"] => string(5) "34.75"
      ["goods_sku_text"] => NULL
      ["status"] => string(2) "up"
      ["createtime"] => int(1715744162)
      ["updatetime"] => int(1715821756)
      ["deletetime"] => NULL
    }
    ["relation":protected] => array(0) {
    }
    ["auto":protected] => array(0) {
    }
    ["insert":protected] => array(0) {
    }
    ["update":protected] => array(0) {
    }
    ["dateFormat":protected] => bool(false)
    ["type":protected] => array(0) {
    }
    ["isUpdate":protected] => bool(true)
    ["replace":protected] => bool(false)
    ["force":protected] => bool(false)
    ["updateWhere":protected] => NULL
    ["failException":protected] => bool(false)
    ["useGlobalScope":protected] => bool(true)
    ["batchValidate":protected] => bool(false)
    ["resultSetType":protected] => string(5) "array"
    ["relationWrite":protected] => NULL
  }
}
 
// 直接赋值
$v['detail']->sku_price[0]->price =   10; 
// 报错如下 Indirect modification of overloaded property addons\shopro\model\Goods::$sku_price has no effect
 
// 正确修改方式
foreach($v['detail']->sku_price as $vv){
     $vv->price = $v['detail']->vip_price; ;
}

发表评论

邮箱地址不会被公开。 必填项已用*标注