Laravel differences linux and windows hosting - laravel

This is very strange: On Windows these functions with exactly the same databases works greats, but when I upload the project to Linux the pageinfo() function returns null. Of course the first thing I thought was that this has to do with case sensitivity, but all seems well formatted...
In my Page Model:
public function pageinfo() {
return $this->hasMany('App\Models\PageToElement', 'page_id');
}
(The Model PageToElement is exactly called like this)
In my controller:
$this->info = Page::find($page->page_id);
$meta = $this->info->pageinfo->where('element_id', 1)->first();
On Windows this nicely returns array:
App\Models\PageToElement Object (
[attributes:protected] => Array(
[id] => 1
[page_id] => 1
[element_id] => 1
[element_parent_id] => 0
[parent_id] => 0
[sorting] => 0
[is_active] => 1
[created_at] => 2015-12-07 10:00:03
[updated_at] => 2015-12-07 10:00:03
)
)
But on Linux, the response is null
What am I overlooking?
After some research, I came to the conclusion that $meta = $this->page->pageinfo->where('element_id', 1)->first(); returns null on the Linux server. But when I do $meta = $this->page->pageinfo; I do get more than one item in return. When I then do $meta = $this->page->pageinfo->first(); it returns one. So I think somehow the where('element_id', 1) is not working for Linux.
But what do you know, $meta = $this->page->pageinfo->where('element_id', '1')->first(); works! element_id is an integer, so why does it need quotes???

But what do you know, $meta = $this->page->pageinfo->where('element_id', '1')->first(); works! But then again not on Windows.
So I wounded up adding an extra line $id = 1; and parsing that in the query.
Strange workaround though

Related

How to merge multiple arrays in PHP and output the values together?

I have a situation while developing an application on Laravel. I have three arrays in the following order. I need to merge them and display their values in the following order too. Here , it goes.
stone_name['ruby','diamond','catseye'];
stone_weight[112,223,445];
stone_rate[1000,2500,670];
I need to merge these three arrays and display the out put in this order.
stone_info = array(stone_name[0] , stone_weight[0] , stone_rate[0]);
So that the final result will be like :
stone_info = array("ruby",112,1000);
I was in the same situation and I had done it in this way. May be this can help you out.
<?php
$stone_name = ['ruby','diamond','catseye'];
$stone_weight = [112,223,445];
$stone_rate = [1000,2500,670];
$result = mergeArrays($stone_name, $stone_weight, $stone_rate);
function mergeArrays($stone_name, $stone_weight, $stone_rate) {
$result = array();
foreach ($stone_name as $key => $name ) {
$result[] = array( 'stone_name' => $name, 'stone_weight' => $stone_weight[$key], 'stone_rate' => $stone_rate[ $key ] );
}
return $result;
}
print_r($result);
Output:
Array
(
[0] => Array
(
[stone_name] => ruby
[stone_weight] => 112
[stone_rate] => 1000
)
[1] => Array
(
[stone_name] => diamond
[stone_weight] => 223
[stone_rate] => 2500
)
[2] => Array
(
[stone_name] => catseye
[stone_weight] => 445
[stone_rate] => 670
)
)
DEMO

Codeigniter echo session Multidimensional Array variable

