<ol> <li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #000088;">$wrapper</span> <span style="color: #339933;">=</span> entity_metadata_wrapper<span style="color: #009900;">(</span><span style="color: #0000ff;">'commerce_product'</span><span style="color: #339933;">,</span> commerce_product_new<span style="color: #009900;">(</span><span style="color: #0000ff;">'product'</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> </div></li> <li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #000088;">$wrapper</span><span style="color: #339933;">-></span><span style="color: #004000;">title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'my title'</span><span style="color: #339933;">;</span> </div></li> <li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #000088;">$wrapper</span><span style="color: #339933;">-></span><span style="color: #004000;">sku</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'my SKU'</span><span style="color: #339933;">;</span> </div></li> <li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #000088;">$wrapper</span><span style="color: #339933;">-></span><span style="color: #004000;">commerce_price</span><span style="color: #339933;">-></span><span style="color: #004000;">amount</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">500</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Price in minors units 500 = 5$</span> </div></li> <li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #000088;">$wrapper</span><span style="color: #339933;">-></span><span style="color: #004000;">commerce_price</span><span style="color: #339933;">-></span><span style="color: #004000;">currency_code</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'USD'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Use your currency... obviously :-)</span> </div></li> <li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> </div></li> <li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;">// You can assign other fields with the same construction: $wrapper->field_name = ...</span></div></li> <li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> </div></li> <li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #000088;">$wrapper</span><span style="color: #339933;">-></span><span style="color: #004000;">save</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> </div></li> </ol>
Источник:
ссылка в комментарии на xandeadx.ru: http://dropbucket.org/node/288 (веб архив)