我是magento2的新手,并使用2.1版。 我必须在购物车中添加多个产品,产品可以是任何类型,我想添加ajax验证以及此功能。
任何人都有想法实现这一目标吗?
谢谢, Chandan
答案 0 :(得分:0)
您好我获得了在购物车中添加多个产品的解决方案: 请参阅以下代码以在MAGENTO 2中实现此功能
import logging
import threading
import time
logging.basicConfig(level=logging.DEBUG,
format='(%(threadName)-10s) %(message)s',
)
def lock_holder():
logging.debug('Starting')
while True:
lock.acquire()
try:
logging.debug('Holding')
time.sleep(0.5)
finally:
logging.debug('Not holding')
lock.release()
time.sleep(0.5)
return
def worker():
logging.debug('Starting')
num_tries = 0
num_acquires = 0
while num_acquires < 3:
time.sleep(0.5)
logging.debug('Trying to acquire')
have_it = lock.acquire(0)
try:
num_tries += 1
if have_it:
logging.debug('Iteration %d: Acquired', num_tries)
num_acquires += 1
else:
logging.debug('Iteration %d: Not acquired', num_tries)
finally:
if have_it:
lock.release()
logging.debug('Done after %d iterations', num_tries)
lock = threading.Lock()
holder = threading.Thread(target=lock_holder), name='LockHolder')
holder.setDaemon(True)
holder.start()
worker = threading.Thread(target=worker, name='Worker')
worker.start()