4

我们如何为可配置产品的关联产品显示“注册以在该产品有货时收到通知”链接。

比如说,我们有一件 T 恤(一种可配置的产品),我们以 3 种尺寸出售它——中号、大号和超大号(简单的相关产品)。

当大尺寸缺货时,我们如何让用户订阅它以在它有货时通知它。

请注意,我已经在管理员中设置了此设置:

System > Configuration > Catalog > Allow Alert When Product Comes Back in Stock - Yes

我注意到此警报的 url 是这样的(它是针对我商店中的一种简单产品的):

http://localhost/mystore/index.php/productalert/add/stock/product_id/1/[some key]/[some key],,/

有什么方法可以直接调用这个 url,传递我们相关产品的产品 ID 吗?如果是这样,那么 URL 末尾的那些键呢?

请指导。

谢谢

4

3 回答 3

7

I added this link beside the out-of-stock associated product:

http://localhost/mysite/index.php/productalert/add/stock/product_id/[associated_product_id]/uenc/[any_key]/

For e.g.

http://localhost/mysite/index.php/productalert/add/stock/product_id/17/uenc/MTM0MzcyMDk0Mw==/

It does my job.

Only thing is, after successfully adding the alert record, it redirects to home page, instead of same page as in normal case.

This is due to [any_key], if we could somehow encrypt current page url [the any_key] just like magento does, we can have it redirect to same page also, after successful saving of alert record. Any ideas?

Thanks

Ok I got it finally!

The uenc key [any_key] is actually base64 encoding of current url.

So with the help of https://github.com/carlo/jquery-base64, I did:

var encodedUrl = $.base64.encode(window.location);

var redirectTo = 'http://localhost/mysite/index.php/productalert/add/stock/product_id/[associated_product_id]/uenc/' + encodedUrl + '/';

Hope this helps!

于 2012-07-31T07:57:49.820 回答
3

Magento 获取网址的方法是:

Mage::helper('productalert')->setProduct($_product)->getSaveUrl('stock')

于 2015-07-17T13:40:10.193 回答
1

Magento 已经使用了从管理面板设置缺货的功能,不幸的是它仅限于某些情况,因此我们无法从管理面板进行设置,无论哪种方式你都可以在上面提到的代码中进行设置,但它是一项手动任务,不能用链接一次又一次地完成。所以我认为最好使用现成的扩展,以防您有特定要求为客户设置产品库存警报功能并且他们可以订阅它。这是 Magento 2 管理良好的扩展,它可以帮助您设置产品警报和注册/订阅功能以及更多管理员可管理的功能。链接到 Magento 2 的缺货通知扩展 - https://www.mconnectmedia.com/out-of-stock-alert-magento2.html

于 2016-06-10T09:13:48.397 回答