Okay im using codeigniter and i got a session where i want to echo [user_id], i can see its an "Multidimensional Array", but i cant seem to get it right...
This is the print_r from all session userdata:
Array (
[session_id] => b7e721332248
[ip_address] => ::1
[user_agent] => Mozilla/5.0
[last_activity] => 1409104940
[user_data] => [name] => 2 [uniq] => 2
[flexi_auth] => Array ( [user_identifier] => mail.com [user_id] => 2 [admin] => 1
[group] => Array ( [3] => Master Admin )
[privileges] => Array ( )
[logged_in_via_password] => 1
[login_session_token] => 11017021313jhbjh1h2j3b213mab913269d95 ) )
if i type:
print_r($this->session->all_userdata()); // i will get all
echo $this->session->userdata('uniq'); //returns 2
echo $this->session->userdata('user_id'); //returns nothing(THIS IS THE PROBLEM)
Ive tried something like this:
$this->session->userdata(1,1); //1,1 would be array 2 and number 2 which would be user_id
Is it because i can only print out if I loop through them somehow?
You're trying to call the data directly, if you're want to access user_data or flexi_auth you need to assign the data to a variable then target it since they're arrays.
$session_data = $this->session->all_userdata();
echo $session_data['user_data']['uniq']; // 2
$user_data = $this->session->userdata('user_data');
echo $user_data['uniq']; /// 2
$flexi_auth = $this->session->userdata('flexi_auth');
echo $flexi_auth['user_id']; /// 2
If you're trying to target a string directly
echo $this->session->userdata('last_activity');
You can simply access user name stored in session like this
echo $this->session->userdata['user_data']['name'];
Be sure you have some userdata in session or use like this to avoid any errors
echo #$this->session->userdata['user_data']['name'];
adding # does not generate any errors. hope you got the answer you were looking for.

Get product id from recurring profile Array

