将 Magento 与简单的静态网站集成

发布于 2024-08-08 06:13:21 字数 857 浏览 3 评论 0原文

Magento 是一个非常强大的电子商务平台。也就是说,它也非常复杂,我想知道是否有一种相对简单的方法来利用 Magento 作为我们的 mISV 网站的后端来履行订单,而无需实际“使用”Magento 的框架来构建网站、运行网站,换句话说,我不想使用内置的CMS等,因为我们已经建立了一个静态网站。我只是希望我们的“立即购买”按钮能够利用结账功能,并且希望能够使用后端部分来跟踪订单等。我能够使用 osCommerce“相当”轻松地完成此任务,但是 Magento事实证明,我的头脑有点难以理解,因为我才开始研究它几天。

我发现另一个人在 Magento wiki 上问了同样的问题(以及论坛中的其他人),但出于某种原因,他们都没有收到回复。我注意到 Stack Overflow 上可能有 Magento 专家,所以我想我应该在这里尝试一下。这是某人在其 wiki 上提出的一个问题的示例,它抓住了我想要完成的任务的本质:

嗨,据我了解,所有 购物车/电子商务解决方案 I 请参阅全功能 PHP 驱动的 Web 网站。这意味着所有页面 用户与之交互的,是服务器 产生的,因此,经验, 与magento绑定 框架/工作流程。我想 整合点点滴滴 我现有的电子商务/购物车 网站。实际上,我想 有:

1) 在产品信息页面上, “立即购买/添加到购物车”按钮添加 到购物车

2) 在每个页面上,查看购物车/结账 选项

3) 在结账页面上,附加 内容已经就位,具有 magento“结帐”块集成在 页面(而不是生成的整个页面 来自 Magento)。

你们有人用 Magento 做过这个吗?这是一个简单的单一产品网站,因此您可以分享的任何建议将不胜感激。

Magento is an awesomely powerful ecommerce platform. That said, it is also very complex, and I'd like to know if there is a relatively simple way to utilize Magento as our mISV site's backend to fulfill orders without actually "using" Magento's framework to build the site, run the site, etc. In other words, I don't want to use the built-in CMS, etc. since we have a static website already built. I'd just like our Buy Now buttons to utilize the checkout stuff, and would like to be able to use the back-end part to keep track of orders etc. I was able to accomplish this "fairly" easily with osCommerce, but Magento is proving to be a little more difficult to wrap my head around since I've only started looking at it for a few days now.

I found another person asking this same exact question on the Magento wiki (along with several others in the forum), and none of them ever receive a reply for some reason. I noticed that there are may Magento experts on Stack Overflow, so I thought I'd give it a go here. This is an example of one question asked by someone on their wiki, and it captures the essence of what I'm trying to accomplish:

Hi, as far as I understand, all
shopping cart/eCommerce solutions I
see are full featured PHP driven web
sites. This means that all the pages
the user interacts with, are server
generated, and thus, the experience,
is tied to the magento
framework/workflow. I’d like to
integrate bits and pieces of
eCommerce/shopping cart in my existing
website. Effectively, I’d like to
have:

1) on a product information page, a
“buy now/add to cart” button that adds
to a cart

2) on every page, a view cart/checkout
option

3) on a checkout page, with additional
content already in place, having the
magento “checkout” block integrated in
the page (and not the entire page generated
from Magento).

Have any of you done this with Magento? This is for a simple one-product website so any advice you could share would be highly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

撩起发的微风 2024-08-15 06:13:21

我们使用静态前端和 Magento 后端 (www.movi​​ngpicturebooks.com)。这相当简单。最大的挑战是您需要将前端硬编码到特定的产品 ID。如果您运行单独的开发和生产环境,那么保持它们同步可能是一个真正的问题。但这是另一个话题了。以下是您需要的部分:

1) 添加到购物车按钮 - 使用此链接格式:

/checkout/cart/add/?product=$PRODUCTID&qty=$QUANTITY

2) 购物车链接:/checkout/cart/

3) 结帐链接:/checkout/onepage/

4) 我的帐户链接:/customer/account/

5) 登录/注销:您需要在每个页面上有一小段 PHP 代码来访问 Magento 会话,然后根据它所在的位置呈现适当的链接。示例:

<?php

$include_file = $_SERVER['DOCUMENT_ROOT'] . '/app/Mage.php';
require_once ($include_file);
Mage::app("default");
Mage::getSingleton("core/session", array("name" => "frontend"));

if (empty($session)) {
        $session = Mage::getSingleton("customer/session");
}

