gl636474 / NaturesCupboard2

0 stars 0 forks source link

Add export cost sheet feature to the "Manage Products" page #17

Closed gl636474 closed 5 years ago

gl636474 commented 5 years ago

Export a CSV spreadsheet with the following columns:

  1. Product Name
  2. Selling price per unit
  3. Cost Price per unit
  4. Margin (£)
  5. Margin (%)

Exported file called "costs_andmargins"

gl636474 commented 5 years ago

The margins (£s & %s) also need to be on the product admin page, not visible on frontend.

gl636474 commented 5 years ago

Add them as proper attributes and have an observer to calculate their values (watch for zeros) on product save. See:

https://www.google.com/url?sa=t&source=web&rct=j&url=https://stackoverflow.com/questions/9233019/magento-calculated-product-attribute-property&ved=2ahUKEwiK2O3Rot3iAhUqUBUIHXLOBM8QFjAAegQIAxAB&usg=AOvVaw1YM7yBMg-3EI12FcVimOtm&cshid=1560113290793

Also add an observer ensure these attributes are locked on product edit (the edit product GET request) so admin cannot change them. See:

https://www.google.com/url?sa=t&source=web&rct=j&url=https://stackoverflow.com/questions/6384120/magento-read-only-and-hidden-product-attributes&ved=2ahUKEwig49rYo93iAhVjpHEKHUUdBpwQFjACegQIBhAB&usg=AOvVaw1IMhly49zKLjCeS2ojN8f-&cshid=1560113598088

gl636474 commented 5 years ago

Code added in working tree on Mac mini, need to test.

gl636474 commented 5 years ago

Just need to test bulk import - margins and categories and then create bulk upload spreadsheet to add cost price to each product.

gl636474 commented 5 years ago

Bulk imports no longer work. Need to implement import_save_before on Margins and Categories observers. See this link for fast model saving: https://magento.stackexchange.com/questions/63764/set-product-category-without-loading-the-whole-product-model/64391 Presumably gets can be done the same way. If not: https://magento.stackexchange.com/questions/56301/how-to-get-product-category-ids-without-loading-the-whole-product

gl636474 commented 5 years ago

And for fast saving attributes: https://magento.stackexchange.com/questions/67242/set-product-attribute-without-loading-full-product