Help for integrating the Laravel package
Forum rules: Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#6031 by mohal_04
13 Apr 2018, 06:35
Hello again,

So, I was making few changes in Stock Section of Product Edit form. So, I have added another field for stock.

207.jpg (23.61 KiB) Viewed 39 times

And want to sum up both stocks using JavaScript. So, I added some code in Vue.js file, i.e. product.js file inside themes directory. Here is the complete path:


It is working fine but I think as it is a custom code, therefore, I should put it under my extension like the path below:


But when I do it, the sum up functionality doesn't work. Below is my modified product.js file code, which I added:

Code: Select allAimeos.Product.Stock = {

   init : function()  {

      this.vstock = new Vue({
         'el': '.item-stock .stock-list',
         'data': {
            'items': $(".item-stock .stock-list").data("items"),
            'keys': $(".item-stock .stock-list").data("keys"),
            'prefix': $(".item-stock .stock-list").data("prefix"),
            'siteid': $(".item-stock .stock-list").data("siteid"),
            'numtypes': $(".item-stock .stock-list").data("numtypes")
         methods: {
            checkSite : function(key, idx) {
               return this.items[key][idx] != this.siteid;

            totalStock : function() {
               var totalStock = 0;
               for(var key in this.items['stock.stocklevel']) {
                     totalStock += parseInt(this.items['stock.stocklevel'][key]);

            addItem : function() {

               var idx = (this.items[this.prefix + 'id'] || []).length;

               for(var key in this.keys) {
                  key = this.keys[key]; this.$set(this.items, key, (this.items[key] || []).concat(['']));

               this.$set(this.items[this.prefix + 'siteid'], idx, this.siteid);

            removeItem : function(idx) {
               for(key in this.items) {
                  this.items[key].splice(idx, 1);

totalStock is the function that I added. Can anyone guide me how to extend Vue.js files?