creating a site which needs to communicate with magento database - php

I am currently working on (a part of) a site where people buy an item from a magento based e-commerce website. However, to use that item, they need to go to another website. Basically that "other" website is what I am working on (and doing it via codeigniter)
I dont know much about magento. the only information my website needs from the magento website is some information regarding products (id, name and status). This information will be linked to other tables, i.e the product ID may be a foreign key in a table in my database. I did a little research and was able to figure out how data is stored in the magento database.
Both websites will be on same server.
Now I have two options which I could think of to get products from the magento website into my website,
first is that I create insert,update and delete triggers for the required tables in the magento website so that when a product is added, modified or deleted, it first tries to do the same on my database, and if successful, continues to do it in the magento database.
second option is that I simply merge the two databases of my website and magento website creating a direct relation link between the tables.
Like I previously stated, I dont know much about magento. So i wanted to know which was the safer, better approach or if there was an approach I diddnt think of.
Any help would be appreciated. Thanks.
further clarification of task:
Basically there is a magento website (lets call it "WEBSITE A") which sells "products". When a person buys a "product", they are basically given a "code" for that product. To use this "code", they have to go to another website which I am building using codeigniter (lets call this "WEBSITE B").
Now as you can guess, the code needs to be used in WEBSITE B, and once used it unlocks stuff for the user based upon the product to which the code belonged.
As you can guess, this will create a lot of links between product and other stuff.
product although created in WEBSITE A , is used in WEBSITE B.

Your first option: Never duplicate data unless you can help it. Why couldn't you query the Magento database instead, since it's on the same server?
Your second option: Never merge databases that aren't related.
Both options are basically anti-patterns. What you should do is query the Magento database directly, or if you want to use the Magento helper functions, include Magento and use its API directly:
<?php
require_once 'path/to/Mage.php';
// Use Magento APIs
?>

Related

PHP add new product function, create new subfolder to the product

I have an e-commerce website, and in the admin menu, I want to create a function so the authorized users can add new products to the site. I have the form page and the PHP script that uploads the data to the MYSQL Database, but thats it.
If I want to see the data of the product, I have created a single product.php file which gets the id using the $_GET['id'] method, and a PHP script will show you all the information about the product with the selected id.
Now it would work perferctly for me, but since this is a webshop, the SEO ranking is a essential, but you can't get ranking to a single page (I mean it won't appear in the search engines if you search for a specific product which avalaible in my webshop). So I was wondering what would be the best way to add new products to the website and increase the SEO ranking.
My idea is to create dynamically a subfolder for all the added products, and put the connected files in that folder, so every products would have a unique folder, with a unique index.php page so they could get SEO ranking.
I need your opinions about this, because I have read a bunch of articles about this topic, but I haven't found an acceptable answer so far. So would my idea be acceptable, or do you guys know any better way to approach this situation?

Doctrine / ExtJS: Use model to create another model

I'm having difficulties implementing some of the features my client would like to have.
We're building a shopware shop, which is almost done. I've developed some plugins and customizations to have the shop fit my client, but I'm not the best at backend development using ExtJS and Doctrine.
The situation is: The shop sells car parts. We've bought a third-party plugin that allows us to enter ktype numbers for each product, so that the client can search for his/her car in the frontend and get all fitting products.
The plugin has it's own window in the backend, which isn't very comfortable.
So I created an extra tab in the article details, which displays all entries from the database using the third-party model.
That wasn't so hard since the model and database were created by the third-party plugin and I just had to query the data and display it.
What I'm trying to accomplish is: I added an extra column (selected) with a checkbox, where the admin can choose the cars the article fits to.
The plan was to read the textfield "ktypes" of the article on load, check all corresponding checkboxes and then when a checkbox is altered just save the new ktypes array to the article.
Problem is, that this way I can't sort by that column since it's not in the ExtJS store/model.
So now I'm thinking I'll create my own Model with all the columns from the third-party model, add a article_id column and a selected column and reference everything there.
What I don't know is: How to I get the contents of the third-party model into my own database?
The third-party plugin doesn't reference the article. The table only holds all car data imported from a csv list. The reference between an article and the data is just a textfield in the article details.
I thought about Doctrine associations, but I don't really have a reference point or foreign key...
Has anyone got an idea how to solve this?
Can share code if that helps...
Thanks!
I went in a different direction but still need help. Will post a new question though since it's a different topic.
Thanks for trying to help!

