BigCommerce API: "Product Name is a Duplicate" `PUT: /catalog/products/${product_id}` - bigcommerce

I am sending the following payload to v3: PUT: /catalog/products/${product_id}
name: '**** C4129X HP 29X - High Yield - black - original - LaserJet - toner cartridge (C4129X) - for LaserJet 5000, 5000dn, 5000gn, 5000LE, 5000n, 5100, 5100dtn, 5100Le, 5100n, 5100se, 5100tn',
description: ' <section id="key-selling-points"> <h2>Key Selling Points</h2> <div class="content"><ul><li>Designed to work precisely with your LaserJet printer></li><li>Ultraprecise techology delivers optimum quality printouts></li><li>High-capacity cartridge means a lower cost per page></li></ul></div> </section> , <section id="marketing-description"> <h2>Marketing description</h2> <div class="content">The HP 29X Black LaserJet Toner Cartridge with Ultraprecise technology for the HP LaserJet 5000 and 5100 Printer series produces optimum quality output. The higher yield cartridge offers users a long lasting, reliable cartridge which reduces the number of cartridge replacements and printer down-time. This higher yield cartridge also provides customers with a low overall cost of ownership. Average cartridge yields 10000 pages. Declared yield value in acordance with ISO/IEC 19752.><br /></div> </section> , <section id="whats-in-the-box"> <h2>What\'s in the Box</h2> <div class="content"><ul><li>Recycling guide></li><li>Toner cartridge></li></ul></div> </section> ',
weight: 888,
width: 0,
depth: 0,
height: 0,
price: 0,
cost_price: 0,
retail_price: 0,
sale_price: 0,
tax_class_id: 0,
product_tax_code: '',
categories: [ 23 ],
brand_id: 38,
inventory_warning_level: 5,
inventory_tracking: 'product',
total_sold: 0,
fixed_cost_shipping_price: 0,
is_free_shipping: false,
is_visible: true,
is_featured: false,
warranty: null,
mpn: 'C4129X',
gtin: '',
availability: 'available',
availability_description: '',
condition: 'New',
is_condition_shown: false,
order_quantity_minimum: 0,
order_quantity_maximum: 0,
page_title: 'C4129X — HP 29X - High Yield - black - original - LaserJet - toner cartridge (C4129X) - for LaserJet 5000, 5000dn, 5000gn, 5000LE, 5000n, 5100, 5100dtn, 5100Le, 5100n, 5100se, 5100tn',
meta_keywords: [],
meta_description: 'C4129X — HP 29X - High Yield - black - original - LaserJet - toner cartridge (C4129X) - for LaserJet 5000, 5000dn, 5000gn, 5000LE, 5000n, 5100, 5100dtn, 5100Le, 5100n, 5100se, 5100tn',
view_count: 2,
price_hidden_label: '',
is_price_hidden: false
}
But Im getting an error saying
"error": "Error: Request returned error code: 409 and body: {\"status\":409,\"title\":\"The product name is a duplicate\",\"type\":\"https://developer.bigcommerce.com/api-docs/getting-started/api-status-codes\",\"errors\":{\"name\":\"The product name is a duplicate\"}
I dont see what is wrong... I only need to update. If the name happens to be the same as before — shouldnt it still be allowed

Have you tried searching your store to see if another product has a similar name? If you do a GET request for the same product_id, does it load successfully with the same product?

Related

Feature Importance and Model Score