I am Using an Observer on Place Order for Recurring Profile
public function SubscribePlan($observer){
$profileIds = Mage::getSingleton('checkout/session')->getLastRecurringProfileIds();
if ($profileIds && is_array($profileIds)) {
$collection = Mage::getModel('sales/recurring_profile')->getCollection()
->addFieldToFilter('profile_id', array('in' => $profileIds))
;
$profiles = array();
foreach ($collection as $profile) {
$profiles[]= $profile;
}
echo"<pre>"; print_r($profiles); echo"</pre>"; die('dead');
}
and Printing Array , It Give me Array like this
[profile_id] => 53
[state] => active
[customer_id] => 10
[store_id] => 1
[method_code] => paypal_express
[created_at] => 2014-06-25 06:04:43
[updated_at] => 2014-06-25 06:04:44
[reference_id] => I-KJXWM42XC01K
[subscriber_name] =>
[start_datetime] => 2014-06-25 06:04:44
[internal_reference_id] => 53-4ba91ddd43b6d2d377378a5aba7f3908
[schedule_description] => One Year
[suspension_threshold] => 5
[bill_failed_later] => 0
[period_unit] => year
[period_frequency] => 1
[period_max_cycles] =>
[billing_amount] => 100.0000
[trial_period_unit] =>
[trial_period_frequency] =>
[trial_period_max_cycles] =>
[trial_billing_amount] =>
[currency_code] => USD
[shipping_amount] => 5.0000
[tax_amount] =>
[init_amount] =>
[init_may_fail] => 0
[order_info] => a:56:{s:9:"entity_id";s:2:"72";s:8:"store_id";s:1:"1";s:10:"created_at";s:19:"2014-06-25 06:03:28";s:10:"updated_at";s:19:"2014-06-25 06:04:38";s:12:"converted_at";N;s:9:"is_active";s:1:"1";s:10:"is_virtual";s:1:"0";s:17:"is_multi_shipping";s:1:"0";s:11:"items_count";i:1;s:9:"items_qty";d:1;s:13:"orig_order_id";s:1:"0";s:18:"store_to_base_rate";s:6:"1.0000";s:19:"store_to_quote_rate";s:6:"1.0000";s:18:"base_currency_code";s:3:"USD";s:19:"store_currency_code";s:3:"USD";s:19:"quote_currency_code";s:3:"USD";s:11:"grand_total";d:0;s:16:"base_grand_total";d:0;s:15:"checkout_method";N;s:11:"customer_id";s:2:"10";s:21:"customer_tax_class_id";s:1:"3";s:17:"customer_group_id";s:1:"1";s:14:"customer_email";s:17:"krn#ocodewire.com";s:15:"customer_prefix";N;s:18:"customer_firstname";s:5:"Karan";s:19:"customer_middlename";N;s:17:"customer_lastname";s:8:"Adhikari";s:15:"customer_suffix";N;s:12:"customer_dob";N;s:13:"customer_note";N;s:20:"customer_note_notify";s:1:"1";s:17:"customer_is_guest";s:1:"0";s:9:"remote_ip";s:14:"112.196.22.234";s:16:"applied_rule_ids";s:0:"";s:17:"reserved_order_id";s:9:"100000057";s:13:"password_hash";N;s:11:"coupon_code";N;s:20:"global_currency_code";s:3:"USD";s:19:"base_to_global_rate";s:6:"1.0000";s:18:"base_to_quote_rate";s:6:"1.0000";s:15:"customer_taxvat";N;s:15:"customer_gender";s:4:"male";s:8:"subtotal";d:0;s:13:"base_subtotal";d:0;s:22:"subtotal_with_discount";d:0;s:27:"base_subtotal_with_discount";d:0;s:10:"is_changed";s:1:"1";s:17:"trigger_recollect";i:0;s:17:"ext_shipping_info";N;s:15:"gift_message_id";N;s:13:"is_persistent";s:1:"0";s:15:"x_forwarded_for";N;s:17:"virtual_items_qty";i:0;s:15:"taxes_for_items";a:0:{}s:14:"can_apply_msrp";b:0;s:21:"totals_collected_flag";b:1;}
[order_item_info] => a:74:{s:7:"item_id";s:2:"88";s:8:"quote_id";s:2:"72";s:10:"created_at";s:19:"2014-06-25 06:03:28";s:10:"updated_at";s:19:"2014-06-25 06:03:28";s:10:"product_id";s:1:"6";s:8:"store_id";s:1:"1";s:14:"parent_item_id";N;s:10:"is_virtual";s:1:"0";s:3:"sku";s:10:"one-yr-sub";s:4:"name";s:8:"One Year";s:11:"description";N;s:16:"applied_rule_ids";s:0:"";s:15:"additional_data";N;s:13:"free_shipping";s:1:"0";s:14:"is_qty_decimal";s:1:"0";s:11:"no_discount";s:1:"0";s:6:"weight";s:6:"0.0010";s:3:"qty";i:1;s:5:"price";d:100;s:10:"base_price";d:100;s:12:"custom_price";N;s:16:"discount_percent";i:0;s:15:"discount_amount";i:0;s:20:"base_discount_amount";i:0;s:11:"tax_percent";i:0;s:10:"tax_amount";i:0;s:15:"base_tax_amount";i:0;s:9:"row_total";d:100;s:14:"base_row_total";d:100;s:23:"row_total_with_discount";s:6:"0.0000";s:10:"row_weight";d:0.001000000000000000020816681711721685132943093776702880859375;s:12:"product_type";s:6:"simple";s:24:"base_tax_before_discount";N;s:19:"tax_before_discount";N;s:21:"original_custom_price";N;s:12:"redirect_url";N;s:9:"base_cost";N;s:14:"price_incl_tax";d:100;s:19:"base_price_incl_tax";d:100;s:18:"row_total_incl_tax";d:100;s:23:"base_row_total_incl_tax";d:100;s:17:"hidden_tax_amount";i:0;s:22:"base_hidden_tax_amount";i:0;s:15:"gift_message_id";N;s:20:"weee_tax_disposition";i:0;s:24:"weee_tax_row_disposition";i:0;s:25:"base_weee_tax_disposition";i:0;s:29:"base_weee_tax_row_disposition";i:0;s:16:"weee_tax_applied";s:6:"a:0:{}";s:23:"weee_tax_applied_amount";i:0;s:27:"weee_tax_applied_row_amount";i:0;s:28:"base_weee_tax_applied_amount";i:0;s:30:"base_weee_tax_applied_row_amnt";N;s:11:"qty_options";a:0:{}s:12:"tax_class_id";s:1:"0";s:12:"is_recurring";s:1:"1";s:9:"has_error";b:0;s:10:"is_nominal";b:1;s:22:"base_calculation_price";d:100;s:17:"calculation_price";d:100;s:15:"converted_price";d:100;s:19:"base_original_price";d:100;s:14:"taxable_amount";d:100;s:19:"base_taxable_amount";d:100;s:17:"is_price_incl_tax";b:0;s:14:"original_price";d:100;s:32:"base_weee_tax_applied_row_amount";i:0;s:25:"discount_tax_compensation";i:0;s:20:"base_shipping_amount";d:5;s:15:"shipping_amount";d:5;s:17:"nominal_row_total";d:105;s:22:"base_nominal_row_total";d:105;s:21:"nominal_total_details";a:0:{}s:15:"info_buyRequest";s:225:"a:4:{s:4:"uenc";s:124:"aHR0cDovL2J3Y211bHRpbWVkaWEuY29tL0UvZXh0ZW5zaW9udGVzdC9pbmRleC5waHAvbXVsdGl2ZW5kb3IvdmVuZG9ycHJvZHVjdHMvc3Vic2NyaXB0aW9uLw,,";s:7:"product";s:1:"6";s:8:"form_key";s:16:"be2eDRXu1MC7OXfK";s:3:"qty";i:1;}";}
[billing_address_info] => a:97:{s:10:"address_id";s:3:"145";s:8:"quote_id";s:2:"72";s:10:"created_at";s:19:"2014-06-25 06:03:28";s:10:"updated_at";s:19:"2014-06-25 06:04:38";s:11:"customer_id";s:2:"10";s:20:"save_in_address_book";s:1:"0";s:19:"customer_address_id";N;s:12:"address_type";s:7:"billing";s:5:"email";s:23:"sukhwantc#ocodewire.com";s:6:"prefix";N;s:9:"firstname";s:4:"test";s:10:"middlename";N;s:8:"lastname";s:4:"test";s:6:"suffix";N;s:7:"company";s:9:"OcodeTest";s:6:"street";s:9:"1 Main St";s:4:"city";s:8:"San Jose";s:6:"region";s:10:"California";s:9:"region_id";s:2:"12";s:8:"postcode";s:5:"95131";s:10:"country_id";s:2:"US";s:9:"telephone";s:10:"9085656554";s:3:"fax";N;s:15:"same_as_billing";s:1:"1";s:13:"free_shipping";i:0;s:22:"collect_shipping_rates";s:1:"0";s:15:"shipping_method";N;s:20:"shipping_description";N;s:6:"weight";i:0;s:8:"subtotal";i:0;s:13:"base_subtotal";i:0;s:22:"subtotal_with_discount";s:6:"0.0000";s:27:"base_subtotal_with_discount";s:6:"0.0000";s:10:"tax_amount";i:0;s:15:"base_tax_amount";i:0;s:15:"shipping_amount";i:0;s:20:"base_shipping_amount";i:0;s:19:"shipping_tax_amount";i:0;s:24:"base_shipping_tax_amount";i:0;s:15:"discount_amount";i:0;s:20:"base_discount_amount";i:0;s:11:"grand_total";d:0;s:16:"base_grand_total";d:0;s:14:"customer_notes";N;s:13:"applied_taxes";s:6:"a:0:{}";s:20:"discount_description";N;s:24:"shipping_discount_amount";N;s:29:"base_shipping_discount_amount";N;s:17:"subtotal_incl_tax";i:0;s:28:"base_subtotal_total_incl_tax";N;s:17:"hidden_tax_amount";N;s:22:"base_hidden_tax_amount";N;s:26:"shipping_hidden_tax_amount";N;s:29:"base_shipping_hidden_tax_amnt";N;s:17:"shipping_incl_tax";i:0;s:22:"base_shipping_incl_tax";i:0;s:6:"vat_id";N;s:12:"vat_is_valid";N;s:14:"vat_request_id";N;s:16:"vat_request_date";N;s:19:"vat_request_success";N;s:15:"gift_message_id";N;s:24:"should_ignore_validation";b:1;s:16:"extra_tax_amount";i:0;s:21:"base_extra_tax_amount";i:0;s:28:"recurring_initial_fee_amount";i:0;s:33:"base_recurring_initial_fee_amount";i:0;s:16:"cached_items_all";a:0:{}s:20:"cached_items_nominal";a:0:{}s:23:"cached_items_nonnominal";a:0:{}s:30:"recurring_trial_payment_amount";i:0;s:35:"base_recurring_trial_payment_amount";i:0;s:23:"nominal_subtotal_amount";i:0;s:28:"base_nominal_subtotal_amount";i:0;s:9:"total_qty";i:0;s:19:"base_virtual_amount";i:0;s:14:"virtual_amount";i:0;s:22:"base_subtotal_incl_tax";i:0;s:23:"nominal_discount_amount";i:0;s:28:"base_nominal_discount_amount";i:0;s:16:"applied_rule_ids";s:0:"";s:19:"nominal_weee_amount";i:0;s:24:"base_nominal_weee_amount";i:0;s:18:"nominal_tax_amount";i:0;s:23:"base_nominal_tax_amount";i:0;s:11:"msrp_amount";i:0;s:16:"base_msrp_amount";i:0;s:19:"freeshipping_amount";i:0;s:24:"base_freeshipping_amount";i:0;s:11:"weee_amount";i:0;s:16:"base_weee_amount";i:0;s:18:"free_method_weight";i:0;s:19:"tax_shipping_amount";i:0;s:24:"base_tax_shipping_amount";i:0;s:16:"shipping_taxable";i:0;s:21:"base_shipping_taxable";i:0;s:20:"is_shipping_incl_tax";b:0;}
[shipping_address_info] => a:103:{s:10:"address_id";s:3:"146";s:8:"quote_id";s:2:"72";s:10:"created_at";s:19:"2014-06-25 06:03:28";s:10:"updated_at";s:19:"2014-06-25 06:04:38";s:11:"customer_id";s:2:"10";s:20:"save_in_address_book";s:1:"0";s:19:"customer_address_id";N;s:12:"address_type";s:8:"shipping";s:5:"email";s:23:"sukhwantc#ocodewire.com";s:6:"prefix";N;s:9:"firstname";s:4:"test";s:10:"middlename";N;s:8:"lastname";s:4:"test";s:6:"suffix";N;s:7:"company";s:9:"OcodeTest";s:6:"street";s:9:"1 Main St";s:4:"city";s:8:"San Jose";s:6:"region";s:10:"California";s:9:"region_id";s:2:"12";s:8:"postcode";s:5:"95131";s:10:"country_id";s:2:"US";s:9:"telephone";s:10:"9085656554";s:3:"fax";N;s:15:"same_as_billing";s:1:"0";s:13:"free_shipping";i:0;s:22:"collect_shipping_rates";b:1;s:15:"shipping_method";s:17:"flatrate_flatrate";s:20:"shipping_description";s:17:"Flat Rate - Fixed";s:6:"weight";i:0;s:8:"subtotal";i:0;s:13:"base_subtotal";i:0;s:22:"subtotal_with_discount";s:6:"0.0000";s:27:"base_subtotal_with_discount";s:6:"0.0000";s:10:"tax_amount";i:0;s:15:"base_tax_amount";i:0;s:15:"shipping_amount";i:0;s:20:"base_shipping_amount";i:0;s:19:"shipping_tax_amount";i:0;s:24:"base_shipping_tax_amount";i:0;s:15:"discount_amount";i:0;s:20:"base_discount_amount";i:0;s:11:"grand_total";d:0;s:16:"base_grand_total";d:0;s:14:"customer_notes";N;s:13:"applied_taxes";s:6:"a:0:{}";s:20:"discount_description";s:0:"";s:24:"shipping_discount_amount";i:0;s:29:"base_shipping_discount_amount";i:0;s:17:"subtotal_incl_tax";i:0;s:28:"base_subtotal_total_incl_tax";N;s:17:"hidden_tax_amount";i:0;s:22:"base_hidden_tax_amount";i:0;s:26:"shipping_hidden_tax_amount";i:0;s:29:"base_shipping_hidden_tax_amnt";N;s:17:"shipping_incl_tax";i:0;s:22:"base_shipping_incl_tax";i:0;s:6:"vat_id";N;s:12:"vat_is_valid";N;s:14:"vat_request_id";N;s:16:"vat_request_date";N;s:19:"vat_request_success";N;s:15:"gift_message_id";N;s:24:"should_ignore_validation";b:1;s:16:"extra_tax_amount";i:0;s:21:"base_extra_tax_amount";i:0;s:28:"recurring_initial_fee_amount";i:0;s:33:"base_recurring_initial_fee_amount";i:0;s:16:"cached_items_all";a:0:{}s:20:"cached_items_nominal";a:0:{}s:23:"cached_items_nonnominal";a:0:{}s:30:"recurring_trial_payment_amount";i:0;s:35:"base_recurring_trial_payment_amount";i:0;s:23:"nominal_subtotal_amount";i:0;s:28:"base_nominal_subtotal_amount";i:0;s:9:"total_qty";i:0;s:19:"base_virtual_amount";i:0;s:14:"virtual_amount";i:0;s:22:"base_subtotal_incl_tax";i:0;s:15:"rounding_deltas";a:0:{}s:23:"nominal_discount_amount";i:0;s:28:"base_nominal_discount_amount";i:0;s:16:"cart_fixed_rules";a:0:{}s:16:"applied_rule_ids";s:0:"";s:19:"nominal_weee_amount";i:0;s:24:"base_nominal_weee_amount";i:0;s:19:"applied_taxes_reset";b:1;s:18:"nominal_tax_amount";i:0;s:23:"base_nominal_tax_amount";i:0;s:31:"base_shipping_hidden_tax_amount";i:0;s:18:"free_method_weight";i:0;s:8:"item_qty";i:1;s:11:"region_code";s:2:"CA";s:11:"msrp_amount";i:0;s:16:"base_msrp_amount";i:0;s:19:"freeshipping_amount";i:0;s:24:"base_freeshipping_amount";i:0;s:11:"weee_amount";i:0;s:16:"base_weee_amount";i:0;s:19:"tax_shipping_amount";i:0;s:24:"base_tax_shipping_amount";i:0;s:16:"shipping_taxable";i:0;s:21:"base_shipping_taxable";i:0;s:20:"is_shipping_incl_tax";b:0;}
[profile_vendor_info] =>
[additional_info] =>
Now I want to Pick Product id From That array ,How can i Do So?
I've spent some time digging through a few print_r($array) outputs and it is never much fun. Have you tried anything in particular that hasn't worked? Be sure to let us know what you've tried and what you've come up with.
I think I may be able to help you though.
I'm pretty sure that this will get you what you want:
$profiles[order_item_info][product_id]
I had to try this out using the terminal and I had to put the names in quotes like the following or I got a "undefined constant" error for my test values so if that throws an error like that, then try this:
$profiles['order_item_info']['product_id']
I've been away from PHP for a while but I'm pretty sure you can get what you need by digging into this multi-dimensional array.

Query error in code igniter ( wrong escape )

I try to insert a row in the table on code igniter from a Array, but something is going wrong.
That's the array:
Array
(
[Date] => 2001-08-15
[Number] => 962883
[Time] => 17:40
[Etc1] => 0
[Etc2] => 0
)
And this the insert:
$this->db->insert('mytable', $myarray);
A new line is inserted, but all columns are empty!
Trying to find de error, I printed the last query by
echo $this->db->last_query() ." <br>";
And I got:
INSERT INTO `mytable` (`Date`, `Number`, `Time`, `Etc1`, `Etc2`)
VALUES
('\02\00\00\01\0-\00\08\0-\01\05\0', '\09\06\02\08\08\03\0', '\01\07\0:\04\00\0', '\00\0', '\00\0')
For some reason I can not get, the codeigniter ( or PHP ) is wrongly escaping the values.
Any Idea?
Firstly your change your array like this:
$data_array = Array
(
'Date'=> 2001-08-15
'Number' => 962883
'Time' => 17:40
'Etc1' => 0
'Etc2' => 0
);
$this->your_model->insert_data($data_array);
and inside your model write function like this
function insert_data($data=array())
{
$this->db->trans_start();
$this->db->insert('your_table_name',$data);
$this->db->trans_complete();
return TRUE;
}
i hope this will solve your problem
try this , this may help.
$this->db->set('Date', '2001-08-15', FALSE);
$this->db->set('Number', '962883', FALSE);
$this->db->set('Time', '17:40', FALSE);
$this->db->set('Etc1', '0', FALSE);
$this->db->set('Etc2', '0', FALSE);
this->db->insert('mytable');
I tried emulating your problem and was able to get the correct SQL statement genrated.
But I am pasting here the code that worked for me:
$data = array
(
'Date' => '2001-08-15',
'Number' => '962883',
'Time' => '17:40',
'Etc1' => '0',
'Etc2' => '0'
);
$this->db->insert('mytable', $data);
Let me know if this works - and if not, what the error message is.

magento category loop not showing important product information

I am trying to organize the category page by dividing the products into subcategories. When I loop through the subcategories (on catalog\product\list.phtml) with the code:
$child_cat = Mage::getModel('catalog/category')->load($child_id);
$_productCollection = Mage::getResourceModel('catalog/product_collection')->addCategoryFilter($child_cat);
and then proceed to loop through the products...
foreach ($_productCollection as $_product):
It does not seem to differentiate between products that are set to be visible and products that are not (both are shown). It also does not show images, prices, or any other information. The only correct information I get is the product URL.
Why is this happening and how do I fix it?
By default, when you load a product collection you'll get a bare amount of information about the products. Ex:
Array
(
[entity_id] => 9
[entity_type_id] => 4
[attribute_set_id] => 4
[type_id] => simple
[sku] => DLKJFER343
[has_options] => 0
[required_options] => 0
[created_at] => 2012-12-07 16:04:58
[updated_at] => 2012-12-11 16:21:37
[cat_index_position] => 0
[stock_item (Varien_Object)] => Array
(
)
)
You need to explicitly tell Magento to load extra information or to filter by a value like this:
$_productCollection = Mage::getResourceModel( 'catalog/product_collection' );
// Filter by enabled products
$_productCollection->addAttributeToFilter( 'status', 1 );
// Load all product information
$_productCollection->addAttributeToSelect( '*' );
$_productCollection->addCategoryFilter( $category );
Now you'll see something like this (using $_product->debug() to dump out some information):
Array
(
[entity_id] => 3
[entity_type_id] => 4
[attribute_set_id] => 4
[type_id] => simple
[sku] => DLKJFER343
[has_options] => 0
[required_options] => 0
[created_at] => 2012-12-05 18:47:39
[updated_at] => 2012-12-11 16:20:25
[cat_index_position] => 0
[status] => 1
[visibility] => 4
[enable_googlecheckout] => 1
[tax_class_id] => 2
[is_recurring] => 0
[weight] => 3.0000
[price] => 534.2500
[name] => Sample Product
[url_key] => some-product
[is_returnable] => 2
[msrp_enabled] => 2
[msrp_display_actual_price_type] => 4
[image] => /w/r/something.png
[small_image] => /w/r/something_sm.png
[thumbnail] => /w/r/something_th.png
[options_container] => container2
[url_path] => some-product.html
[image_label] => One image label
[small_image_label] => Another image label
[thumbnail_label] => An image label
[description] => Long winded blah, blah, blah.
[short_description] => Blah, blah, blah.
[stock_item (Varien_Object)] => Array
(
)
)
The media gallery information (labels, etc) is a different beast and must be specifically requested through the getMediaGalleryImages() method of the Mage_Catalog_Model_Product object.
HOWEVER this method will return NULL if called while looping through a product collection. Oddly, you cannot access this data without explicitly loading the product model (for reasons I won't go into in this response). So, we need to try something like this:
$product = Mage::getModel( 'catalog/product' )->load( $_product->getId() );
$images = $product->getMediaGalleryImages();
There's a performance hit doing this in your collection loop though, so be careful.
EDIT:
Mage_Catalog_Block_Product->getLoadedProductCollection()
Long, long, long story short (this method digs deep)... as far as I can tell getLoadedProductCollection() will only show attributes which have Used In Product Listing set to Yes.
The reason resides in Mage_Catalog_Model_Resource_Config...
public function getAttributesUsedInListing()
{
// ... some code above omitted...
->where('main_table.entity_type_id = ?', (int)$this->getEntityTypeId())
// THIS RIGHT HERE IS WHY
->where('additional_table.used_in_product_listing = ?', 1);
return $adapter->fetchAll($select);
}

Resources