We are displaying "SAVE DESIGN" button in Product view page. once Registered customer click on that button, we want to create new product with same product details with different [ random] sku. we want to display those products in custom tab under "My account" similar to "My wishlist".
1 Answer 1
this is not a full solution, but some puzzle pieces you can put together.
There should already be a lot of scripts out there to create a product programattically.
Here is just one from inchoo but you can look for others.
What you have to change.
You need to set the random SKU.
$sku = call your method to generate the sku.
$product->setSku($sku);
And you could add a new product attribute that is a reference to the customer id.
Let's say the attribute is called created_by_customer_id.
You will have to get the customer id from the session and set it on the product before calling save.
$customerId = Mage::getSingleton('customer/session')->getCustomerId();
$product->setCreatedByCustomerId($customerId);
And to display the products in the customer account you need to add a new menu item to account navigation.
And in the controller action that is linked to the menu can load a block that gets the products collection associated to the current user.
public function getCustomerProducts()
{
$customerId = Mage::getSingleton('customer/session')->getCustomerId();
$products = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('created_by_customer_id', $customerId);
return $products;
}
The template is up to you.
You can just loop through the products:
<?php foreach ($this->getCustomerProducts() as $product) :?>
<!-- your html here -->
<?php endforeach;?>
-
Those
puzzle piecesare valuable as diamonds..... you are the ultimate.....Baby in Magento– Baby in Magento2017年03月15日 13:33:05 +00:00Commented Mar 15, 2017 at 13:33