if($session->isLoggedIn()) {
    $login_action = "Sign Out";
    $login_url = "/index.php/customer/account/logout/";
} else {
    $login_action = "Sign In";
    $login_url = "/index.php/customer/account/login/";
}

?>

6) 换肤:您提到想要将 Magento 购物车内容嵌入到您的设计模板中。您需要担心的不仅仅是购物车,还有我的帐户、登录、忘记密码等等。这是 Magento 中已完成一半记录的一个区域。做一点研究,你应该能够驾驭它。

We use a static front end with a Magento back end (www.movingpicturebooks.com). It's fairly straight-forward. The biggest challenge is that you need to hardcode your front end to specific product IDs. If you're running seperate development and production environments, it can be a real bitch to keep them in sync. But that's another subject. Here are the pieces you need:

1) Add to Cart buttons - Use this link format:

/checkout/cart/add/?product=$PRODUCTID&qty=$QUANTITY

2) Shopping Cart Link: /checkout/cart/

3) Checkout Link: /checkout/onepage/

4) My Account Link: /customer/account/

5) Login/Logout: You need to have a small bit of PHP code on every page to access the Magento session, and then depending on where it's at, render the appropriate link. Example:

<?php

$include_file = $_SERVER['DOCUMENT_ROOT'] . '/app/Mage.php';
require_once ($include_file);
Mage::app("default");
Mage::getSingleton("core/session", array("name" => "frontend"));

if (empty($session)) {
        $session = Mage::getSingleton("customer/session");
}

if($session->isLoggedIn()) {
    $login_action = "Sign Out";
    $login_url = "/index.php/customer/account/logout/";
} else {
    $login_action = "Sign In";
    $login_url = "/index.php/customer/account/login/";
}

?>

6) Skinning: You mention wanting to embed the Magento Shopping Cart stuff in your design template. It's not just the cart you need to worry about - it's My Account, Login, Forget Password, all sorts of stuff. This is the one area of Magento that's halfway documented. Do a little research and you should be able to rock it.

调妓 2024-08-15 06:13:21

1) 在产品信息页面上,
“立即购买/添加到购物车”按钮添加
到购物车

也许这个< /a> 问题会帮助你(看问题,而不是答案:-)),因为它展示了如何通过链接到某个 URL 将项目添加到购物车,这使得可以从 Magento 外部执行此操作。

2) 在每个页面上,查看购物车/结账
选项

您想实际显示购物车中的商品还是只是有一个指向购物车/结帐的链接?后者显然是微不足道的。

3) 在结账页面上,附加
内容已经就位,具有
magento“结帐”块集成在
页面(而不是整个页面)
从 Magento 生成)。

我认为这应该是可能的,但需要您研究 Magento 的内部结构。为此,您必须

  • 将 Magento 的 JS 和 CSS 文件包含到您的网站中

  • 在 Magento 中伪造一个结帐请求(通过模仿 Magento 的引导程序并注入您自己的 Mage_Core_Controller_Request_Http 实例以及您的虚假结帐 URL)

  • 捕获假请求的输出(如果你无法弄清楚你仍然可以使用 ob_start 等,这应该可以通过 ZF 实现)

  • 打印出您自己站点中的 html 代码

这对您来说应该不会太难。

至于其余的,您实际上不必做太多事情,因为(一页)结帐基于 AJAX 调用,可能不会干扰您的实际站点。

我无法告诉你这是否会像 osCommerce 一样简单(还没有使用过),但我非常肯定它应该是可行的。

1) on a product information page, a
“buy now/add to cart” button that adds
to a cart

Maybe this question will help you(look at the question, not the answer :-) ) as it shows how to add an item to the cart by linking to a certain URL which would make it possible to do this from outside of Magento.

2) on every page, a view cart/checkout
option

Do you want to actually show the items in the cart or simply have a link to the cart/checkout? The latter would be trivial obviously.

3) on a checkout page, with additional
content already in place, having the
magento “checkout” block integrated in
the page (and not the entire page
generated from Magento).

I think that should be possible, but would require you to look into the internals of Magento. To do this you would have to

  • include Magento's JS and CSS files into your site

  • fake a checkout request in Magento(by mimicing the bootstrap of Magento and injecting your own instance of Mage_Core_Controller_Request_Http with your fake URL of a checkout)

  • capture the output of the fake request(that should be possible via the ZF if you can't figure it out you can still use ob_start and the like)

  • print out the html code in your own site

If you have had experience with the Zend Framework this shouldn't be too hard for you.

As for the rest you won't have to do much really, since the (onepage) checkout is based on AJAX calls that probably don't interfere with you actual site.

I can't tell you if this is going to be as easy as with osCommerce(haven't been using it), but I'm very positive that it should doable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文