0

I am developing a feature by name "Quick Order" in product page where I have to take the custom options and configurable options from the last ordered item and add the same with the product which I am viewing ..

I tried to use the reorder functionality with some customization but it did not work ..it says "Please specify the product's option(s)."..

If anybody knows the how this can be achieved it will be very helpful ...

2 Answers 2

0

Hi i am assuming that you are taking last order item is the item which you are viewing. for implement you requirement you need first load order item object of that item from order object. You can take order item object from item collectoin by adding product filter like blow:

<?php $orderItems=Mage::getModel('sales/order_item')->getCollection()
                 ->addFieldToFilter('product_id',$_product->getId());
      $latestitem = $orderItems->getLastItem(); ?>

After loading product option you can create hidden input and in which you can define product option as value like below:

<input type="hidden" name="quickproductoption" value="<?php echo $latestitem->getProductOptions(); ?>"/>

Now in add quick product action you can get the data from quickproductoption input and add it programmatically like below:

<?php
/* load $product from request product id */
$cart = Mage::getSingleton('checkout/cart');
$data = $this->getRequest()->getPost('quickproductoption');
$params = $data['info_buyRequest'];
$params['qty'] = 1;
$cart->addProduct($product, $params);
?>

I hope it will help you

0
-1

Please try to get option id of size of size using eav attibute the programically create an cart url For more information contact us.

<?php
$ConfigProduct=Mage::getModel('catalog/product')->load($cpid);
$GetAllowAttributes=$ConfigProduct->getTypeInstance(true)
            ->getConfigurableAttributes($ConfigProduct);

 foreach ($GetAllowAttributes() as $attribute) {
                $productAttribute   = $attribute->getProductAttribute();
               $attribute_code= $productAttribute->getAttributeCode();
               $attributeid=$productAttribute->getId();
               break;


 }
$attribute_details = Mage::getSingleton("eav/config")->getAttribute("catalog_product", $attribute_code);
$options = $attribute_details->getSource()->getAllOptions(false);
foreach($options as $option){
    // print_r($option) and find all the elements
    //echo $option["value"];
    //echo $option["label"];
    if($option["label"]==$youlabel){
        $opid=$option["value"];
         $cartUrl=Mage::helper('checkout/cart')->getAddUrl($ConfigProduct).'?super_attribute['.$attributeid.']='.$option["value"].'&qty=1';
         break;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.