Exemple : l’objet $item
est appelé dans le template summary.phtml.
Ce tableau stocke et permet d’afficher tout un ensemble d’informations sur un produit ajouté au panier.
1 |
<?php foreach($this->getItems() as $item): ?> |
Pour afficher les propriétés de l’objet $item
:
1 |
<?php print_r($item->toArray()); exit(); ?> |
Résultat en front :
Array
(
[item_id] => 70
[quote_id] => 51
[created_at] => 2015-01-30 09:08:42
[updated_at] => 2015-01-30 09:08:42
[product_id] => 2
[store_id] => 1
[parent_item_id] =>
[is_virtual] => 0
[sku] => test_b_produit
[name] => testB
[description] =>
[applied_rule_ids] =>
[additional_data] =>
[free_shipping] =>
[is_qty_decimal] => 0
[no_discount] => 0
[weight] => 10.0000
[qty] => 1
[price] => 8
[base_price] => 8
[custom_price] =>
[discount_percent] => 0
[discount_amount] => 0
[base_discount_amount] => 0
[tax_percent] => 0
[tax_amount] => 0
[base_tax_amount] => 0
[row_total] => 8
[base_row_total] => 8
[row_total_with_discount] => 0.0000
[row_weight] => 10
[product_type] => simple
[base_tax_before_discount] =>
[tax_before_discount] =>
[original_custom_price] =>
[redirect_url] =>
[base_cost] =>
[price_incl_tax] => 8
[base_price_incl_tax] => 8
[row_total_incl_tax] => 8
[base_row_total_incl_tax] => 8
[hidden_tax_amount] => 0
[base_hidden_tax_amount] => 0
[gift_message_id] =>
[weee_tax_disposition] => 0
[weee_tax_row_disposition] => 0
[base_weee_tax_disposition] => 0
[base_weee_tax_row_disposition] => 0
[weee_tax_applied] => a:0:{}
[weee_tax_applied_amount] => 0
[weee_tax_applied_row_amount] => 0
[base_weee_tax_applied_amount] => 0
[base_weee_tax_applied_row_amnt] =>
[stock_id] => 1
[image_url] =>
[image] => /c/h/charlotte-pirroni-miss-cote-dazur.jpg
[qty_options] => Array
(
)[product] => Array
(
[entity_id] => 2
[entity_type_id] => 4
[attribute_set_id] => 4
[type_id] => simple
[sku] => test_b_produit
[has_options] => 0
[required_options] => 0
[created_at] => 2014-11-24 13:36:52
[updated_at] => 2014-12-10 15:07:46
[name] => testB
[image] => /c/h/charlotte-pirroni-miss-cote-dazur.jpg
[small_image] => /c/h/charlotte-pirroni-miss-cote-dazur.jpg
[thumbnail] => /c/h/charlotte-pirroni-miss-cote-dazur.jpg
[url_key] => testb
[url_path] => testb.html
[msrp_enabled] => 2
[msrp_display_actual_price_type] => 4
[gift_message_available] =>
[status] => 1
[visibility] => 4
[tax_class_id] => 0
[is_recurring] => 0
[weight] => 10.0000
[price] => 8.0000
[special_price] =>
[msrp] =>
[special_from_date] =>
[special_to_date] =>
[batch_prices] => Array
(
)[website_batch_prices] => Array
(
)[initial_price] => 8.0000
[final_price] =>
[batch_special_prices] => Array
(
)[website_batch_special_prices] => Array
(
)[initial_special_price] =>
[is_salable] => 1
[stock_item] => Array
(
[item_id] => 2
[product_id] => 2
[stock_id] => 1
[qty] => 19.0000
[min_qty] => 0.0000
[use_config_min_qty] => 1
[is_qty_decimal] => 0
[backorders] => 0
[use_config_backorders] => 1
[min_sale_qty] => 1.0000
[use_config_min_sale_qty] => 1
[max_sale_qty] => 0.0000
[use_config_max_sale_qty] => 1
[is_in_stock] => 1
[low_stock_date] =>
[notify_stock_qty] =>
[use_config_notify_stock_qty] => 1
[manage_stock] => 0
[use_config_manage_stock] => 1
[stock_status_changed_auto] => 0
[use_config_qty_increments] => 1
[qty_increments] => 0.0000
[use_config_enable_qty_inc] => 1
[enable_qty_increments] => 0
[is_decimal_divided] => 0
[type_id] => simple
[stock_status_changed_automatically] => 0
[use_config_enable_qty_increments] => 1
[product_name] => testB
[store_id] => 1
[product_type_id] => simple
[product_status_changed] => 1
[product_changed_websites] =>
[ordered_items] => 1
)[stock_tax_class_ids] => Array
(
)[do_not_use_category_id] => 1
[request_path] => testb.html
[tier_prices] => Array
(
)[tier_price] => Array
(
)[is_in_stock] => 1
[store_id] => 1
[customer_group_id] => 0
[group_price] => Array
(
)[group_price_changed] => 0
)[tax_class_id] => 0
[is_recurring] => 0
[has_error] =>
[calculation_price] => 8
[original_price] => 8
[is_nominal] =>
[base_calculation_price] => 8
[converted_price] => 8
[base_original_price] => 8
[taxable_amount] => 8
[base_taxable_amount] => 8
[is_price_incl_tax] =>
[base_weee_tax_applied_row_amount] => 0
[discount_tax_compensation] => 0
)
Admettons qu’on souhaite afficher la propriété [sku]
de l’objet $item
:
1 |
<p>sku: <?php echo $item->getData('sku'); ?></p> |
Admettons qu’on souhaite afficher la propriété [created_at]
de l’objet $item
:
1 |
<p>created at: <?php echo $item->getData('created_at'); ?></p> |
Autre méthode possible :
1 |
<p>sku: <?php echo $item->getSku(); ?></p> |
1 |
<p>created at: <?php echo $item->getCreatedAt(); ?></p> |