Question

Comment accéder le prix dans l'un des produits simples? Ce qui suit est le début du tableau que je veux de mon accès var_dump ($ _ product-> debug ()); (Stackoverflow ne me laisserait pas poster tout ça). Je travaille sur la question relative à ce poste: https: // stackoverflow .com / questions / 16703427 / magento-récupération-simple-produit-prix-pour-configurable produit

["_cache_instance_products"]=>
  array(9) {
    ["0 (Mage_Catalog_Model_Product)"]=>
    array(33) {
      ["entity_id"]=>
      string(2) "69"
      ["entity_type_id"]=>
      string(1) "4"
      ["attribute_set_id"]=>
      string(2) "10"
      ["type_id"]=>
      string(6) "simple"
      ["sku"]=>
      string(13) "1001-blu-ven1"
      ["has_options"]=>
      string(1) "0"
      ["required_options"]=>
      string(1) "0"
      ["created_at"]=>
      string(19) "2013-04-02 22:12:27"
      ["updated_at"]=>
      string(19) "2013-04-02 23:54:41"
      ["parent_id"]=>
      string(2) "78"
      ["color"]=>
      string(1) "6"
      ["vendor"]=>
      string(1) "5"
      ["name"]=>
      string(14) "test_1 blue v1"
      ["url_key"]=>
      string(14) "test-1-blue-v1"
      ["msrp_enabled"]=>
      string(1) "2"
      ["msrp_display_actual_price_type"]=>
      string(1) "4"
      ["image"]=>
      string(12) "no_selection"
      ["small_image"]=>
      string(12) "no_selection"
      ["thumbnail"]=>
      string(12) "no_selection"
      ["options_container"]=>
      string(10) "container2"
      ["url_path"]=>
      string(19) "test-1-blue-v1.html"
      ["weight"]=>
      string(6) "0.0000"
      ["price"]=>
      string(6) "1.0000"
      ["status"]=>
      string(1) "1"
      ["visibility"]=>
      string(1) "1"
      ["enable_googlecheckout"]=>
      string(1) "1"
      ["tax_class_id"]=>
      string(1) "0"
      ["is_recurring"]=>
      string(1) "0"
      ["description"]=>
      string(19) "test_1 blue v1 desc"
      ["short_description"]=>
      string(19) "test_1 blue v1 desc"
Était-ce utile?

La solution

Dans votre sortie getData ci-dessus, il est là, avec un prix de 1,00 $:

["price"]=>
      string(6) "1.0000"

Pour y accéder, l'utilisation $_product->getPrice()

Modifier

Alors que je ne suis pas tout à fait, nous espérons que cela aide - pour obtenir tous d'un produit simples parent configurable, utilisez les touches suivantes:

$childProducts = Mage::getModel('catalog/product_type_configurable')
                    ->getUsedProducts(null,$_product);   
foreach($childProducts as $child) {
    print_r($child->getPrice());
}

Dans votre cas, il semble que $ _Product peut contenir cette collection simple, dans ce cas, il peut être mal nommé. Si que est ce cas, je suggère itérer avec un foreach:

foreach($_product as $_child){
  print_r($_child->getPrice());
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top