CHANGE-293 #75 editing product, Product Qty Units 

While editing product, Product Qty Units displays as 1 if it is 0 on the database #75
Fix Unit, Min and fix copy from and copy to products
<a href='#crh-start'></a><a href='#crh-data-%7B%22processed%22%3A%20%5B%22https%3A//github.com/zencart/zc-v1-series/pull/77%23issuecomment-48560000%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/77%23discussion_r14787659%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/77%23discussion_r14787753%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/77%23discussion_r14787754%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/77%23discussion_r14787760%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/77%23issuecomment-48653331%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/77%23issuecomment-48801312%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/77%23issuecomment-48801334%22%5D%2C%20%22comments%22%3A%20%7B%22General%20Comment%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/zencart/zc-v1-series/pull/77%23issuecomment-48560000%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222014-07-10T02%3A52%3A56Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/227354%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/zcwilt%22%7D%7D%2C%20%7B%22body%22%3A%20%22There%27s%20a%20lot%20of%20code%20duplication%20here.%20%20Needs%20to%20be%20DRY%27d%20up%20%28maybe%20in%20another%20ticket%29.%22%2C%20%22created_at%22%3A%20%222014-07-10T19%3A37%3A07Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1590605%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/texdc%22%7D%7D%2C%20%7B%22body%22%3A%20%22Thanks%20for%20the%20comment%2C%5Cr%5CnHowever%20your%20example%20isn%27t%20correct%20in%20this%20context.%5Cr%5Cn%5Cr%5Cnzen_db_input%28%24product-%3Efields%5B%27products_quantity_order_min%27%5D%20%3F%3A%201%29%3B%5Cr%5Cnexpands%20to%20%5Cr%5Cnzen_db_input%28%24product-%3Efields%5B%27products_quantity_order_min%27%5D%20%3F%20%24product-%3Efields%5B%27products_quantity_order_min%27%5D%20%3A%201%29%3B%5Cr%5Cnwhich%20wouldn%27t%20match%20the%20intent%20of%20the%20original%20change.%5Cr%5Cn%5Cr%5CnAs%20for%20code%20duplication%2C%20agreed%20it%27s%20there%2C%20however%20the%20intent%20of%20v160%20is%20not%20to%20be%20a%20complete%20wholesale%20rewrite%20of%20code.%20Ajeh%27s%20commit%20here%20is%20a%20bugfix.%5Cr%5CnThe%20core%20team%20currently%20has%20enough%20to%20do.%20%5Cr%5CnIf%20someone%20else%20wants%20to%20tackle%20removing%20the%20duplication%2C%20that%20involves%20completely%20rewriting%20the%20entire%20product-type%20infrastructure%20%28which%20affects%20way%20more%20than%20just%20these%20few%20admin%20files%29.%20In%20which%20case%2C%20feel%20free%2C%20create%20an%20issue%20ticket%20and%20do%20a%20PR.%22%2C%20%22created_at%22%3A%20%222014-07-12T03%3A38%3A33Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/227354%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/zcwilt%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222014-07-12T03%3A39%3A49Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/404472%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/drbyte%22%7D%7D%5D%2C%20%22title%22%3A%20%22General%20Comment%22%7D%2C%20%22Pull%201d1868b0145ff9599b911dd33d75c1e70b82a354%20admin/includes/modules/product_music/copy_to_confirm.php%2025%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/zencart/zc-v1-series/pull/77%23discussion_r14787753%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22See%20above%20comment.%5Cr%5Cn%60%60%60php%5Cr%5Cnzen_db_input%28%24product-%3Efields%5B%27products_quantity_order_min%27%5D%20%3F%3A%201%29%3B%5Cr%5Cnzen_db_input%28%24product-%3Efields%5B%27products_quantity_order_units%27%5D%20%3F%3A%201%29%3B%5Cr%5Cn%60%60%60%22%2C%20%22created_at%22%3A%20%222014-07-10T19%3A35%3A27Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1590605%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/texdc%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20admin/includes/modules/product_music/copy_to_confirm.php%3AL83-91%22%7D%2C%20%22Pull%201d1868b0145ff9599b911dd33d75c1e70b82a354%20admin/includes/modules/product_music/update_product.php%207%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/zencart/zc-v1-series/pull/77%23discussion_r14787754%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Again%2C%5Cr%5Cn%60%60%60php%5Cr%5Cnzen_db_prepare_input%28%24_POST%5B%27products_quantity_order_min%27%5D%20%3F%3A%201%29%3B%5Cr%5Cnzen_db_prepare_input%28%24_POST%5B%27products_quantity_order_units%27%5D%20%3F%3A%201%29%3B%5Cr%5Cn%60%60%60%22%2C%20%22created_at%22%3A%20%222014-07-10T19%3A35%3A30Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1590605%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/texdc%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20admin/includes/modules/product_music/update_product.php%3AL37-45%22%7D%2C%20%22Pull%201d1868b0145ff9599b911dd33d75c1e70b82a354%20admin/includes/modules/update_product.php%207%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/zencart/zc-v1-series/pull/77%23discussion_r14787760%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22And%20again%2C%5Cr%5CnAgain%2C%5Cr%5Cn%60%60%60php%5Cr%5Cnzen_db_prepare_input%28%24_POST%5B%27products_quantity_order_min%27%5D%20%3F%3A%201%29%3B%5Cr%5Cnzen_db_prepare_input%28%24_POST%5B%27products_quantity_order_units%27%5D%20%3F%3A%201%29%3B%5Cr%5Cn%60%60%60%22%2C%20%22created_at%22%3A%20%222014-07-10T19%3A35%3A32Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1590605%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/texdc%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20admin/includes/modules/update_product.php%3AL35-43%22%7D%2C%20%22Pull%201d1868b0145ff9599b911dd33d75c1e70b82a354%20admin/includes/modules/copy_to_confirm.php%2025%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/zencart/zc-v1-series/pull/77%23discussion_r14787659%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22There%27s%20a%20shorter%20syntax%20for%20these%20lines%3A%5Cr%5Cn%60%60%60php%5Cr%5Cnzen_db_input%28%24product-%3Efields%5B%27products_quantity_order_min%27%5D%20%3F%3A%201%29%3B%5Cr%5Cnzen_db_input%28%24product-%3Efields%5B%27products_quantity_order_units%27%5D%20%3F%3A%201%29%3B%5Cr%5Cn%60%60%60%22%2C%20%22created_at%22%3A%20%222014-07-10T19%3A33%3A32Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1590605%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/texdc%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20admin/includes/modules/copy_to_confirm.php%3AL83-91%22%7D%7D%7D'></a>
<a href='https://www.codereviewhub.com/'><img src='http://www.codereviewhub.com/site/github-bar.png' height=40></a>
- [ ] <a href='#crh-comment-Pull 1d1868b0145ff9599b911dd33d75c1e70b82a354 admin/includes/modules/copy_to_confirm.php 25'></a> <img src='http://www.codereviewhub.com/site/github-remaining.png' height=16 width=60>&nbsp;<b><a href='https://github.com/zencart/zc-v1-series/pull/77#discussion_r14787659'>File: admin/includes/modules/copy_to_confirm.php:L83-91</a></b>
- <a href='https://github.com/texdc'><img border=0 src='https://avatars.githubusercontent.com/u/1590605?size=16' height=16 width=16'></a> There's a shorter syntax for these lines:
```php
zen_db_input($product->fields['products_quantity_order_min'] ?: 1);
zen_db_input($product->fields['products_quantity_order_units'] ?: 1);
```
- [ ] <a href='#crh-comment-Pull 1d1868b0145ff9599b911dd33d75c1e70b82a354 admin/includes/modules/product_music/copy_to_confirm.php 25'></a> <img src='http://www.codereviewhub.com/site/github-remaining.png' height=16 width=60>&nbsp;<b><a href='https://github.com/zencart/zc-v1-series/pull/77#discussion_r14787753'>File: admin/includes/modules/product_music/copy_to_confirm.php:L83-91</a></b>
- <a href='https://github.com/texdc'><img border=0 src='https://avatars.githubusercontent.com/u/1590605?size=16' height=16 width=16'></a> See above comment.
```php
zen_db_input($product->fields['products_quantity_order_min'] ?: 1);
zen_db_input($product->fields['products_quantity_order_units'] ?: 1);
```
- [ ] <a href='#crh-comment-Pull 1d1868b0145ff9599b911dd33d75c1e70b82a354 admin/includes/modules/product_music/update_product.php 7'></a> <img src='http://www.codereviewhub.com/site/github-remaining.png' height=16 width=60>&nbsp;<b><a href='https://github.com/zencart/zc-v1-series/pull/77#discussion_r14787754'>File: admin/includes/modules/product_music/update_product.php:L37-45</a></b>
- <a href='https://github.com/texdc'><img border=0 src='https://avatars.githubusercontent.com/u/1590605?size=16' height=16 width=16'></a> Again,
```php
zen_db_prepare_input($_POST['products_quantity_order_min'] ?: 1);
zen_db_prepare_input($_POST['products_quantity_order_units'] ?: 1);
```
- [ ] <a href='#crh-comment-Pull 1d1868b0145ff9599b911dd33d75c1e70b82a354 admin/includes/modules/update_product.php 7'></a> <img src='http://www.codereviewhub.com/site/github-remaining.png' height=16 width=60>&nbsp;<b><a href='https://github.com/zencart/zc-v1-series/pull/77#discussion_r14787760'>File: admin/includes/modules/update_product.php:L35-43</a></b>
- <a href='https://github.com/texdc'><img border=0 src='https://avatars.githubusercontent.com/u/1590605?size=16' height=16 width=16'></a> And again,
Again,
```php
zen_db_prepare_input($_POST['products_quantity_order_min'] ?: 1);
zen_db_prepare_input($_POST['products_quantity_order_units'] ?: 1);
```
- [x] <a href='#crh-comment-General Comment'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/zencart/zc-v1-series/pull/77#issuecomment-48560000'>General Comment</a></b>
- <a href='https://github.com/zcwilt'><img border=0 src='https://avatars.githubusercontent.com/u/227354?size=16' height=16 width=16'></a> :+1:
- <a href='https://github.com/texdc'><img border=0 src='https://avatars.githubusercontent.com/u/1590605?size=16' height=16 width=16'></a> There's a lot of code duplication here.  Needs to be DRY'd up (maybe in another ticket).
- <a href='https://github.com/zcwilt'><img border=0 src='https://avatars.githubusercontent.com/u/227354?size=16' height=16 width=16'></a> Thanks for the comment,
However your example isn't correct in this context.
zen_db_input($product->fields['products_quantity_order_min'] ?: 1);
expands to
zen_db_input($product->fields['products_quantity_order_min'] ? $product->fields['products_quantity_order_min'] : 1);
which wouldn't match the intent of the original change.
As for code duplication, agreed it's there, however the intent of v160 is not to be a complete wholesale rewrite of code. Ajeh's commit here is a bugfix.
The core team currently has enough to do.
If someone else wants to tackle removing the duplication, that involves completely rewriting the entire product-type infrastructure (which affects way more than just these few admin files). In which case, feel free, create an issue ticket and do a PR.


<a href='https://www.codereviewhub.com/zencart/zc-v1-series/pull/77?mark_as_completed=1'><img src='http://www.codereviewhub.com/site/github-mark-as-completed.png' height=26></a>&nbsp;<a href='https://www.codereviewhub.com/zencart/zc-v1-series/pull/77?approve=1'><img src='http://www.codereviewhub.com/site/github-approve.png' height=26></a>&nbsp;<a href='https://github.com/zencart/zc-v1-series/pull/77'><img src='http://www.codereviewhub.com/site/github-refresh.png' height=26></a>
<a href='#crh-end'></a>