1

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?

0

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.

  • Thanks. But I have already tried this Link 1 & 2 options, but the problem is I am using Megento with XAMPP, So there was an error like '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 the database installed and I am accessing it through phpmyadmin. I s there a way to fix this? – SMash May 22 '18 at 11:41
  • The store_website table comes default in Magento 2. If you don't have multiple stores setup, then you can export this table from any fresh Magento 2 installation and import it into your project. – Mohit Kumar Arora May 22 '18 at 11:58
  • Or please update your question, so that I can post the solution for this problem. I can post correct table structure and default entries of the table. – Mohit Kumar Arora May 22 '18 at 12:00
  • I have edited the question – SMash May 22 '18 at 12:29
  • @SMash, please check my updated answer. – Mohit Kumar Arora May 22 '18 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.