Thursday, 29 November 2018

How do Delete wishlist item in magento 1.9 by programatically?

  $wishList = Mage::getSingleton('wishlist/wishlist')->loadByCustomer($userId);
            $wishListItemCollection = $wishList->getItemCollection();
            foreach ($wishListItemCollection as $item) {
               $w_product_id = $item->getProductId();
                if ($w_product_id==$product_id) {
                    $item->delete();
                   
                    echo 'Deleted successfully';
                }else{
                    echo 'Not Deleted';

                }

How do List to wishlist item in magento 1.9 by programatically?

$itemCollection = Mage::getModel('wishlist/item')->getCollection()->addCustomerIdFilter($customarId);
 foreach($itemCollection as $product) {
                   
                    $product_id = $product->getId(),
                   
                 
                
            }

Wednesday, 28 November 2018

How do I add to wishlist in magento 1.9 by programatically?

$wishlist = Mage::getModel('wishlist/wishlist')->loadByCustomer($customerId, true);
$product = Mage::getModel('catalog/product')->load($productId);

$buyRequest = new Varien_Object(array()); // any possible options that are configurable and you want to save with the product

$result = $wishlist->addNewItem($product, $buyRequest);
$wishlist->save();

Friday, 23 November 2018

How to get list billing address and list shipping address by customer id in magento 1.9

$customerId = 2;
$customer = Mage::getModel('customer/customer')->load($customerId);
$defaultBilling  = $customer->getDefaultBilling();
$defaultShipping = $customer->getDefaultShipping();

$allAddress = Mage::getModel('customer/address')->getCollection()->setCustomerFilter($customer);

foreach ($allAddress as $address) {
    if($defaultBilling == $address->getId()) {
        // its customer default billing address
    } else if($defaultShipping == $address->getId()) {
        // its customer default shipping address
    } else {
        // its customer other address that saved
    }
}

Saturday, 27 October 2018

How to remove +/- symbol off the price in Magento 1.9 product custom option


 app/code/core/Mage/Catalog/Block/Product/View/Options/Abstract.php and edited the line number 127

$priceStr = $sign;

to look like this:

$priceStr = '';

Magento 1.9 product Custom Options - make every first radio button checked

<script type="text/javascript">
var $j = jQuery.noConflict();
$j(document).ready(function(){

    $j('.options-list input.radio:first').attr('checked','checked');
    opConfig.reloadPrice();
});
</script>

Thursday, 13 September 2018

How to Login with phone number without extension? [duplicate] in magento 1

Override Mage_Customer_AccountController to your local module and update loginPostAction function with below code.


    ......
    if ($this->getRequest()->isPost()) {
        $login = $this->getRequest()->getPost('login');
        // NEW CODE ADDED
        $phoneNumber = $login['username'];
        $customer = Mage::getResourceModel('customer/address_collection')
            ->addAttributeToSelect('telephone')
            ->addAttributeToFilter('telephone', $phoneNumber)
            ->getFirstItem()->getCustomer();
        if ($customer !== false) {
            $login['username'] = $customer->getEmail();
        }else{
            $login['username'] = $phoneNumber;
        }
        // NEW CODE COMPLETED
    .......