25.11.2014 Views

Composite Product - Magento

Composite Product - Magento

Composite Product - Magento

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Product</strong> Configura.ons and <br />

<strong>Composite</strong> <strong>Product</strong>s Func.onality <br />

by Andrey Tserkus, <br />

So0ware Engineer, <strong>Magento</strong> 2


Our Session <br />

• Vocabulary <br />

• Implementa.on <br />

• Documenta.on


Vocabulary


Defini.on <br />

“<strong>Composite</strong> <strong>Product</strong>” – any <br />

product with configurable <br />

op.ons


1. Simple <strong>Product</strong> <br />

with custom op.ons


2. Configurable


3. Grouped


4. Downloadable


5. Bundle


6. GiK Card


7. The Most Important <strong>Product</strong>…


7. Your Own <strong>Product</strong>!


Interac.on <br />

? ? <br />

?


1. Add to Shopping Cart


2. Place an Order


3. Put in Wishlist


4. Keep in Recurring Profiles <br />

2011 2012 2013…


5. The Most Important…


5. Your Own Func.onality!


Now we have: <br />

2012 <br />

• Lot of <strong>Composite</strong> <strong>Product</strong>s <br />

• Configura.on travels across whole <br />

system <br />

• Configura.on is stored, reverted, <br />

used at Admin panel


Our Session <br />

• Vocabulary <br />

• Implementa.on <br />

• Documenta.on


Implementa.on


Configura.on Op.ons


Op.on = Varien_Object<br />

Varien_Object <br />

code <br />

value <br />

op.on_1 <br />

John Doe <br />

Varien_Object <br />

code <br />

op.on_2 <br />

value Happy birthday!


Configura.on = key-­‐value collec.on <br />

of op.ons<br />

Configura:on <br />

op.on_1 <br />

code <br />

value <br />

Varien_Object <br />

op.on_1 <br />

John Doe <br />

op.on_2 <br />

code <br />

value <br />

Varien_Object <br />

op.on_2 <br />

Happy birthday! <br />

… <br />


Basic API <br />

• <strong>Product</strong>: getCustomOptions()<br />

• Wishlist, Quote Item, etc: getOptions()<br />

• More – in docs


How is to transfer all that <br />

different en..es around? <br />

We want to…<br />

• put Wishlist item to Shopping Cart <br />

• turn Shopping Cart into an Order <br />

• re-­‐compose and edit an Order <br />

• do not lose product configura.on


$_POST = array( <br />

‘op.on_1’ => ‘John Doe’ <br />

hjp://www <br />

‘op.on_2’ => ‘Happy birthday!’ <br />

POST ) /checkout/ <br />

op.on_1=John Doe <br />

op.on_2=Happy birthday!


One Important Idea <br />

$_POST contains all data with <br />

product configura:on


Serializa.on <br />

array( <br />

) <br />

‘op.on_1’ => ‘John Doe’ <br />

serialize() <br />

‘op.on_2’ => ‘Happy birthday!’ <br />

* Internal name is “buyRequest”


Op.ons Valida.on <br />

? <br />

Valida.on made each .me op.ons are used!


DOs <br />

• Support configura.on in your themes <br />

• Support op.ons parsing in your own <br />

product <br />

• Save your .me – reuse everything. <br />

E.g.: Catalog models and helpers.


DON’Ts <br />

• DON’T assume $buyRequest to be <br />

valid and safe <br />

• DON’T forget to recalculate <br />

everything based on op.ons (product <br />

price, shipping price and availability) <br />

• DON’T skip tes.ng (TAF, <strong>Magento</strong> 2) <br />

• DON’T hack the Core :)


Our Session <br />

• Vocabulary <br />

• Implementa:on <br />

• Documenta.on


Documenta.on


Do you like API reference? <br />

Helper::prepareAndRender() <br />

category_id – id of rendered category <br />

• NULL makes the helper guess the <br />

category on its own <br />

• FALSE tells the helper that there is no <br />

current category


Do you like tales with pictures?


Do you like UML?


Developer’s Guide


The Book <br />

• I have a dream… to provide full <strong>Magento</strong> <br />

developer’s documenta.on <br />

• Our na:ve format – with class schemes, <br />

screenshots, diagrams, etc. <br />

• A non-­‐profit project by <strong>Magento</strong> company


Links <br />

• http://mgn.to/ebook -­‐ free PDF <br />

• http://mgn.to/pbook -­‐ printed book


Our Session <br />

• Vocabulary <br />

• Implementa:on <br />

• Documenta:on


Thanks! <br />

Twijer: @Zerkella <br />

Email: andrey.tserkus@magento.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!