Hi I was doing a practice on Random Forest Classifier using a credit card fraud dataset from Kaggle (https://www.kaggle.com/mlg-ulb/creditcardfraud).
First, I created model with 20 trees and fitted it into the full dataset (31 features), the model was able to get a score of around 99.95%. Subsequently, I checked the feature importance and it seems like feature 12, 14 and 17 was measured to be the most important features.
from sklearn.ensemble import RandomForestClassifier
x_train, x_test, y_train, y_test = train_test_split(df, y, test_size=0.25)
model = RandomForestClassifier(n_estimators=20, verbose=2)
model.fit(x_train, y_train)
model.score(x_test, y_test)
================================================================
[Parallel(n_jobs=1)]: Using backend SequentialBackend with 1 concurrent workers.
[Parallel(n_jobs=1)]: Done 1 out of 1 | elapsed: 0.0s remaining: 0.0s
[Parallel(n_jobs=1)]: Done 20 out of 20 | elapsed: 0.2s finished
0.999592708069998
================================================================
importance = model.feature_importances_
# summarize feature importance
for i,v in enumerate(importance):
print('Feature: %0d, Score: %.5f' % (i,v))
================================================================
Feature: 0, Score: 0.01206
Feature: 1, Score: 0.01748
Feature: 2, Score: 0.01454
Feature: 3, Score: 0.02275
Feature: 4, Score: 0.02935
Feature: 5, Score: 0.01019
Feature: 6, Score: 0.01946
Feature: 7, Score: 0.03668
Feature: 8, Score: 0.01059
Feature: 9, Score: 0.03032
Feature: 10, Score: 0.07120
Feature: 11, Score: 0.09098
Feature: 12, Score: 0.10580
Feature: 13, Score: 0.01147
Feature: 14, Score: 0.12103
Feature: 15, Score: 0.01332
Feature: 16, Score: 0.04959
Feature: 17, Score: 0.14742
Feature: 18, Score: 0.04764
Feature: 19, Score: 0.01404
Feature: 20, Score: 0.01091
Feature: 21, Score: 0.01968
Feature: 22, Score: 0.01265
Feature: 23, Score: 0.01125
Feature: 24, Score: 0.00876
Feature: 25, Score: 0.00678
Feature: 26, Score: 0.02034
Feature: 27, Score: 0.00833
Feature: 28, Score: 0.01272
Feature: 29, Score: 0.01267
I wanted to see how would the important features affect the model score and thus I went to drop a bunch of features to see what happens. However I realised that even after dropping all but feature 0 (which only has an importance of 0.01), the model score still remained very high (94%)
tiny_x_train = x_train.copy()
tiny_x_test = x_test.copy()
tiny_x_train.drop(df.columns.difference(['V1']), 1, inplace=True) #Feature 0 is V1
tiny_x_test.drop(df.columns.difference(['V1']), 1, inplace=True)
model.fit(tiny_x_train, y_train)
model.score(tiny_x_test, tiny_y_test)
================================================================
0.9473684210526315
I am guessing part of the reason why the score remained high was due to the data being very skewed (fraud happens in <1% of data). Is my assumption correct or is there anything else I have missed out here?
You are correct.
You are obtaining such a good accuracy because of dataset. For sure, if you check other scores of the confusion matrix (precision, recall,...) you will see that your model is not as a good as it seems.
As a final comment, imagine I create a model that always returns: "No Fraud". Which will be the accuracy of this silly model? Around 99%. So I recommend check the confusion matrix metrics to understand better the behavior of your model.

Drop in Fps while Reading From Camera

I have Two cameras, one is microsoft and another one is logitech.
For both cameras i have used the below pipeline.
gst-launch-1.0 -v v4l2src device=/dev/video1 ! videoconvert ! video/x-raw,format=I420,width=640,height=480 ! fpsdisplaysink
For Microsoft :
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0: last-message = rendered: 678, dropped: 10, current: 30.10, average: 29.71
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0: last-message = rendered: 678, dropped: 10, current: 30.10, average: 29.71
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0: last-message = rendered: 678, dropped: 10, current: 30.10, average: 29.71
But, when i moved my hand very close to the camera, or i closed the camera with my hand then the results are,
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0: last-message = rendered: 2554, dropped: 44, current: 7.52, average: 28.93
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0/GstTextOverlay:fps-display-text-overlay: text = rendered: 2558, dropped: 44, current: 7.51, average: 28.81
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0: last-message = rendered: 2558, dropped: 44, current: 7.51, average: 28.81
There is a Huge Drop in Frame Rate.
What is the problem in this scenario and how to resolve it??
For Logitech:
Same pipeline i had used, but the results are as follows,
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0: last-message = rendered: 0, dropped: 79, fps: 0.00, drop rate: 24.07
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0: last-message = rendered: 0, dropped: 79, fps: 0.00, drop rate: 24.07
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0: last-message = rendered: 0, dropped: 79, fps: 0.00, drop rate: 24.07
I am totally confused, What is the problem with these two scenario's??

kivy bind textiput to slider vlaue

I want to create a control panel which provides a slider for quick input but also an textinput to type in the exact value as float number. Additionally there shall be a label, which displays the actual value.
The problem is, that I am not quit shure how to link all three widgets to each other AND auto update them if one changes the value...
Everything is done in an external .kv file.
Here is my first attempt via id. It works but the textinput does not change its content if I change the sliders value. Does anyone have a better solution for my problem?
Thanks for your help :)
That's the content of test.kv:
<MainLayout>:
BoxLayout:
pos: self.parent.x + self.parent.width*0.1, self.parent.y
orientation: 'vertical'
BoxLayout:
orientation: 'horizontal'
Label:
color: 0, 0, 0, 1
font_size: 20
text: 'Position: ' + str(linear_pos_slider.value) + ' mm'
size: self.texture_size
Slider:
id: linear_pos_slider
orientation: 'horizontal'
max: 50
min: -50
padding: 1
value: float(linear_pos_ti.text)
step: 0.1
TextInput:
id: linear_pos_ti
size_hint: 0.2, 0.8
font_size: 20
text_color: 0, 0, 0, 1
input_filter: 'float'
multiline: 'False'
text: '0'
And here is the content of the test.py to make the application run:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.slider import Slider
from kivy.uix.floatlayout import FloatLayout
from kivy.core.window import Window
Window.clearcolor = (1, 1, 1, 1)
class MainLayout(BoxLayout):
pass
class Test(App):
def build(self):
return MainLayout()
if __name__ == "__main__":
Test().run()
You should just be able to bind them to each other:
Label:
color: 0, 0, 0, 1
font_size: 20
text: 'Position: ' + str(linear_pos_slider.value) + ' mm'
size: self.texture_size
Slider:
id: linear_pos_slider
orientation: 'horizontal'
max: 50
min: -50
padding: 1
value: float(linear_pos_ti.text)
step: 0.1
TextInput:
id: linear_pos_ti
size_hint: 0.2, 0.8
font_size: 20
text_color: 0, 0, 0, 1
input_filter: 'float'
multiline: 'False'
text: str(linear_pos_slider.value)
Although in practice, it would be better if you used a NumericProperty (or StringProperty) in the code and bound them to that. This has all the same advantages but it is cleaner and gives you easy access from the code side too.
Note that since the bindings are one-way (property -> widget), you will need to set it with on_* events:
Slider:
id: linear_pos_slider
orientation: 'horizontal'
max: 50
min: -50
padding: 1
value: root.value
on_value: root.value = self.value
step: 0.1
TextInput:
id: linear_pos_ti
size_hint: 0.2, 0.8
font_size: 20
text_color: 0, 0, 0, 1
input_filter: 'float'
multiline: 'False'
text: str(root.value)
on_text: root.value = float(self.text)
with:
from kivy.properties import NumericProperty, StringProperty
class MainLayout(BoxLayout):
value = NumericProperty(0.0)
pass

