Add external product to DB and basket

Hi guys

We have a shop that has an iframe of an external partner with products that the user can buy and add to the local(!) shopping cart. From there we have a link to a script, with the product parameters attached, something like:
http://www.myshop.com/addfromiframe.php?name=product&price=99&bla=bla etc.

We thought to do it like this:
[ol]
[li]Script receives values and stores them as a new product to the DB (which fields? is there a function for this?)
[/li][li]Flag product to avoid that it is shown in the local shop (maybe some cron to delete it later)
[/li][li]Add product to cart (using addToBasket?)
[/li][/ol]

Has anybody done this before and if yes, how?
Any input or known pitfalls?

Appreciate any input :slight_smile:
Dan

Hi,

we have done this for orders. Think of some securitystuff: If you miss them, one could very easily crash your DB!

You could add products to a hidfden category and set flag for “don’t show in searchresult”.

Best Joscha

Hi Dan,
ok let me ask some questions:
Your partner shop has a link/button with href simmilar to “http://www.myshop.com/addfromiframe.php?name=product&price=99&bla=bla”?. If no: how do you want to track the add2cart action?
If yes: Why not import the products instead of creating on the fly? and use “HDI 2Basket” or Oxids nativ functionallity.

You have access to the partner shop? If no: There might be some hurdles with verifying that the action came frome the partner site and not from a script kiddie :wink:

Otherwise it is quiet simple to add new products programatically:


$oArticle = oxNew("oxarticle");
$oArticle->assign ( array("oxarticles__active"=> 1,"oxarticles__oxtitle"=>"Super Product","oxarticles__oxprice"=>"9.99" ) );
$oArticle->save(); 

This should do the job (roughly).

regards

Rafael

[QUOTE=Rafael Dabrowski;78158]Hi Dan,
ok let me ask some questions:
Your partner shop has a link/button with href simmilar to “http://www.myshop.com/addfromiframe.php?name=product&price=99&bla=bla”?. If no: how do you want to track the add2cart action?
If yes: Why not import the products instead of creating on the fly? and use “HDI 2Basket” or Oxids nativ functionallity. [/QUOTE]

The partner shop has an URL like I described (partner-specific shop in an iframe). They maintain the catalogue (about 3mio products) and it’s changes on a regular basis. There is an API option, but far too expensive. So no way to import products :).

You have access to the partner shop? If no: There might be some hurdles with verifying that the action came frome the partner site and not from a script kiddie :wink:

Well, I guess I can handle that somehow. But I can’t avoid all cases I know that (like changing price etc.).

Otherwise it is quiet simple to add new products programatically:


$oArticle = oxNew("oxarticle");
$oArticle->assign ( array("oxarticles__active"=> 1,"oxarticles__oxtitle"=>"Super Product","oxarticles__oxprice"=>"9.99" ) );
$oArticle->save(); 

This should do the job (roughly).

regards

Rafael

Thanks for your reply and code input. I’m new to OXID… :slight_smile:

Best regards
Dan

@Rafael:

What is needed to actually get access to the classes/functions if I want to create all of this in a file separated from the rest of the shop? I mean which files do I need to include etc.
Maybe you can help me out before I search for hours… :slight_smile:

Thx
Dan

Hi Dan,
it should be enough to require modules/functions.php and core/oxfunctions.php

regards

Rafael

e: but why do you want to do that?