Tuesday, October 14, 2014

Creating simple Magento product by hand

In a development process, you often will need some testing data you may use. Magento supplies you with default Sample Data containing some products. Thing is, they’re not associated with much use for those who have some custom attributes included in your products, if you create your own personal attribute set, or a item type.


This problem might be easily solved with the addition of products programmatically. I’ll show you a good example on how to add a simple product by doing this. You could adjust this code a bit, and make it benefit other product varieties, or even put it to use as a scan script.

We’re setting the product in ‘Default Values‘ range. You can uncomment the code online 5 to established product data to get a specific store. For example, you could try this. The code over will set distinct meta values.

Just add the past line to the file. Be sure in order to delete it when you’re done developing, though. This will get you a multitude of data you can certainly save. For example pertaining to setting meta_title, you’ll use any magic method setMetaTitle(‘somevalue’). You can find all the values it is possible to set for the product by logging the post data with product save. I’m thinking of saveAction inside the ProductController that receives called from supervision when you’re saving a program.

Sometimes, doing so in the administration is enough, but it gets painful when you wish to add several products, or if you’re nonetheless developing SugarCRM London attribute, and making changes within the fly.

You can call this with an observer, set is to be a controller action, or cheat as well as call it from the view file, whichever you think is better. Just pay awareness, that if anyone observe some event, don’t use people who get called with every magento freelancer motion.
.

No comments:

Post a Comment