Change the colour of bubbles in Google visualization motion chart

I there a way where by I can define the colours of bubbles in a motion chart provided by Google visualization API ? I do not want to use the default colour scheme.
Thank you in advance.
I've not found an inbuilt way to do this. However, what you can do is assign each bubble a "colour" variable. Then you can set the colour of the bubbles to this variable. I have found that for 3 bubbles, setting one to 1, another to 1.5 and the third to 3 projects reasonable well (on the default colour scheme, yellow projects very poorly). This approach gives you limited control over the colour scheme.
It's 2017 and I have yet to find a good update for this. So here is the solution I came up with. HTH.
#views.py
# Bubble Chart: ID, X, Y Color, Size
data.append(['ID', 'X', 'Y', 'Category', 'Z'])
data.append(['', 0, 0, 'Cat 1', 0]) #<-- the order of
data.append(['', 0, 0, 'Cat 2', 0]) #<-- these fakeout items
data.append(['', 0, 0, 'Cat 3', 0]) #<-- is important
data.append(['', 0, 0, 'Cat 4', 0]) #<-- Blue, Red, Orange, Green - in that order
... for r in source:
data.append(r.a, r.b, r.c, r.d, r.e)
return render(
request,
'Template.html',
{
'title':'',
'year':datetime.now().year,
'org': org,
'data': json.dumps(data),
}
#in the scripts block of template.html
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable({{data|safe}});
var options = {
title: 'Bubble By Category Strategy',
hAxis: { title: 'X', ticks: [{v: 0, f:''}, {v: 1, f:'L'}, {v: 2, f:'M'}, {v: 3, f:'H'}, {v: 4, f:''}] },
vAxis: { title: 'Y', ticks: [{v: 0, f:''}, {v: 1, f:'L'}, {v: 2, f:'M'}, {v: 3, f:'H'}, {v: 4, f:''}] },
bubble: {
textStyle: {
fontSize: 11,
fontName: 'Lato',
}
}
};
var chart = new google.visualization.BubbleChart(document.getElementById('riskChart'));
chart.draw(data, options);
}
</script>

Dojo 1.5.0 Charting Legend missing

