Creating product catalog Proof-Of-Concept through Angular

176 views
Skip to first unread message

Kasper Hansen

unread,
Nov 10, 2014, 8:33:38 AM11/10/14
to ang...@googlegroups.com
I started playing around with Angular for little under a month ago, normally I work in the PHP world with Magento etc. However, I've decided to try and remove some of the heavy backend, and create my own, through an angular setup (kind of ERP like)

My first target has been to be able to manage products, attributes and alike through Angular. So far I've gotten part of the way. I've generated a list with valuable info where you can specify your way down to a single product.
I've also made a product edit page, and an attribute edit / create page.

Functionalities on these pages includes adding more colors, changing the type of attribute, or changing the full attribute functionality for all products.

The proejct Im connecting this up against, is fairly simple as it has a very flat product base, which makes it very easy to work with.

Now, to maintain all this data, I have a few Json files I use to maintain it all with.

Json 1: Product data, all the product data listed from a CSV > JSON conversion (Products come as a CSV pr standard from Magento) this is very flat data with each product being a single object.
Json 2: Attributes data, this is a fully customized JSON, based around how the data in Magento works, but this will be left purely for the system, and never overwritten by Magento nor imported into it.

the product page is used to build the product listing.
the Attributes json is used to build the edit product page, and the edit attribute page.

I've now run into several "minor" issues though, which has halted my progression.

I've attempted several times to get my save function used for edit products to point towards the correct page - sadly without success. this has left me in a state of questioning how I do this correctly.
Currently, if I try to save my data, it will go in my attribute list, as far as I can gather, it must be because Im using this to run through and set the variabels? I'm not certain.

Secondly, my data doesnt seem to save to the json files on a push, this may be a pure local issue, as I haven't tried moving this to a dev server yet.

Once my save data is working, I'll gladly give a few examples of how the system works in a very early prototype.

Sander Elias

unread,
Nov 10, 2014, 10:32:11 AM11/10/14
to ang...@googlegroups.com
Hi Kasper,

You need to handle the saving part on the server side. Angular is pure front-end. 
Can you show me the code you use to send the data back to the server, perhaps I can then help you.

Regards
Sander

Kasper Hansen

unread,
Nov 11, 2014, 4:13:30 AM11/11/14
to ang...@googlegroups.com
$scope.save = function() {
    $http({
    method: 'POST',
    header: {'Content-Type': 'application/x-www-form-urlencoded'},
    url: './assets/json/attributes.json',
    data: $scope.attr,

    })

Should I not be able to push data into a JSON file? Granted, I cannot create a new file, but updating data in an existing one, is not possible either?

Kasper Hansen

unread,
Nov 11, 2014, 4:48:43 AM11/11/14
to ang...@googlegroups.com
The data posted this way around seems (mostly) correct. I just need to figure out how to edit the JSON files.

I'll probably end up having to do a PHP backend, to match up on top of the current Magento install, run a few ajax calls to php docs and make them do the saving of the data. This would also allow me to do direct integration into Magento, on a push notification from the system.

I do need to find out how to get my scope to inherit the "inside" scope though, as I have an options scope building input fields for changing values of dropdowns inside the code.

label(ng-repeat="Options in att.type.options")
input(type="hidden" ng-value="$index+1")
input(ng-value="Options.value")

the plan is to be able to add/remove these fields, and store this info in the JSON file together with the original pull, but it doesn't seem to be included.

Kasper Hansen

unread,
Nov 11, 2014, 7:44:48 AM11/11/14
to ang...@googlegroups.com
I got the options to work now, so they get introduced correctly into my JSON output.

Sander Elias

unread,
Nov 11, 2014, 8:10:35 AM11/11/14
to ang...@googlegroups.com
Hi Kasper,

I'm glad to hear you are finding your way in Angular.

Regards
Sander
Reply all
Reply to author
Forward
0 new messages