Question

I need to add a button for 'Buy Now / Checkout' along with the 'add to cart' button. I need to display both of these buttons together in product gallery as well as product's detail view page. I have referred some of these reference [1]:https://github.com/mageprince/magento2-buynow

I am accessing this project through XAMPP without running apache2 or mysql services in separately. But I have installed them locally on my machine. When I follow those mentioned guidelines I am getting an error like this.

step ==> sudo php bin/magento setup:upgrade

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento2.store_website' doesn't exist, query was: SELECT store_website.* FROM store_website

I have created magento2 database in phpmyadmin and I am accessing it though phpmyadmin. So, how can I integrate this extension with my project?

Anybody can help me with this to figure it out, please?

Était-ce utile?

La solution

There are many free modules available for adding Buy Now button for the products.

Please check below links:

Link 1

Link 2

If you only want to send customer directly to checkout page after clicking on Buy Now button, then you can check the answer posted by Aaron Allen.

Updated answer for the Base table or view not found error for store_website table:

  • Please check whether store_website exists or not.
  • If the table does not exist, please run the following queries to create the table and fill default data:

 

CREATE TABLE store_website (
  website_id smallint(5) UNSIGNED NOT NULL COMMENT 'Website Id',
  code varchar(32) DEFAULT NULL COMMENT 'Code',
  name varchar(64) DEFAULT NULL COMMENT 'Website Name',
  sort_order smallint(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Sort Order',
  default_group_id smallint(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Default Group Id',
  is_default smallint(5) UNSIGNED DEFAULT '0' COMMENT 'Defines Is Website Default'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Websites';


INSERT INTO store_website (website_id, code, name, sort_order, default_group_id, is_default) VALUES
(0, 'admin', 'Admin', 0, 0, 0),
(1, 'base', 'Website 1', 0, 1, 1);

ALTER TABLE store_website
  ADD PRIMARY KEY (website_id),
  ADD UNIQUE KEY STORE_WEBSITE_CODE (code),
  ADD KEY STORE_WEBSITE_SORT_ORDER (sort_order),
  ADD KEY STORE_WEBSITE_DEFAULT_GROUP_ID (default_group_id);

ALTER TABLE store_website
  MODIFY website_id smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Website Id', AUTO_INCREMENT=3;
COMMIT;

Updated answer for the Base table or view not found error for store_group table:

Run the following queries in after choosing the correct database:

CREATE TABLE store_group (
  group_id smallint(5) UNSIGNED NOT NULL COMMENT 'Group Id',
  website_id smallint(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Website Id',
  code varchar(32) DEFAULT NULL COMMENT 'Store group unique code',
  name varchar(255) NOT NULL COMMENT 'Store Group Name',
  root_category_id int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Root Category Id',
  default_store_id smallint(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Default Store Id'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Store Groups';

INSERT INTO store_group (group_id, website_id, code, name, root_category_id, default_store_id) VALUES
(0, 0, 'default', 'Default', 0, 0),
(1, 1, 'main_website_store', 'Main Website Store', 2, 1);

ALTER TABLE store_group
  ADD PRIMARY KEY (group_id),
  ADD UNIQUE KEY STORE_GROUP_CODE (code),
  ADD KEY STORE_GROUP_WEBSITE_ID (website_id),
  ADD KEY STORE_GROUP_DEFAULT_STORE_ID (default_store_id);

ALTER TABLE store_group
  MODIFY group_id smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Group Id', AUTO_INCREMENT=2;

ALTER TABLE store_group
  ADD CONSTRAINT STORE_GROUP_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID FOREIGN KEY (website_id) REFERENCES store_website (website_id) ON DELETE CASCADE;
COMMIT;

Updated answer for the Base table or view not found error for store table:

Run the following queries in after choosing the correct database:

CREATE TABLE store (
  store_id smallint(5) UNSIGNED NOT NULL COMMENT 'Store Id',
  code varchar(32) DEFAULT NULL COMMENT 'Code',
  website_id smallint(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Website Id',
  group_id smallint(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Group Id',
  name varchar(255) NOT NULL COMMENT 'Store Name',
  sort_order smallint(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Store Sort Order',
  is_active smallint(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Store Activity'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Stores';

INSERT INTO store (store_id, code, website_id, group_id, name, sort_order, is_active) VALUES
(0, 'admin', 0, 0, 'Admin', 0, 1),
(1, 'default', 1, 1, 'Default Store View', 0, 1);

ALTER TABLE store
  ADD PRIMARY KEY (store_id),
  ADD UNIQUE KEY STORE_CODE (code),
  ADD KEY STORE_WEBSITE_ID (website_id),
  ADD KEY STORE_IS_ACTIVE_SORT_ORDER (is_active,sort_order),
  ADD KEY STORE_GROUP_ID (group_id);


ALTER TABLE store
  MODIFY store_id smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Store Id', AUTO_INCREMENT=2;


ALTER TABLE store
  ADD CONSTRAINT STORE_GROUP_ID_STORE_GROUP_GROUP_ID FOREIGN KEY (group_id) REFERENCES store_group (group_id) ON DELETE CASCADE,
  ADD CONSTRAINT STORE_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID FOREIGN KEY (website_id) REFERENCES store_website (website_id) ON DELETE CASCADE;
COMMIT;

Note: I assume that you have default Magento (with the single store setup) and there is no multi-store or multi-website setup.

Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top