I just upgraded from Dojo 1.4.3 to 1.5.0 and noticed that my legend is now missing.
Anyone else have this problem??
I keep receiving the following error:
o is undefined in dojo.js line 73
This error occurs when
chart1.render(); //Graph shows but error causes the rest of the code in that javascript function to not execute (So, not legend because it's created after chart1.render(); line.
executes. Works perfect in release 1.4.3.
Does charting tests work for you? Go to Dojo Nightly Charting Tests and select a test, which uses Tooltips, e.g., test_event2d.html. If it works for you, see what is different in your setup. If you found the difference, and it is related to Dojo, please file a bug. Don't forget to mention a browser you use, and attach a minimalistic test case as a file.
Found the problem..It seems like a bug but not 100% sure...Here is how to recreate it using
the Dojo Nightly Charting Tests code and dojo version 1.5.0 (Any web browser):
NOTE: This error occurs when adding a series to plot "other" and calling chart1.render(); more than once. If chart1.render(); is only called once, no error and everything works as it should. See addSeries for "Series B"...Remove plot: "other" from "Series B" and everything works OK even if chart1.render() is called twice. This problem can also be recreated by just removing "markers: true" from the "default" addPlot and calling char1.render(); twice.
Warning: The HTML below in the code section isn't displaying 100% correctly but all the javascript code is present to recreate this problem easily.
Eugene: Thanks for the link to the testing page, that helped out. Also, should I file a bug report on this??
Event 2D
#import "dojo-release-1.5.0/dojo/resources/dojo.css";
#import "dojo-release-1.5.0/dijit/tests/css/dijitTests.css";
.dojoxLegendNode {border: 1px solid #ccc; margin: 5px 10px 5px 10px; padding: 3px}
.dojoxLegendText {vertical-align: text-top; padding-right: 10px}
dojo.require("dojox.charting.Chart2D");
dojo.require("dojox.charting.themes.PlotKit.green");
dojo.require("dojox.charting.action2d.Highlight");
dojo.require("dojox.charting.action2d.Magnify");
dojo.require("dojox.charting.action2d.MoveSlice");
dojo.require("dojox.charting.action2d.Shake");
dojo.require("dojox.charting.action2d.Tooltip");
dojo.require("dojox.charting.widget.Legend");
dojo.require("dojo.colors");
dojo.require("dojo.fx.easing");
var dc = dojox.charting;
var dur = 450;
var chart1;
makeObjects = function(){
chart1 = new dc.Chart2D("test1");
//chart1.setTheme(dc.themes.PlotKit.green);
chart1.addPlot("default", {type: "Default", lines: true, markers: true, tension:2});
chart1.addPlot("other", {type: "Lines",
hAxis: "other x",
vAxis: "other y"
});
chart1.addPlot("grid", {type: "Grid",
hMajorLines: true,
hMinorLines: false,
vMajorLines: true,
vMinorLines: false
});
chart1.addAxis("x", {min: 0, max: 6, majorTick: {stroke: "black", length: 3}, minorTick: {stroke: "gray", length: 3}});
chart1.addAxis("y", {vertical: true, min: 0, max: 10, majorTick: {stroke: "black", length: 3}, minorTick: {stroke: "gray", length: 3}});
chart1.addAxis("other x", {leftBottom: false, min: 0, max: 6, majorTick: {stroke: "black", length: 3}, minorTick: {stroke: "gray", length: 3}});
chart1.addAxis("other y", {leftBottom: false, vertical: true, min: 0, max: 10, majorTick: {stroke: "black", length: 3}, minorTick: {stroke: "gray", length: 3}});
chart1.addSeries("Series A", [{x: 0.5, y: 5}, {x: 1.5, y: 1.5}, {x: 2, y: 9}, {x: 5, y: 0.3}]);
chart1.addSeries("Series B", [{x: 0.3, y: 8}, {x: 4, y: 6, tooltip: "Custom tooltip"}, {x: 5.5, y: 2}], {plot: "other"});
var anim1a = new dc.action2d.Magnify(chart1, "default");
var anim1b = new dc.action2d.Tooltip(chart1, "default");
chart1.render();
chart1.render();
var legend1 = new dojox.charting.widget.Legend({chart: chart1, horizontal: false}, "legend1");
};
dojo.addOnLoad(makeObjects);
Event 2D
Go-->
Hover over markers, bars, columns, slices, and so on.
1: Markers, lines, 2D data, custom axis. Actions: Magnify, Tooltip.
That's all Folks!