In this developer documentation for the Magento Estimated Delivery Date Extension, you will find step-by-step instructions, sample code, and API references to fully customize your plugin.
Estimated Delivery Date Manual Configuration
Estimated Delivery Date module will automatically add “Delivery Dates” on Product Page if enabled in back-end. However, you can change standard “Delivery Date” display or position in the front-end. To do this follow the instructions below.
Product Page
To have the Delivery Date displayed on the page, make sure you have the corresponding block in the layout template file:
/app/design/frontend/default/default/layout/catalog.xml
<block type="estimateddelivery/product" name="estimateddelivery_product"
as="estimateddelivery" template="estimateddelivery/product.phtml" />
Now, edit HTML template and place following code in desired place on Product Page:
/app/design/frontend/default/default/template/catalog/product/view.phtml
<?php echo $this->getChildHtml('estimateddelivery') ?>
The changes in the code above are enough to display “Estimated Delivery Date” on Product Page. However you can also change design of Estimated Delivery block. To do this, edit corresponding file:
/theme_path/default/template/estimateddelivery/product.phtml
Category Page
In order to add the Estimated Delivery to the category page, you will have to edit the file:
/app/design/frontend/<your active theme>/default/template/catalog/category/view.phtml
and enter the following code where the desired block should be located.
<?php echo $this->getChildHtml('estimateddelivery')?>
Display Estimated Delivery Dates and Shipping Dates in Magento for Specific Categories & Products
The following methods in “Plumrocket_Estimateddelivery_Block_Product” block allow to show shipping and delivery dates for specific products:
setProduct($product)
Allows to set the product for which the dates will be shown.
Example:
Let’s show the date for “related” products on Product Page:
$relatedProducts = get_related_products(); // where get_related_products() is some custom
method to retrieve related products
$estimatedBlock = $this->getLayout()->createBlock('estimateddelivery/product')
->setTemplate('estimateddelivery/product.phtml');
foreach ($relatedProducts as $_product) {
echo $estimatedBlock->setProduct($_product)->toHtml();
}
Example:
On Product Page with custom design we can display dates for “related” products and immediately after that display dates for the current product:
<div class="related_dates">
<?php
$relatedProducts = get_related_products(); // where get_related_products() is some
custom method to retrieve related products
foreach ($relatedProducts as $_product) {
echo $this->getChild('estimateddelivery')->setProduct($_product)->toHtml();
} ?>
</div>
<div class="main_date">
<?php $this->getChild('estimateddelivery')->reset()->toHtml(); ?>
</div>
setCategory($category)
Allows to set the category for which the dates will be shown.
Example:
Let’s display html block that contains delivery date for the set category:
$customCategory = Mage::getModel('catalog/category')->load(<any id>);
echo $this->getLayout()->createBlock('estimateddelivery/product')
->setTemplate('estimateddelivery/category.phtml')->setCategory($customCategory)
->toHtml();
getProduct()
Allows to get the product for which the dates will be shown. Note: If no product was indicated manually – current product will be returned on Product Page.
getCategory()
Allows to get the category for which the dates will be shown. Note: If no category was indicated manually – current category will be returned on Product Page or Category Page.
reset()
Allows to clear all current settings. After calling this method, the other methods (getProduct and getCategory) will return current product (on Product Page) and current category (on Product Page or Category Page) accordingly.This method comes handy for displaying dates of custom products (categories) on the product (category) page, and for returning to default settings.
Example code of layout.xml file:
Let’s display block with date for the product by inserting it into the layout:
<catalog_product_default>
<reference name="content">
<block type="estimateddelivery/product" name="estimateddelivery_product"
as="estimateddelivery" template="estimateddelivery/product.phtml" />
</reference>
</catalog_product_default>
Fixing issue with estimated delivery attribute import
Magento has a problem with importing product attribute values that have custom source model.
1. In order to import the attributes correctly using Magento import, you need to perform some changes in the code.
Please, follow the instructions below.
Find the file:
/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php
and copy it into the file:
/app/code/local/Mage/ImportExport/Model/Import/Entity/Product.php
Open created file and change the following code:
protected $_indexValueAttributes = array('status', 'tax_class_id', 'visibility',
'gift_message_available', 'custom_design' );
to this code:
protected $_indexValueAttributes = array('estimated_delivery_enable',
'estimated_shipping_enable', 'status', 'tax_class_id', 'visibility',
'gift_message_available', 'custom_design'
);
Save your changes
2. If you are using Magmi for import, you need to change the code in this software, as it has the same issue as Magento.
Please, follow the instructions below to change the code.
Find and edit file:
/magmi/plugins/inc/magmi_defaultattributehandler.php
After the following code in method handleIntAttribute :
// if it's tax_class, get tax class id from item value
case "tax/class_source_product":
$ovalue = $this->getTaxClassId($ivalue);
break;
add next code lines:
// if it's estimated delivery class
case "estimateddelivery/attribute_source_enable":
$ovalue = $ivalue;
break;
It should look like this:
// if it's tax_class, get tax class id from item value
case "tax/class_source_product":
$ovalue = $this->getTaxClassId($ivalue);
break;
// if it's estimated delivery class
case "estimateddelivery/attribute_source_enable":
$ovalue = $ivalue;
break;