RealTimeDesigner Support Network
Wiki Forums Libraries Docs Support RealTimeDesigner Home

RealTimeDesigner WIKI

Magento Cart with RealTimeDesigner

Magento Cart is a very adaptable, open source ecommerce shopping cart platform that is widely used and well supported by a large community. Magento is especially adapted to an ecommerce site with a large array of products. Magento is written in PHP language and uses MYSQL database, the same platform as RTD itself.

The model we are presenting which combines Magento with RTD is by no means the only way to accomplish such a task but we believe it is a very good marraige, employing the strengths of each of the two products. If you find other ways to accomplish the same, we'd be glad to hear from you. The basics of our model are:

  1. Magento is used for a catalog and cart
  2. RTD is called for design using a “Design It Now” button placed in Magento
  3. RTD Design thumbnails and price calculations are pushed to Magento cart
  4. Transactions are handled through Magento Cart
  5. A bridge is used to link login data so that users see the solution as seamless

Each of these aspects are discussed in greater detail below.

Magento Installation

A standard Magento installation is required aside from the RTD. We recommend you choose a hosting company that is already supporting Magento users. There are several references for Magento around the web if you need more information. Basically, your installation will include a product in Magento for each and every product you wish to design in RTD.

Design It Now Button

The first step to combining Magento and RTD is to insert a “Design It Now” button within your magento site. The simplest way to do this is to insert a button image and HTML link for the RTD directly into your Magento product description. Because our site would have a large array of products, we chose a bit more complicated method that involves creating to attributes in magento. One attribute determines whether the product will be a “design online” type of product. The second attribute contains the external link for that product into RTD. This standardized our site so that the Design It Now button always appeared in the same location. Details for our method are below:

In Magento backend, create an Attribute Set for the special product type. Name the attribute set “Product Design Required”. Next, create 2 attributes as shown: Catalog > Manage Attributes > Add New Attribute

Attribute one:
  • Attribute name : Show “Design Online” button
  • Attribute code: launchdesign
  • Scope: Global
  • Catalog Input Type for Store: Yes/No
  • Values Required: Yes
  • Visible on Product View Page on Front-end: Yes
  • Used in Product Listing: Yes
Attribute two:
  • Attribute name : Design Link
  • Attribute code: design_link
  • Scope: Global
  • Catalog Input Type for Store: Text Field
  • Values Required: No
  • Visible on Product View Page on Front-end: Yes
  • Used in Product Listing: Yes

Assign these attributes to Attribute Set. Now when you create new products, the attributes will be available for all products.

Pushing the RTD Design to Magento Cart

Our model uses the RTD to calculate pricing. We found that Magento was far inferior to RTD for calculating the complex array needed that defines pricing of custom printed products. Once the user finishes his RTD design and clicks submit, you'll need a way to send this information automatically to RTD - both design and pricing information. This is done by using the RTD to “format” the data in a particular format and “teaching” Magento how to recieve that information. The RTD part is done using the EXTERNAL NOTIFICATION process which basically sends a formatted file to any web address that you instruct it to. You enter that web address as well as which data elements are to be passed into the EXTERNAL NOTIFICATION screen as shown HERE.

Magento by itself would not know what to do with the formatted file sent by RTD. A “bridge” is created by installing a PHP computer script called processing.php. This script tells magento where to place each piece of data sent by RTD. After the user clicks submit for the RTD design, the data is sent to Magento which processes it and displays the cart view with that item added to the cart. Users then continue shopping or checkout through Magento as they desire.

My work was conducted when Designer site had setting an option to redirectly to Magento site and follow the path of the Magento shops as follow: http://discountsignshop.com/funny/processing.php The process of obtaining product information from the page designer begins processing the file processing.php The steps in handling processing.php file includes:

1. Get product information from desginer following syntax: $ FIELD_VALUE_NAME = $ _REQUEST ['FIELD_VALUE'];
FIELD_VALUE which is the value from the configuration allows setting by administrator of designer site. These variables are named or defined in the admin.

2. After getting this information product, an important task that I will find out in-store product Magento . If Magento store this product does not exist, the page processor will take us back to the designer site.

I can only search for products by name:
Line 48 (Processing.php)
/ * get product name from URL * /
$ p_name_1 = $ _REQUEST ['p_name_1'];

And below this line you will find my way to connect to the database of Magento.

$ connection = Mage:: getSingleton ('core / resource') → getConnection (“core_read”);
$ query = 'SELECT
entity_id
FROM
catalog_product_entity_varchar
JOIN ON eav_attribute catalog_product_entity_varchar.attribute_id = eav_attribute.attribute_id
WHERE
catalog_product_entity_varchar.entity_type_id = 4 AND
eav_attribute.attribute_code = “name” AND
catalog_product_entity_varchar.value = ”'. $ p_name_1 .'”;';
$ result = $ connection→ fetchAll ($ query);
$ product_id = $ result [0] ['entity_id'];

catalog_product_entity_varchar.entity_type_id = 4 is default product type. You should not change anything. Keep my code and change the name of variables.

MYSQL query on the following command, if the product exists, you get the product_id to update prices for products and information of the product to cart. Update prices and other information is updated via a product option in Magento site, this option was named DESIGN DETAILS.

DESIGN DETAILS is textarea type , It will contain information of the product to store in the shopping cart and the price of the product from the designer site will be updated through this option.
Rates are calculated as shown below:

/ * UPDATE FOR OPTION PRICE OF PRODUCT IN Magento * /
$ p_total_price_1 = $ _REQUEST ['p_total_price_1'];
$ qty_1 = $ _REQUEST ['qty_1'];
$ price_option = $ p_total_price_1 / $ qty_1;
$ price_option = round ($ price_option, 4);
$ connection2 = Mage:: getSingleton ('core / resource') → getConnection (“core_write”);
$ query2 = 'UPDATE SET catalog_product_option_price catalog_product_option_price.price = ”'. $
price_option. '” WHERE catalog_product_option_price.option_id = “282”';
Product’s option id.
$ result2 = $ connection2→ query ($ query2);

The values are taken from the site designer you can find from line 78 to line 282.

Next, we will group the information into a text to assign this variable value option for newly updated. From line 284.
/ * START * All Fields MERGE /
$ opt =' ';

Line 404 to remove the special characters, such characters will break the link information when updating the product to cart via URL

$ options = str_replace ('&','+',$ opt);

From 405 lines to 420 lines as I do get the address of the site links magento.

Finally, if the product is found, meaning the results to search queries product_id, the page will be redirected to the Magento shopping cart site.

example:
I find products id = 275. The link to the shopping cart will have the following syntax:
checkout / cart / add? product = 275 & qty = 1 & options [282] = 'Text value of product design'

In general:

if ($ product_id !='') {?>
<script>
parent.location = ('<? php echo $ ur;?> / checkout / cart / add? product = <? php echo $ product_id;?> & qty = <? php echo $ _qty;?> & options [282] = <? php echo $ options;?>');
</ script>

If product not found on Magento site, user will be directed back to designer site.

<script>alert(“This product has expired OR We have no one.Please try again!”);
history.go(-1);
</script>

Note

User Login

The procedures above are adequate to complete RTD online design through Magento but does not address the issues encountered by Registered Users. If you have disabled this feature, nothing more is needed. If you desire to use the Registerred Users features of the RTD and Magento you should consider linking the login info for both. This gives returning visitors the ability to see what they bought before and recall previous designs. Without linking the logins, your users will be faced with a seperate login for each system which may prove clumbsy. To create the link for user logins you will need to install the following script. Be sure to edit the login credentials coded into the file to correspond with your RTD account.