Joomla PHP code

I'm new in using Joomla and i need your help please.
I'm newly working in a company. The company bought a web shop from other company and the web shop is live now.
One button in one of the pages is responsible to place an order and the action for this button is to send an email with all the data about the orders to my company.
Now my task is to develop an API which does the following:
when clicking on that button the information should be handles in certain way and sent to other system which our company have and this system is used by my company to handle the different orders.
My problem is that i can't find the php page that contains the code which is creating these orders email in order to change it.
Is there is any tool or plugin which might help or do you have any idea how to handle this situation?
Hint: I'm not able to get any support from the company who programmed the web shop
It is very hard to tell you what to do when we don't even know which Joomla e-commerce extension you are using. Nevertheless, there are things that you can do to find out which file is doing the actual processing of the order.
However, before even doing that, you will need to define what "order processing" means. Is it when the order is saved to the database? Is it when the order is approved by the payment gateway?
In the first case, you will need to look up for code saving the data to the database (which is likely in the models folder of the extension - it might also be in the controllers), in the latter case, you will need to look up for the code processing the payment (which is likely in the controllers folder or the helpers folder).
Note that some "advanced" e-commerce extensions trigger events when an order is processed that you can use in a plugin in order to do what you want.

Setting up a wordpress site using two different database

I will try my best to describe the whole scenario as clearly as possible.
Wordpress site 1
Website name: Seller portal
Database: db1
Wordpress site 2
Website name: Customer portal
Database: db2
Both sites are made with (wordpress + woocommerce). Both db1 and db2 are hosted on the same server.
On site 1, as a merchant you can publish new products for sale and you can also view your sales report. Let's say, on db1, table a,b,c,d,e are used to host your product information and sales report.
As mentioned before, site 2 running on database db2. But only for the product and sales section, it directly communicates with db1 (table a,b,c,d,e).
Therefore, site 1 and 2 store their user info, theme info everything on different databases. But when it comes to product and sales section, they share the same database. So, when anyone buys anything on site 2, merchants instantly gets the sales info on site 1. And when merchant publishes a new product to sale on site 1, users of site 2 will instantly see that new product on site 2.
Can anyone directs me to the right path how to achieve this? From wp-config files I see option to connect to only one database.
Thank you.
Since the two sites are essentially the same instance, what is the purpose of having two separate databases?
If I had to use something like that I would try creating a network. It is pretty easy to set up and you end up with basically what you are describing, two different sites that run on the same data, but with only one database.
The only problem is that if you decide to try it you will have to handle the merging of the two databases yourself.

Should I use Wordpress Multisite?

I'm about to start on a new project but I'm doubting if I should use Multisite for the company's structure or not.
The situation is as follows;
Corporation is based in a few EU countries, which each of the country websites have a consumer website and a professional website.
My thought was; Use multisite to make the consumer/professional switch and use WPML for each website. Things went fine so far. Yet; all websites have one shared product database. I'd like to make a custom post type "Products" and have them available in every language on every website (Consumer/Pro). Yet I cant find a way to have it (easily managable) share that product database and its relations.
So there's my doubt on using MultiSite, and as of yet, I dont see any other option to get what I want; Consumer/Professional sites, all with their own content, but with a shared product database.
You can use the switch_to_blog() function within your product archive (http://codex.wordpress.org/WPMU_Functions/switch_to_blog). This would allow you to get the products from another site within the multisite. Then use restore_current_blog() to return back to your individual site.

Categories