craftcms / digital-products

Sell digital products with Craft Commerce.
https://plugins.craftcms.com/digital-products
MIT License
18 stars 9 forks source link

Add product button disappeared #49

Closed kevadamson closed 4 years ago

kevadamson commented 4 years ago

Description

Add product button seems to have gone missing on /admin/digital-products/products

Also, if I try and "Save as a new product" I get the following error:

Integrity constraint violation – yii\db\IntegrityException SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'foo' for key 'digitalproducts_products_sku_unq_idx' The SQL being executed was: INSERT INTOdigitalproducts_products(id,postDate,expiryDate,typeId,promotable,taxCategoryId,price,sku,dateCreated,dateUpdated,uid) VALUES (1011, '2020-08-01 14:27:00', NULL, 1, 0, 1, '10', 'foo', '2020-08-19 17:19:32', '2020-08-19 17:19:32', 'a133ada6-c5ee-42f2-91e7-7e07d505b834') Error Info: Array ( [0] => 23000 [1] => 1062 [2] => Duplicate entry 'foo' for key 'digitalproducts_products_sku_unq_idx' ) ↵ Caused by: PDOException SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'foo' for key 'digitalproducts_products_sku_unq_idx' in /var/www/foo/vendor/yiisoft/yii2/db/Command.php at line 1293

Steps to reproduce

  1. /admin/digital-products/products

Additional info

Cloner 1.1.2 Conditional Fields 0.0.6 Control Panel Body Classes 2.2.1 Control Panel CSS 2.2.1 CP Field Inspect 1.2.1 Craft Commerce 3.2.2.1 Dashboard Begone 1.0.1 Digital Products 2.4.0 Expanded Singles 1.1.3 Express Forms 1.0.6 Field and Tab Permissions 1.4.0 Field Manager 2.1.8 Internal Assets 2.3.1 Redactor 2.7.1 Redactor Anchors 1.1.0 Redactor Custom Styles 3.0.4 Redactor nofollow link plugin 1.0.1 Single Cat 1.2.1 Super Table 2.6.1

kevadamson commented 4 years ago

Tried deleting product to add another, and the button has gone completely - so can't add any products now.

I've tried disabling plugins one by one, still not showing.

I've tried a fresh install of the plugin.

ThinkGraphical commented 4 years ago

Same issue, not related to your setup i guess..

kevadamson commented 4 years ago

Same issue, not related to your setup i guess..

@ThinkGraphical I've tried on a fresh project, and now Digital Products won't install at all - just sits in the plugins list as uninstalled. Sounds like a universal issue ...

spencech commented 4 years ago

Also just installed this (haven't used this plugin previously so assumed I was missing something), and cannot find a way to create a new digital product.

spencech commented 4 years ago

Just scanned the digital-products source code a little bit, and it seems like the Craft.DigitalProducts.ProductIndex.canCreateProducts Boolean is evaluating to false in the JS and obscuring the button (in this file: craft-dir/vendor/craftcms/digital-products/src/web/assets/cp/dist/js/DigitalProductsProductIndex.js). Specifically, it looks like the following "editable" attribute is undefined in the html and causing the issue:

if (!this.canCreateProducts && $source.data('editable')) {
     this.canCreateProducts = true;
}

Setting the initializer to true in the JS (~Line 21 of the aforementioned file, snippet below) temporarily solves the issue it seems @kevadamson; I at least got the button back and created a new product with it. Granted, this effectively promotes all users to product creators, so it might not be advisable in a system where that could cause trouble. At the very least, maybe turn the boolean on when you want to activate the button, then turn it off again to prevent unwanted access. Hack alert!

Craft.DigitalProducts.ProductIndex = Craft.BaseElementIndex.extend({

    productTypes: null,

    $newProductBtnGroup: null,
    $newProductBtn: null,

    canCreateProducts: true, //currently set to false in source code, this is the line I changed

Still, seems like a bug fix should hopefully come shortly for this.

lukeholder commented 4 years ago

Thanks for reporting that! 2.4.1 is now out with this fix. (7d52130f4228e2035ecf5125991f2a5bbaa51b6a , a42cd08363a0eeea0b2eb518078960a1b0099096)