Laravel Eloquent Get Append Attributes With Find - php

I created a model with 10 append attributes and I can't get them with find() method. But when I convert returned object from find() to an array with method toArray() I can see them but I need them like an object.
This object was printed when I use find():
School Object
(
[table:protected] => schools
[fillable:protected] => Array
(
[0] => name
[1] => type_id
[2] => description
[3] => info_specialties
[4] => contacts
[5] => cover_name
[6] => financing_id
[7] => city
)
[guarded:protected] => Array
(
[0] => id
)
[appends:protected] => Array
(
[0] => type
[1] => short_type
[2] => school_url
[3] => cover_photo_url
[4] => cover_photo_thumbnail_url
[5] => city
[6] => municipality
[7] => appended_district_id
[8] => district
[9] => description_without_tags
)
[district_id] =>
[cover_photo] =>
[connection:protected] =>
[primaryKey:protected] => id
[perPage:protected] => 15
[incrementing] => 1
[timestamps] => 1
[attributes:protected] => Array
(
[id] => 24
[type_id] => 3
[name] => adasdasd
[description] =>
asdadasdasdasdqwdqd\qw\[dqw\d
[info_specialties] =>
qwqwdqwdqwdqwdqwd
[contacts] =>
qwdqwdqwdqwd
[cover_name] => SAbjfpe4m7.jpg
[financing_id] => 1
[city_id] => 18
[created_at] => 2015-01-31 20:56:06
[updated_at] => 2015-02-04 18:50:13
)
[original:protected] => Array
(
[id] => 24
[type_id] => 3
[name] => adasdasd
[description] =>
asdadasdasdasdqwdqd\qw\[dqw\d
[info_specialties] =>
qwqwdqwdqwdqwdqwd
[contacts] =>
qwdqwdqwdqwd
[cover_name] => SAbjfpe4m7.jpg
[financing_id] => 1
[city_id] => 18
[created_at] => 2015-01-31 20:56:06
[updated_at] => 2015-02-04 18:50:13
)
[relations:protected] => Array
(
)
[hidden:protected] => Array
(
)
[visible:protected] => Array
(
)
[dates:protected] => Array
(
)
[touches:protected] => Array
(
)
[observables:protected] => Array
(
)
[with:protected] => Array
(
)
[morphClass:protected] =>
[exists] => 1
)
And when I use toArray:
Array
(
[id] => 24
[type_id] => 3
[name] => adasdasd
[description] =>
asdadasdasdasdqwdqd\qw\[dqw\d
[info_specialties] =>
qwqwdqwdqwdqwdqwd
[contacts] =>
qwdqwdqwdqwd
[cover_name] => SAbjfpe4m7.jpg
[financing_id] => 1
[city_id] => 18
[created_at] => 2015-01-31 20:56:06
[updated_at] => 2015-02-04 18:50:13
[type] => qdasdasd
[short_type] => asdasdasd
[school_url] => http://localhost:8000/school/24
[cover_photo_url] => http://localhost:8000/storage/cover_photos/SAbjfpe4m7.jpg
[cover_photo_thumbnail_url] => http://localhost:8000/storage/cover_photos/thumbnails/SAbjfpe4m7.jpg
[city] => sdasdasd
[municipality] => ÐÑкаква община2 от нÑкакъв облаÑÑ‚2
[appended_district_id] => 6
[district] => ÐÑкакъв облаÑÑ‚2
[description_without_tags] => asdadasdasdasdqwdqd\qw\[dqw\d
)
Here's an example of my class:
<?php
class School extends Eloquent {
protected $appends = array('type');
public function getTypeAttribute()
{
return Type::find($this->type_id)->name;
}
}

That's the nature of custom attributes that you get with an attribute accessor. They will only be evaluated when used (and then cached for later use). When you convert it to and array, all $appends properties are loaded.
If you have your model object you can just access them like any other attribute:
$school->type;

Related

how to fetch data from json? [duplicate]

This question already has an answer here:
How to extract and access data from JSON with PHP?
(1 answer)
Closed 3 years ago.
i have data in json something like that:
stdClass Object
(
[contacts] => stdClass Object
(
[14] => stdClass Object
(
[data] => stdClass Object
(
[email] => veer#gmail.com
[first_name] => veer
[last_name] =>
[user_id] => 16
[owner_id] => 0
[optin_status] => 0
[date_created] => 2020-01-20 13:14:54
[ID] => 14
[gravatar] => http://localhost:8888/wordpress/wp-content/themes/wp_lms/assets/images/avatar.jpg
[age] =>
)
[meta] => stdClass Object
(
[preferences_changed] => 1579526094
[user_login] => veer
[profile_picture] => http://localhost:8888/wordpress/wp-content/themes/wp_lms/assets/images/avatar.jpg
[birthday] =>
)
[tags] => Array
(
[0] => 92
[1] => 13
[2] => 12
[3] => 9
)
[files] => Array
(
)
)
[9] => stdClass Object
(
[data] => stdClass Object
(
[email] => singh.pratibha1432#gmail.com
[first_name] => Pratibha
[last_name] => Singh
[user_id] => 8
[owner_id] => 0
[optin_status] => 0
[date_created] => 2020-01-20 13:14:54
[ID] => 9
[gravatar] => http://localhost:8888/wordpress/wp-content/themes/wp_lms/assets/images/avatar.jpg
[age] =>
)
[meta] => stdClass Object
(
[preferences_changed] => 1579526094
[user_login] => pratibha
[profile_picture] => http://localhost:8888/wordpress/wp-content/themes/wp_lms/assets/images/avatar.jpg
[birthday] =>
)
[tags] => Array
(
[0] => 94
[1] => 93
[2] => 92
[3] => 91
[4] => 82
[5] => 15
[6] => 14
[7] => 13
[8] => 9
)
[files] => Array
(
)
)
[4] => stdClass Object
(
[data] => stdClass Object
(
[email] => singh.dev1432#gmail.com
[first_name] => Devesh
[last_name] => Singh
[user_id] => 7
[owner_id] => 0
[optin_status] => 0
[date_created] => 2020-01-20 13:14:54
[ID] => 4
[gravatar] => http://localhost:8888/wordpress/wp-content/themes/wp_lms/assets/images/avatar.jpg
[age] =>
)
[meta] => stdClass Object
(
[preferences_changed] => 1579526094
[user_login] => devesh
[profile_picture] => http://localhost:8888/wordpress/wp-content/themes/wp_lms/assets/images/avatar.jpg
[birthday] =>
)
[tags] => Array
(
[0] => 93
[1] => 92
[2] => 15
[3] => 12
[4] => 11
[5] => 9
)
[files] => Array
(
)
)
[2] => stdClass Object
(
[data] => stdClass Object
(
[email] => admin#gmail.com
[first_name] => veronica
[last_name] =>
[user_id] => 1
[owner_id] => 0
[optin_status] => 0
[date_created] => 2020-01-20 13:14:54
[ID] => 2
[gravatar] => http://localhost:8888/wordpress/wp-content/uploads/avatars/1/5dc525d984494-bpfull.jpg
[age] =>
)
[meta] => stdClass Object
(
[preferences_changed] => 1579526094
[user_login] => admin
[profile_picture] => http://localhost:8888/wordpress/wp-content/uploads/avatars/1/5dc525d984494-bpfull.jpg
[birthday] =>
)
[tags] => Array
(
[0] => 94
[1] => 92
[2] => 15
[3] => 14
[4] => 13
[5] => 9
)
[files] => Array
(
)
)
)
[status] => success
)
and now I am trying to fetch "email" from the contacts->id->data->email so for that i am using this code. I am trying to loop the things by which i can fetch email from all the ids present. and in the ids section, there is data and inside data the email is present so how can i fetch all emails from all the ids.
foreach ((Array)$body->contacts as $id => $values) {
foreach ($values as $data => $value) {
$emails = array('email'=>$value->email);
return $emails;
}
}
but it return only single data:
Array
(
[email] => veer#gmail.com
)
i want to fetch all the email like that:
Array
(
[0] => Array
(
[emails] => veer#gmail.com
)
[1] => Array
(
[emails] => singh.pratibha1432#gmail.com
)
[2] => Array
(
[emails] => singh.dev1432#gmail.com
)
[3] => Array
(
[emails] => admin#gmail.com
)
)
how can I achieve this?
Define null array and in foreach run store every email in that variable.
$emails = array();
foreach ((Array)$body->contacts as $id => $values) {
foreach ($values as $data => $value) {
$emails[] = array('emails'=>$contact->data->email;);
}
}
return $emails;

How to access protective array? [duplicate]

This question already has answers here:
Get Order items and WC_Order_Item_Product in WooCommerce 3
(2 answers)
Closed 5 years ago.
I have woocommrece order detail array which had protective element so when like normal array you can't access them via their key .This array is result of the plugin file code which i have purchased.
I have customize this code so many time but the protective array do not let me access into it. Any idea
Array
(
[1251] => WC_Order_Item_Product Object
(
[extra_data:protected] => Array
(
[product_id] => 0
[variation_id] => 0
[quantity] => 1
[tax_class] =>
[subtotal] => 0
[subtotal_tax] => 0
[total] => 0
[total_tax] => 0
[taxes] => Array
(
[subtotal] => Array
(
)
[total] => Array
(
)
)
)
[data:protected] => Array
(
[order_id] => 2040
[name] => Vanilla Pastries
[product_id] => 776
[variation_id] => 0
[quantity] => 5
[tax_class] => gst_18
[subtotal] => 296.6
[subtotal_tax] => 53.388
[total] => 296.6
[total_tax] => 53.388
[taxes] => Array
(
[total] => Array
(
[5] => 26.694
[10] => 26.694
)
[subtotal] => Array
(
[5] => 26.694
[10] => 26.694
)
)
)
[cache_group:protected] => order-items
[meta_type:protected] => order_item
[object_type:protected] => order_item
[id:protected] => 1251
[changes:protected] => Array
(
)
[object_read:protected] => 1
[default_data:protected] => Array
(
[order_id] => 0
[name] =>
[product_id] => 0
[variation_id] => 0
[quantity] => 1
[tax_class] =>
[subtotal] => 0
[subtotal_tax] => 0
[total] => 0
[total_tax] => 0
[taxes] => Array
(
[subtotal] => Array
(
)
[total] => Array
(
)
)
)
[data_store:protected] => WC_Data_Store Object
(
[instance:WC_Data_Store:private] => WC_Order_Item_Product_Data_Store Object
(
[internal_meta_keys:protected] => Array
(
[0] => _order_id
[1] => _name
[2] => _product_id
[3] => _variation_id
[4] => _quantity
[5] => _tax_class
[6] => _subtotal
[7] => _subtotal_tax
[8] => _total
[9] => _total_tax
[10] => _taxes
[11] => _product_id
[12] => _variation_id
[13] => _qty
[14] => _tax_class
[15] => _line_subtotal
[16] => _line_subtotal_tax
[17] => _line_total
[18] => _line_tax
[19] => _line_tax_data
)
[meta_type:protected] => order_item
[object_id_field_for_meta:protected] => order_item_id
)
[stores:WC_Data_Store:private] => Array
(
[coupon] => WC_Coupon_Data_Store_CPT
[customer] => WC_Customer_Data_Store
[customer-download] => WC_Customer_Download_Data_Store
[customer-session] => WC_Customer_Data_Store_Session
[order] => WC_Order_Data_Store_CPT
[order-refund] => WC_Order_Refund_Data_Store_CPT
[order-item] => WC_Order_Item_Data_Store
[order-item-coupon] => WC_Order_Item_Coupon_Data_Store
[order-item-fee] => WC_Order_Item_Fee_Data_Store
[order-item-product] => WC_Order_Item_Product_Data_Store
[order-item-shipping] => WC_Order_Item_Shipping_Data_Store
[order-item-tax] => WC_Order_Item_Tax_Data_Store
[payment-token] => WC_Payment_Token_Data_Store
[product] => WC_Product_Data_Store_CPT
[product-grouped] => WC_Product_Grouped_Data_Store_CPT
[product-variable] => WC_Product_Variable_Data_Store_CPT
[product-variation] => WC_Product_Variation_Data_Store_CPT
[shipping-zone] => WC_Shipping_Zone_Data_Store
)
[current_class_name:WC_Data_Store:private] => WC_Order_Item_Product_Data_Store
[object_type:WC_Data_Store:private] => order-item-product
)
[meta_data:protected] => Array
(
)
)
)
The object you want to access has the type WC_Order_Item_Product. Use its public methods to query it for data or tell it to do something.
This is how OOP works. You don't even need to know how the object properties are named.
I guess
global $post;
echo '<pre>';
print_r($post->data);
echo '</pre>';
echo $post->data->order_id;

Laravel Getting attributes data

I am new in laravel using Laravel 5.3.
I am creating a check() function in laravel model for user login
here i get all data form database useing default $this->all(); this return me a large multidymentional
array .
Illuminate\Database\Eloquent\Collection Object
(
[items:protected] => Array
(
[0] => App\wn_users Object
(
[table:protected] => wn_users
[timestamps] =>
[fillable:protected] => Array
(
[0] => role_id
[1] => firstname
[2] => lastname
[3] => username
[4] => email
[5] => password
[6] => companyname
[7] => country_id
[8] => description
[9] => ip
[10] => update_date
[11] => status
)
[connection:protected] =>
[primaryKey:protected] => id
[keyType:protected] => int
[incrementing] => 1
[with:protected] => Array
(
)
[perPage:protected] => 15
[exists] => 1
[wasRecentlyCreated] =>
[attributes:protected] => Array
(
[user_id] => 1
[role_id] => 1
[firstname] => Aman kumar
[lastname] => --
[username] => Aman kumar
[email] => aman.imaxtechnologies#gmail.com
[password] => e10adc3949ba59abbe56e057f20f883e
[companyname] => Imax
[country_id] => 123
[description] => Testing
[ip] => 192.168.1.1
[update_date] => 2017-03-20
[status] => 0
[created_at] =>
[updated_at] =>
)
[original:protected] => Array
(
[user_id] => 1
[role_id] => 1
[firstname] => Aman kumar
[lastname] => --
[username] => Aman kumar
[email] => aman.imaxtechnologies#gmail.com
[password] => e10adc3949ba59abbe56e057f20f883e
[companyname] => Imax
[country_id] => 123
[description] => Testing
[ip] => 192.168.1.1
[update_date] => 2017-03-20
[status] => 0
[created_at] =>
[updated_at] =>
)
[casts:protected] => Array
(
)
[dates:protected] => Array
(
)
[dateFormat:protected] =>
[appends:protected] => Array
(
)
[events:protected] => Array
(
)
[observables:protected] => Array
(
)
[relations:protected] => Array
(
)
[touches:protected] => Array
(
)
[hidden:protected] => Array
(
)
[visible:protected] => Array
(
)
[guarded:protected] => Array
(
[0] => *
)
)
)
)
But i want to get only 'attributes:protected' Form whole array in laravel . I have already tried
echo $data = $this->getAttributes()['firstname']; but this returns error
Undefined index: firstname
Please help me to resolve my issue
Thanks in Advance for your help and time .
A very simple way:
$arr = $this->all()->toArray();
var_dump($arr); // oh~ array data!
So you have a collection with properties. And you can access them just like $collection->first()->firstname Or if you want to do some operation with all items use each method:
$collection = $collection->each(function ($item, $key) {
$item->firstname .= ' Smith';
});

Laravel 5 relationship belongsTo not working

First of all what I want to achieve it's quite simple : I want to use relationship belongsTo from Laravel 5 to get a value from another table. Like so
<?= $email->contact->first_name; ?>
But this is not working at all, instead, I get this error : Trying to get property of non-object. But when I do print_r($email) it shows me that $email is actually an object...So I really don't understand now.
This is (a part of) what I have in my Controller :
$emails = Email::where('user_id', '=', Auth::user()->id)->take(6)->orderBy('created_at', 'desc')->get();
This is what I have in my view :
foreach($emails as $key => $email) {
echo $email->contact->first_name; ?>
}
This is my model email
public function contact()
{
return $this->belongsTo('App\Contact', 'contact_id');
}
As you can see, I am using a second parameter inside belongsTo method, which is 'contact_id' because I don't want to use 'user_id' as the foreign key.
EDIT:
This is my output of print_r($email) :
App\Email Object ( [connection:protected] => [table:protected] => [primaryKey:protected] => id [perPage:protected] => 15 [incrementing] => 1 [timestamps] => 1 [attributes:protected] => Array ( [id] => 88 [user_id] => 1 [group_id] => 1 [contact_id] => 79 [reminder_id] => 31 [subject] => Test task #3 [view] => 0 [view_hash] => $2y$10$NZ3B.UUqtRRl2opH5UwXOeRNeRROeZGdid6Crs4ShT1VptbZJS.iu [content] => blablabla
EDIT 2 :
This is my output of print_r($email->contact) :
App\Contact Object ( [fillable:protected] => Array ( [0] => title [1] => content ) [table:protected] => contacts [connection:protected] => [primaryKey:protected] => id [perPage:protected] => 15 [incrementing] => 1 [timestamps] => 1 [attributes:protected] => Array ( [id] => 86 [user_id] => 1 [group_id] => 1 [first_name] => Matthieu [last_name] => Boistoule [email] => m.boistoule#gmail.com [phone] => [company] => [title] => [website] => [industry] => [address] => [city] => [country] => [province] => [postal_code] => [lead_source] => [notes] => [created_at] => 2015-06-04 12:13:00 [updated_at] => 2015-06-04 12:13:00 ) [original:protected] => Array ( [id] => 86 [user_id] => 1 [group_id] => 1 [first_name] => Matthieu [last_name] => Boistoule [email] => m.boistoule#gmail.com [phone] => [company] => [title] => [website] => [industry] => [address] => [city] => [country] => [province] => [postal_code] => [lead_source] => [notes] => [created_at] => 2015-06-04 12:13:00 [updated_at] => 2015-06-04 12:13:00 ) [relations:protected] => Array ( ) [hidden:protected] => Array ( ) [visible:protected] => Array ( ) [appends:protected] => Array ( ) [guarded:protected] => Array ( [0] => * ) [dates:protected] => Array ( ) [casts:protected] => Array ( ) [touches:protected] => Array ( ) [observables:protected] => Array ( ) [with:protected] => Array ( ) [morphClass:protected] => [exists] => 1 )

how to get an array value on php magento to display magento wishlist image

Hi am customizing magento wishlist and I want to display image on every product on my wishlist.
currently the products display the default image (no image).
in my view.phtml in wishlist directory this my code
foreach($this->getWishlist() as $item){
// ... some code
<img src="<?php echo $this->helper('catalog/image')->init($item, 'small_image')->resize(113, 113)*/?>" alt="<?php echo $item->getName();?>" width="113"/>
// the image that always shows the no image, it does not display the product image..
// I think there is something wrong with $this->helper('catalog/image')->init($item, 'small_image')->resize(113, 113)
// i try to print thr $item
print_r($item);
}
this is the result
Mage_Wishlist_Model_Item Object
(
[_customOptionDownloadUrl:protected] => wishlist/index/downloadCustomOption
[_eventPrefix:protected] => wishlist_item
[_eventObject:protected] => item
[_options:protected] => Array
(
[0] => Mage_Wishlist_Model_Item_Option Object
(
[_item:protected] => Mage_Wishlist_Model_Item Object
*RECURSION*
[_product:protected] =>
[_eventPrefix:protected] => core_abstract
[_eventObject:protected] => object
[_resourceName:protected] => wishlist/item_option
[_resource:protected] =>
[_resourceCollectionName:protected] => wishlist/item_option_collection
[_cacheTag:protected] =>
[_dataSaveAllowed:protected] => 1
[_isObjectNew:protected] =>
[_data:protected] => Array
(
[option_id] => 26
[wishlist_item_id] => 26
[product_id] => 6767
[code] => info_buyRequest
[value] => a:1:{s:7:"product";s:4:"6767";}
)
[_hasDataChanges:protected] => 1
[_origData:protected] => Array
(
[option_id] => 26
[wishlist_item_id] => 26
[product_id] => 6767
[code] => info_buyRequest
[value] => a:1:{s:7:"product";s:4:"6767";}
)
[_idFieldName:protected] => option_id
[_isDeleted:protected] =>
[_oldFieldsMap:protected] => Array
(
)
[_syncFieldsMap:protected] => Array
(
)
)
)
[_optionsByCode:protected] => Array
(
[info_buyRequest] => Mage_Wishlist_Model_Item_Option Object
(
[_item:protected] => Mage_Wishlist_Model_Item Object
*RECURSION*
[_product:protected] =>
[_eventPrefix:protected] => core_abstract
[_eventObject:protected] => object
[_resourceName:protected] => wishlist/item_option
[_resource:protected] =>
[_resourceCollectionName:protected] => wishlist/item_option_collection
[_cacheTag:protected] =>
[_dataSaveAllowed:protected] => 1
[_isObjectNew:protected] =>
[_data:protected] => Array
(
[option_id] => 26
[wishlist_item_id] => 26
[product_id] => 6767
[code] => info_buyRequest
[value] => a:1:{s:7:"product";s:4:"6767";}
)
[_hasDataChanges:protected] => 1
[_origData:protected] => Array
(
[option_id] => 26
[wishlist_item_id] => 26
[product_id] => 6767
[code] => info_buyRequest
[value] => a:1:{s:7:"product";s:4:"6767";}
)
[_idFieldName:protected] => option_id
[_isDeleted:protected] =>
[_oldFieldsMap:protected] => Array
(
)
[_syncFieldsMap:protected] => Array
(
)
)
)
[_notRepresentOptions:protected] => Array
(
[0] => info_buyRequest
)
[_flagOptionsSaved:protected] =>
[_resourceName:protected] => wishlist/item
[_resource:protected] =>
[_resourceCollectionName:protected] => wishlist/item_collection
[_cacheTag:protected] =>
[_dataSaveAllowed:protected] => 1
[_isObjectNew:protected] =>
[_data:protected] => Array
(
[wishlist_item_id] => 26
[wishlist_id] => 5
[product_id] => 6767
[store_id] => 1
[added_at] => 2013-06-11 03:14:04
[description] =>
[qty] => 1.0000
[product] => Mage_Catalog_Model_Product Object
(
[_cacheTag:protected] => catalog_product
[_eventPrefix:protected] => catalog_product
[_eventObject:protected] => product
[_canAffectOptions:protected] =>
[_typeInstance:protected] =>
[_typeInstanceSingleton:protected] =>
[_linkInstance:protected] =>
[_customOptions:protected] => Array
(
)
[_urlModel:protected] =>
[_errors:protected] => Array
(
)
[_optionInstance:protected] =>
[_options:protected] => Array
(
)
[_reservedAttributes:protected] =>
[_isDuplicable:protected] => 1
[_calculatePrice:protected] => 1
[_defaultValues:protected] => Array
(
)
[_storeValuesFlags:protected] => Array
(
)
[_lockedAttributes:protected] => Array
(
)
[_isDeleteable:protected] => 1
[_isReadonly:protected] =>
[_resourceName:protected] => catalog/product
[_resource:protected] =>
[_resourceCollectionName:protected] => catalog/product_collection
[_dataSaveAllowed:protected] => 1
[_isObjectNew:protected] =>
[_data:protected] => Array
(
[entity_id] => 6767
[entity_type_id] => 4
[attribute_set_id] => 4
[type_id] => simple
[sku] => sku6768
[has_options] => 0
[required_options] => 0
[created_at] => 2011-07-25 19:46:25
[updated_at] => 2013-06-03 21:08:50
[cat_index_position] => 80000
[price] => 0.0000
[tax_class_id] => 2
[final_price] => 0.0000
[minimal_price] => 0.0000
[min_price] => 0.0000
[max_price] => 0.0000
[tier_price] =>
[image_label] => Amplifier +15V Input
[manufacturer2] => 130
[name] => Amplifier +15V Input
[small_image] => /d/s/dsc00394.jpg
[small_image_label] => Amplifier +15V Input
[thumbnail] => /d/s/dsc00394.jpg
[thumbnail_label] => Amplifier +15V Input
[url_key] => amplifier-15v-input
[url_path] => amplifier-15v-input.html
[short_description] => <p> </p>
[status] => 1
[visibility] => 4
[is_salable] => 1
[stock_item] => Varien_Object Object
(
[_data:protected] => Array
(
[is_in_stock] => 1
)
[_hasDataChanges:protected] =>
[_origData:protected] =>
[_idFieldName:protected] =>
[_isDeleted:protected] =>
[_oldFieldsMap:protected] => Array
(
)
[_syncFieldsMap:protected] => Array
(
)
)
[request_path] => amplifier-15v-input.html
)
[_hasDataChanges:protected] => 1
[_origData:protected] =>
[_idFieldName:protected] => entity_id
[_isDeleted:protected] =>
[_oldFieldsMap:protected] => Array
(
)
[_syncFieldsMap:protected] => Array
(
)
)
[product_name] => Amplifier +15V Input
[name] => Amplifier +15V Input
[price] => 0.0000
)
[_hasDataChanges:protected] =>
[_origData:protected] => Array
(
[wishlist_item_id] => 26
[wishlist_id] => 5
[product_id] => 6767
[store_id] => 1
[added_at] => 2013-06-11 03:14:04
[description] =>
[qty] => 1.0000
)
[_idFieldName:protected] => wishlist_item_id
[_isDeleted:protected] =>
[_oldFieldsMap:protected] => Array
(
)
[_syncFieldsMap:protected] => Array
(
)
)
now, my problem is how can I query or get the [_resourceName:protected] => catalog/product and [small_image] => /d/s/dsc00394.jpg from the print_r($item); ?
i just want it to be print on my image source, does anyone has an idea about my case?
thanks in advance ....
I got the solution about this, I try this.
foreach ($item->_data as $item_img){
echo $item_img->_data[small_image];
}

Categories