Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 获取foreach magento对象的属性_Php_Foreach_Magento 1.9 - Fatal编程技术网

Php 获取foreach magento对象的属性

Php 获取foreach magento对象的属性,php,foreach,magento-1.9,Php,Foreach,Magento 1.9,我有一个大数组,我想保存在数据库中。 我的代码行$model=Mage::getModel('thorleif/category')->setData($arr) 返回以下结果 object(Ns_Thorleif_Model_Category)#298 (15) { ["_eventPrefix":protected]=> string(13) "core_abstract" ["_eventObject":protected]=> string(6) "object" ["_re

我有一个大数组,我想保存在数据库中。 我的代码行
$model=Mage::getModel('thorleif/category')->setData($arr)
返回以下结果

object(Ns_Thorleif_Model_Category)#298 (15) { ["_eventPrefix":protected]=> string(13) "core_abstract" ["_eventObject":protected]=> string(6) "object" ["_resourceName":protected]=> string(17) "thorleif/category" ["_resource":protected]=> NULL ["_resourceCollectionName":protected]=> string(28) "thorleif/category_collection" ["_cacheTag":protected]=> bool(false) ["_dataSaveAllowed":protected]=> bool(true) ["_isObjectNew":protected]=> NULL ["_data":protected]=> array(5065) { [0]=> array(3) { ["id_linio_category"]=> int(18784) ["name"]=> string(8) "Mascotas" ["level"]=> int(0) } [1]=> array(3) { ["id_linio_category"]=> int(18893) ["name"]=> string(6) "Perros" ["level"]=> int(1) } [2]=> array(3) { ["id_linio_category"]=> int(18973) ["name"]=> string(27) "Camas y Muebles para perros" ["level"]=> int(2) } [3]=> array(3) { ["id_linio_category"]=> int(18985) ["name"]=> string(16) "Casa para Perros" ["level"]=> int(3) } [4]=> array(3) { ["id_linio_category"]=> int(18984) ["name"]=> string(21) "Colchones para perros" ["level"]=> int(3) } [5]=> array(3) { ["id_linio_category"]=> int(18983) ["name"]=> string(17) "Camas para Perros" ["level"]=> int(3) } [6]=> array(3) { ["id_linio_category"]=> int(18982) ["name"]=> string(29) "Camas de Plastico para Perros" ["level"]=> int(3) } [7]=> array(3) { ["id_linio_category"]=> int(18981) ["name"]=> string(29) "Camas Ortopedicas para Perros" ["level"]=> int(3) } [8]=> array(3) { ["id_linio_category"]=> int(18980) ["name"]=> string(19) "Tapetes para Perros" ["level"]=> int(3) } [9]=> array(3) { ["id_linio_category"]=> int(18979) ["name"]=> string(30) "Almohadas y Fundas para perros" ["level"]=> int(3) } [10]=> array(3) { ["id_linio_category"]=> int(18978) ["name"]=> string(20) "Corrales para Perros" ["level"]=> int(3) } [11]=> array(3) { ["id_linio_category"]=> int(18977) ["name"]=> string(27) "Puertas y Rejas para Perros" ["level"]=> int(3) }
如何从foreach中获取每个属性的值?谢谢

我已经这样了

foreach($arr as $value){
                $array = array('id_linio_category' => $value['id_linio_category'], 'name' => $value['name'], 'level' => $value['level']);
                $model = Mage::getModel('thorleif/category')->setData($array);
                $model->save();

            }
我已经变成这样了

foreach($arr as $value){
                $array = array('id_linio_category' => $value['id_linio_category'], 'name' => $value['name'], 'level' => $value['level']);
                $model = Mage::getModel('thorleif/category')->setData($array);
                $model->save();

            }