These are chat archives for reactioncommerce/reaction

31st
May 2016
Brent Hoover
@zenweasel
May 31 2016 00:34
@rwatts3 Yes. Almost the entire API is available through Meteor methods which can be called from an external app
Valery Orloff
@valorloff
May 31 2016 05:42
@aaronjudd
Error: Access Denied [403]
at [object Object].inventoryRegister (packages/reactioncommerce:reaction-inventory/server/methods.js:25:13)
in this code condition !ReactionCore.hasPermission("createProduct") return TRUE in REST mode call method ReactionCore.Collections.Products.insert,
how to get around this check in REST mode?
Interestingly, this check only throws error if the product type is an 'variant',
and error throws after the variant was added)
Valery Orloff
@valorloff
May 31 2016 05:55
solved )
by comment if (!ReactionCore.hasPermission("createProduct")) {
guys, how do you put chunks of code here?
Brent Hoover
@zenweasel
May 31 2016 06:01
Use three backticks before and after code
Valery Orloff
@valorloff
May 31 2016 06:40
This message was deleted
Brent Hoover
@zenweasel
May 31 2016 06:41
The backtick is the character to the left of the 1
Valery Orloff
@valorloff
May 31 2016 06:43
found it, thanks @zenweasel
Brent Hoover
@zenweasel
May 31 2016 06:43
:+1:
krestt
@krestt
May 31 2016 07:17
There is product collections a field named SKU But i dont see anywhere where i can set its value from admin panel
Is it not implemented yet?
Brent Hoover
@zenweasel
May 31 2016 07:18
Yeah, it’s true. It’s left off there.
krestt
@krestt
May 31 2016 07:26
Can you explain please this line of code? const { Log } = ReactionCore; What are the "curly brackets" are for?
Brent Hoover
@zenweasel
May 31 2016 07:27
that’s object expansion in ES6
krestt
@krestt
May 31 2016 07:27
Thank you.
Brent Hoover
@zenweasel
May 31 2016 07:28
instead of saying Log = ReactionCore.Log you can just use that. You can also do { this, that, theother } = AnObject
Owen Hoskins
@owenhoskins
May 31 2016 08:04
@zenweasel Hello there. I am testing the fixture part of you your Reaction customization guide and am running into an error importing my data: Error while importing to Shops: insertDocument :: caused by :: 11000 E11000 duplicate key error index: meteor.Shops.$_id_ dup key: { : "J8Bhq3uTtdgwZx3rz" }
Brent Hoover
@zenweasel
May 31 2016 08:05
Do you have both reaction-sampledata and a new package installed?
Owen Hoskins
@owenhoskins
May 31 2016 08:06
(just trying a ./reaction reset)
but I've removed reaction-sampledata and have a custom package per the tutorial
Brent Hoover
@zenweasel
May 31 2016 08:07
Hmmm, I don’t know
Did you create your own fixtures?
Owen Hoskins
@owenhoskins
May 31 2016 08:08
Yep, private/data/Shops.json etc.
within the custom package
Brent Hoover
@zenweasel
May 31 2016 08:08
because that key is the one that’s in reaction-sampledata
Owen Hoskins
@owenhoskins
May 31 2016 08:09
True. I exported my fixture data which had been added using the sample shop.
So that error was a little misleading because I hand't reset this time around.
Modified 1 document while importing 1 to Shops

/Users/owenhoskins/.meteor/packages/meteor-tool/.1.3.2_4.xb8iu1++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:267
                        throw(ex);
                              ^
Error: Couldn't determine the schema associated with this document
    at Function.ReactionImport.identify (packages/reactioncommerce:core/server/import.js:101:9)
    at Function.ReactionImport.load (packages/reactioncommerce:core/server/import.js:39:20)
    at Function.ReactionImport.process
=> Exited with code: 8
Brent Hoover
@zenweasel
May 31 2016 08:12
Hmmm, that’s a new one
I would need to debug it to see what’s going on
Owen Hoskins
@owenhoskins
May 31 2016 08:13
Wouldn't know where to start looking into that one myself.
On running ./reaction reset-- what is that bit about Also delete modules?
Brent Hoover
@zenweasel
May 31 2016 08:16
that’s for removing the reinstalling all dependencies
you normally you don’t need to do that
Owen Hoskins
@owenhoskins
May 31 2016 08:16
Running some npm commands I suppose.
Brent Hoover
@zenweasel
May 31 2016 08:17
Actually just running some bash scripts to delete node_modules etc.
Owen Hoskins
@owenhoskins
May 31 2016 08:17
Ah right, that makes sense.
While I have your ear -- is RC running on DigitalOcean?
Brent Hoover
@zenweasel
May 31 2016 08:18
I am pretty sure Get Outfitted is running on Digital Ocean
Owen Hoskins
@owenhoskins
May 31 2016 08:19
Might you know if the DO Ubuntu instance has presistant file storage?
Brent Hoover
@zenweasel
May 31 2016 08:19
Sorry, I don't
Owen Hoskins
@owenhoskins
May 31 2016 08:20
Np! I'll continue to investigate.
So I found the culprit to the import error. I had created an additional schema and was importing a "Posts.json"
Brent Hoover
@zenweasel
May 31 2016 08:21
Oh, great.
Owen Hoskins
@owenhoskins
May 31 2016 08:21
Removed that and all ran as expected. Any idea how I would import data with a custom schema?
Brent Hoover
@zenweasel
May 31 2016 08:23
Sure, if you were adding your custom data, something that’s not part of stock Reaction. Or maybe you have overridden the stock-Reaction schemas for products
Owen Hoskins
@owenhoskins
May 31 2016 08:24
Both, but most importantly non-stock RC.
Brent Hoover
@zenweasel
May 31 2016 08:24
Yeah, probably most non-trivial customizations will need to modify the schema somewhat
Sorry, I misread your question
You would need to look at ReactionImport.indication so that the auto-detection can figure out what schema you want
Did you look at that already?
Owen Hoskins
@owenhoskins
May 31 2016 08:28
Looking now, had thought it might be in ReactionImport.identify
The indication is specified in ReactionImport.fixture().process(Assets.getText("private/data/Products.json"), ["title"], ReactionImport.load); as title?
Brent Hoover
@zenweasel
May 31 2016 08:29
Honestly I am not 100% sure how that auto-detection works
Owen Hoskins
@owenhoskins
May 31 2016 08:30
there is also the bit at the end of import.js with a list of stuff like ReactionImport.indication("i18n", ReactionCore.Collections.Translations, 0.2);
me either heh...
Brent Hoover
@zenweasel
May 31 2016 08:31
I think it just says “if it has this field, it’s this collection"
Owen Hoskins
@owenhoskins
May 31 2016 08:32
Ok, I'll see if I can verify that. Otherwise, who could I follow up on this with?
Brent Hoover
@zenweasel
May 31 2016 08:33
"Allow packages to extend the auto collection detection facility of ReactionImport. It is used to add a certain field as an indication that the document belongs to a certain collection."
Aaron may know more (he usually does). Or if Tom is around, he wrote that part
Owen Hoskins
@owenhoskins
May 31 2016 08:35
Thanks. Now checking those Import docs you just referenced. (wise place to start haha)
Brent Hoover
@zenweasel
May 31 2016 08:36
Yeah, they aren’t super verbose but it’s something
Let me know how it goes. If we can get it figured out I will add it to the docs
Owen Hoskins
@owenhoskins
May 31 2016 08:37
Will do, I think it would be an apt inclusion. Appreciate the support!
I am also interested in how to preserve images that have been uploaded through a reset.
Owen Hoskins
@owenhoskins
May 31 2016 08:48
I've just PMd @tdecaluwe regarding this, will report back on any insights.
Brent Hoover
@zenweasel
May 31 2016 09:12
re: images I have an example I can show to you, but it’s not my code, it’s @prinzdezibel, if I can get his okay I can show you because we are doing that on his project
Owen Hoskins
@owenhoskins
May 31 2016 09:13
That'd be great. Please do!
Michael Jenny
@prinzdezibel
May 31 2016 10:09
@zenweasel @owenhoskins. sure. NP
Brent Hoover
@zenweasel
May 31 2016 10:15
function importProductImages() {
  let productsJson = Assets.getText("private/data/Products.json");
  let products = EJSON.parse(productsJson);
  for (let product of products) {
      let productId = product._id;
      if (!ReactionCore.Collections.Media.findOne({"metadata.productId": productId})) {
        let shopId = product.shopId;
        let handle = product.handle;
        if (!handle) continue; // Probably a variant..
        //let variantId = product.variants[0]._id;
        const pass = {standard: true, small: true};
        for (let item in pass) {
          let filepath;
          if (item === "standard"){
            filepath = "private/images/standard/" + handle + ".png";
          } else if (item == "small") {
            filepath = "private/images/small/" + handle + "_sm.png";
          }
          let binary = Assets.getBinary(filepath);
          let fileObj = new FS.File();
          fileObj.attachData(binary, {type: "image/png"});
          fileObj.metadata = {
 //         ownerId: userId,
            productId: productId,
//          variantId: variantId,
            landing: item === "standard" ? false : true,
            toGrid: 1,
            shopId: shopId,
            priority: 0
          };
          ReactionCore.Collections.Media.insert(fileObj);
        }
      }
    }
}
that’s Micheal’s code there, and he just runs that function after the imports are done
Owen Hoskins
@owenhoskins
May 31 2016 10:18
@prinzdezibel @zenweasel Thank you both! You run it inReactionCore.Hooks.Events.add("onCoreInit")... or elsewhere?
Brent Hoover
@zenweasel
May 31 2016 10:19
Yes
Owen Hoskins
@owenhoskins
May 31 2016 10:20
Excellent. Will give this a go.
Owen Hoskins
@owenhoskins
May 31 2016 11:34
Got a Docker custom image build conundrum. Building a freshly pulled reaction 0.13 development branch yesterday worked. But today repeating the same steps throws a
/opt/reaction/build-meteor.sh: line 24:  4058 Killed                  meteor build --directory $APP_BUNDLE_DIR
The command '/bin/sh -c bash $BUILD_SCRIPTS_DIR/install-deps.sh &&    bash $BUILD_SCRIPTS_DIR/install-mongodb.sh &&     bash $BUILD_SCRIPTS_DIR/install-node.sh &&    bash $BUILD_SCRIPTS_DIR/install-phantom.sh &&     bash $BUILD_SCRIPTS_DIR/install-meteor.sh &&      cd $APP_SOURCE_DIR &&     bash $BUILD_SCRIPTS_DIR/build-meteor.sh &&    bash $BUILD_SCRIPTS_DIR/post-build-cleanup.sh' returned a non-zero code: 137
:worried:
Brent Hoover
@zenweasel
May 31 2016 12:27
I can guarantee nothing changed today
Valery Orloff
@valorloff
May 31 2016 13:49
@zenweasel where is from landing: item === "standard" ? false : true, ?
i don't find that in cfs.Media.filerecord fields
Brent Hoover
@zenweasel
May 31 2016 13:51
that’s part of setting the metadata
that part might only be applicable to Micheal
Valery Orloff
@valorloff
May 31 2016 14:48
I tried your above example:
Error: Unknown asset: https://drive.google.com/uc?export=download&id=0B2hX...
at Object.Future.wait problem,
why?
Michael Jenny
@prinzdezibel
May 31 2016 14:52
@valorloff: re: landing you don't need that. it's specific to my application
@valorloff re: unknown assets: You need to include the files in package.js
Brent Hoover
@zenweasel
May 31 2016 14:54
I will rewrite it to make it more generic to put in the tutorial but I just wanted to give it to @owenhoskins to try for his use
Michael Jenny
@prinzdezibel
May 31 2016 14:54
e.g.
 // Product images
  function getFilesFromFolder(packageName,folder){
      // local imports
      var _=Npm.require("underscore");
      var fs=Npm.require("fs");
      var path=Npm.require("path");
      // helper function, walks recursively inside nested folders and return absolute filenames
      function walk(folder){
          var filenames=[];
          // get relative filenames from folder
          var folderContent=fs.readdirSync(folder);
          // iterate over the folder content to handle nested folders
          _.each(folderContent,function(filename){
              // build absolute filename
              var absoluteFilename=folder+path.sep+filename;
              // get file stats
              var stat=fs.statSync(absoluteFilename);
              if(stat.isDirectory()){
                  // directory case => add filenames fetched from recursive call
                  filenames=filenames.concat(walk(absoluteFilename));
              }
              else{
                  // file case => simply add it
                  filenames.push(absoluteFilename);
              }
          });
          return filenames;
      }
      // save current working directory (something like "/home/user/projects/my-project")
      var cwd=process.cwd();
      // chdir to our package directory
      process.chdir("packages"+path.sep+packageName);
      // launch initial walk
      var result=walk(folder);
      // restore previous cwd
      process.chdir(cwd);
      return result;
  }

  var images = getFilesFromFolder("easyweasel-data", "private/images");
  api.addAssets(images, "server");
Valery Orloff
@valorloff
May 31 2016 15:24
whether BLOB is a valid content type of image file for
fileObj = new FS.File(image)?
Valery Orloff
@valorloff
May 31 2016 15:47
Does meteor method supports BLOB as parameter? I tried post file to meteor method by REST, but inside method transferred param is undefined, should it work?
newsiberian
@newsiberian
May 31 2016 16:14
@valorloff, hello, I believe you need to convert BLOB via EJSON.newBinary. I suggest you to google how to pass BLOB to server side (not only meteor). There was something about it on stackoverflow. Also there was something interesting in EJSON section in old meteor docs, don't remember...
@motoxuz
@motoxuz_twitter
May 31 2016 23:57
I have a question, when google browses my site/shopping cart it only sees this: "This site requires JavaScript. Please enable it in your browser settings." And this is shown in google results
Brent Hoover
@zenweasel
May 31 2016 23:59
You probably want to look at the spiderable package so you can render a search-engine friendly version of the site for spiders