719-286-0751 [email protected]

Support for custom product types with Mail Chimp 4 Magento

Support for custom product types with Mail Chimp 4 Magento

A number of our clients have custom product types in their Magento stores, such as gift cards, which they were unable to sync to their Mail Chimp accounts. Our clients were all using the Ebizmarts Mail Chimp 4 Magento extension. This extension currently only provides support for simple, virtual, downloadable and configurable product types. If you have any other product types or a custom product type in your Magento store, then you’ll see the following error under Newsletter -> Mail Chimp -> Mail Chimp Errors.

A product with the provided ID does not exist in the account for this list.

For one our clients in particular this was very problematic. All of their products are a custom product type, so none of their eCommerce data was appearing in Mail Chimp. To fix this we built a module that provides a work around for custom product types. Instead of syncing the product type as something custom it replaces this information with a “virtual” product type so the product can pass through. This does not fix the issue of bundled or grouped products, which is a separate issue around supporting variants. Also, if your custom product type is a complex product (uses multiple underlying SKUs) this fix will also not resolve your issue.

Here’s how to fix this issue for your store. That said, we do recommend having a developer implement this fix as it requires editing code!

UPDATE FILE: app/code/community/Ebizmarts/MailChimp/Model/Api/Products.php
On line 69, look for this code:


protected function _buildNewProductRequest($product, $batchId, $mailchimpStoreId, $magentoStoreId)
{
    $variantProducts = array();
    if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
          ...

This piece of code is where the Ebizmarts module constructs the API request to inform MailChimp about a product within your store. Above the `$variantProducts = ..` portion of the code, we are going to add a new line of code:


protected function _buildNewProductRequest($product, $batchId, $mailchimpStoreId, $magentoStoreId)
{
    if ($product->getTypeId() == 'YOUR-CUSTOM-PRODUCT-TYPE') {
        $product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE); 
    }
    $variantProducts = array();
    if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
          ...

Notice the ‘YOUR-CUSTOM-PRODUCT-TYPE’ portion of the code. You need to update this with the exact product type code for your custom product. This value can be found by running the below SQL query, updating the ‘YOUR-SKU’ to match the product sku in question:


select type_id FROM catalog_product_entity where sku = 'YOUR-SKU';

Finally, notice what the block of code is doing — essentially if a product comes through the Ebizmarts code that is a custom type, we are going to “trick” the module into treating it as a simple product. If you have a giftcard or other virtual product, you may want to instead set the type id to be virtual:


   ...
   if ($product->getTypeId() == 'YOUR-CUSTOM-PRODUCT-TYPE') {
        // Quick hack to force the product to appear as a simple product
        $product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_VIRTUAL);
   }
   ...

As a final note, please keep in mind that you will need to reapply this fix if you upgrade the Ebizmarts module in the future.

Once you have finished installing this fix on your site you will need to reset your errors and ecommerce data. To do this, log into the Magento admin and go to System -> Configuration -> Mail Chimp and then click these buttons:

Once your crons runs again you should see all your ecommerce data for custom product types, orders with custom product types and abandoned carts appear in Mail Chimp.

Need help with syncing custom product types to Mailchimp?

We’ve had a lot of experience customizing Magento. If you need help, head over to the Cadence Labs contact page, or email us at [email protected]. We provide support for this and other Magento issues at affordable rates. 

 

Submit a Comment

Your email address will not be published. Required fields are marked *

Install our webapp on your iPhone! Tap and then Add to homescreen.
Share This