Category:Computer programming books
Category:English-language booksQ:
Add to cart still keep the attribute of product
I have a Magento store with over 200,000 products, and some of them have children products.
I need to see all the products that are in the wishlist and can add all of them to the cart and this is the solution that I have found, but it can not see the attributes of the product like size, color, price etc.
$cart = Mage::getSingleton('checkout/cart');
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->setStoreId(Mage::app()->getStore()->getId());
foreach ($products as $product) {
$productId = $product->getId();
$storeId = Mage::app()->getStore()->getId();
$cart->addProduct($product, array('product'=>$productId, 'qty'=>1,'store'=>$storeId));
}
It will add all products that are in the wishlist to the cart but they will keep their attributes.
Can anyone help me with this?
A:
You have to add 'qty'=>1, 'from_date' => strtotime("from now") as new attributes to product array.
$cart = Mage::getSingleton('checkout/cart');
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->setStoreId(Mage::app()->getStore()->getId());
foreach ($products as $product) {
$productId = $product->getId();
$storeId = Mage::app()->getStore()->getId();
$cart->addProduct($product, array('product'=>$productId, 'qty'=>1, 'from_date' => strtotime("from now"),'store'=>$storeId));
}
Q:
Does a 'Window Size' value with Parse have to be greater than the number of rows in a table?
I am trying to update a value in my Parse DB and I get ac619d1d87
Related links:
Comments